2019-09-19 22:25:37 +00:00
|
|
|
import { AppState } from "../reducers";
|
|
|
|
|
import { FlattenedWidgetProps } from "../reducers/entityReducers/canvasWidgetsReducer";
|
|
|
|
|
import { WidgetProps } from "../widgets/BaseWidget";
|
2019-10-02 18:13:04 +00:00
|
|
|
import { WidgetType } from "../constants/WidgetConstants";
|
2019-09-19 22:25:37 +00:00
|
|
|
export const getWidgets = (
|
|
|
|
|
state: AppState,
|
|
|
|
|
): { [widgetId: string]: FlattenedWidgetProps } => {
|
|
|
|
|
return state.entities.canvasWidgets;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const getWidget = (state: AppState, widgetId: string): WidgetProps => {
|
|
|
|
|
return state.entities.canvasWidgets[widgetId];
|
|
|
|
|
};
|
2019-09-22 20:25:05 +00:00
|
|
|
|
|
|
|
|
export const getEditorConfigs = (
|
|
|
|
|
state: AppState,
|
|
|
|
|
): { pageId: string; layoutId: string } => {
|
|
|
|
|
const { currentLayoutId, currentPageId } = state.ui.editor;
|
|
|
|
|
return {
|
|
|
|
|
pageId: currentPageId,
|
|
|
|
|
layoutId: currentLayoutId,
|
|
|
|
|
};
|
|
|
|
|
};
|
2019-09-25 18:33:56 +00:00
|
|
|
|
2019-10-02 18:13:04 +00:00
|
|
|
export const getDefaultWidgetConfig = (
|
|
|
|
|
state: AppState,
|
|
|
|
|
type: WidgetType,
|
|
|
|
|
): Partial<WidgetProps> => {
|
|
|
|
|
const configs = state.entities.widgetConfig.config;
|
|
|
|
|
const widgetConfig = { ...configs[type] };
|
|
|
|
|
delete widgetConfig.rows;
|
|
|
|
|
delete widgetConfig.columns;
|
|
|
|
|
return widgetConfig;
|
|
|
|
|
};
|