Add functionality for fetching global styles from server
[MAILPOET-6335]
This commit is contained in:
committed by
Aschepikov
parent
708969954a
commit
f906cd686f
@ -24,6 +24,9 @@ export function getInitialState(): State {
|
|||||||
postId,
|
postId,
|
||||||
editorSettings: getEditorSettings(),
|
editorSettings: getEditorSettings(),
|
||||||
theme: getEditorTheme(),
|
theme: getEditorTheme(),
|
||||||
|
styles: {
|
||||||
|
globalStylesPostId: 153, // Todo - fetch from DB
|
||||||
|
},
|
||||||
autosaveInterval: 60,
|
autosaveInterval: 60,
|
||||||
cdnUrl: getCdnUrl(),
|
cdnUrl: getCdnUrl(),
|
||||||
isPremiumPluginActive: isPremiumPluginActive(),
|
isPremiumPluginActive: isPremiumPluginActive(),
|
||||||
|
@ -7,6 +7,7 @@ import { serialize } from '@wordpress/blocks';
|
|||||||
import { BlockInstance } from '@wordpress/blocks/index';
|
import { BlockInstance } from '@wordpress/blocks/index';
|
||||||
import { storeName } from './constants';
|
import { storeName } from './constants';
|
||||||
import { State, Feature, EmailTemplate, EmailEditorPostType } from './types';
|
import { State, Feature, EmailTemplate, EmailEditorPostType } from './types';
|
||||||
|
import { Post } from '@wordpress/core-data/build-types/entity-types/post';
|
||||||
|
|
||||||
export const isFeatureActive = createRegistrySelector(
|
export const isFeatureActive = createRegistrySelector(
|
||||||
( select ) =>
|
( select ) =>
|
||||||
@ -220,6 +221,21 @@ export const getCurrentTemplate = createRegistrySelector( ( select ) => () => {
|
|||||||
return getEditedPostTemplate();
|
return getEditedPostTemplate();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
export const getGlobalEmailStylesPost = createRegistrySelector(
|
||||||
|
( select ) => () => {
|
||||||
|
const postId = select( storeName ).getGlobalStylesPostId();
|
||||||
|
|
||||||
|
if ( postId ) {
|
||||||
|
return select( coreDataStore ).getEditedEntityRecord(
|
||||||
|
'postType',
|
||||||
|
'wp_global_styles',
|
||||||
|
postId
|
||||||
|
) as unknown as Post;
|
||||||
|
}
|
||||||
|
return getEditedPostTemplate();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the email templates.
|
* Retrieves the email templates.
|
||||||
*/
|
*/
|
||||||
@ -292,6 +308,10 @@ export function getTheme( state: State ): State[ 'theme' ] {
|
|||||||
return state.theme;
|
return state.theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getGlobalStylesPostId( state: State ): number | null {
|
||||||
|
return state.styles.globalStylesPostId;
|
||||||
|
}
|
||||||
|
|
||||||
export function getUrls( state: State ): State[ 'urls' ] {
|
export function getUrls( state: State ): State[ 'urls' ] {
|
||||||
return state.urls;
|
return state.urls;
|
||||||
}
|
}
|
||||||
|
@ -179,6 +179,9 @@ export type State = {
|
|||||||
postId: number;
|
postId: number;
|
||||||
editorSettings: EmailEditorSettings;
|
editorSettings: EmailEditorSettings;
|
||||||
theme: EmailTheme;
|
theme: EmailTheme;
|
||||||
|
styles: {
|
||||||
|
globalStylesPostId: number | null;
|
||||||
|
};
|
||||||
autosaveInterval: number;
|
autosaveInterval: number;
|
||||||
cdnUrl: string;
|
cdnUrl: string;
|
||||||
urls: EmailEditorUrls;
|
urls: EmailEditorUrls;
|
||||||
|
Reference in New Issue
Block a user