Skip to content

Commit

Permalink
Merge branch 'master' into recentBotsOrder
Browse files Browse the repository at this point in the history
  • Loading branch information
cwhitten authored May 15, 2020
2 parents f9f4f5e + 5f8181b commit c9ba980
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface FlowEditorConfig {
export type FlowEditorWidgetMap = { [widgetName: string]: WidgetComponent<any> };
export enum FlowSchemaBuiltinKeys {
default = 'default',
custom = 'custom',
}

/** schema */
Expand Down
12 changes: 10 additions & 2 deletions Composer/packages/extensions/visual-designer/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React, { useRef, useMemo } from 'react';
import isEqual from 'lodash/isEqual';
import formatMessage from 'format-message';
import { DialogFactory } from '@bfc/shared';
import { useShellApi, JSONSchema7 } from '@bfc/extension';
import { useShellApi, JSONSchema7, FlowSchema } from '@bfc/extension';

import { ObiEditor } from './editors/ObiEditor';
import { NodeRendererContext, NodeRendererContextValue } from './store/NodeRendererContext';
Expand All @@ -17,6 +17,7 @@ import { FlowSchemaContext } from './store/FlowSchemaContext';
import { FlowSchemaProvider } from './schema/flowSchemaProvider';
import { mergePluginConfig } from './utils/mergePluginConfig';
import { getCustomSchema } from './utils/getCustomSchema';
import { defaultFlowSchema } from './schema/defaultFlowSchema';

formatMessage.setup({
missingTranslation: 'ignore',
Expand Down Expand Up @@ -108,6 +109,13 @@ const VisualDesigner: React.FC<VisualDesignerProps> = ({ schema }): JSX.Element
};

const visualEditorConfig = mergePluginConfig(...plugins);
const customFlowSchema: FlowSchema = nodeContext.customSchemas.reduce((result, s) => {
const definitionKeys: string[] = Object.keys(s.definitions);
definitionKeys.forEach($kind => {
result[$kind] = defaultFlowSchema.custom;
});
return result;
}, {} as FlowSchema);

return (
<CacheProvider value={emotionCache}>
Expand All @@ -116,7 +124,7 @@ const VisualDesigner: React.FC<VisualDesignerProps> = ({ schema }): JSX.Element
<FlowSchemaContext.Provider
value={{
widgets: visualEditorConfig.widgets,
schemaProvider: new FlowSchemaProvider(visualEditorConfig.schema),
schemaProvider: new FlowSchemaProvider(visualEditorConfig.schema, customFlowSchema),
}}
>
<div data-testid="visualdesigner-container" css={styles}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export const defaultFlowSchema: FlowSchema = {
default: {
widget: 'ActionHeader',
},
custom: {
widget: 'ActionHeader',
colors: { theme: ObiColors.Gray20, color: ObiColors.White },
},
[SDKKinds.IfCondition]: {
widget: 'IfConditionWidget',
nowrap: true,
Expand Down

0 comments on commit c9ba980

Please sign in to comment.