Skip to content

Commit

Permalink
fix: RepeatDialog not shown (#1835)
Browse files Browse the repository at this point in the history
* render fallback node

* fix the problem in a more schema-driven way

* revert unnecessary changes
  • Loading branch information
yeze322 authored and cwhitten committed Jan 8, 2020
1 parent 25b2fae commit 8a8d205
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import { ActionCard } from '../widgets/ActionCard';
import { UISchema } from './uischema.types';

export const uiSchema: UISchema = {
default: {
'ui:widget': ActionCard,
},
[SDKTypes.EditArray]: {
'ui:widget': ActionCard,
content: data => `${data.changeType} {${data.itemsProperty || '?'}}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
import { FC, ComponentClass } from 'react';
import { BaseSchema, SDKTypes } from '@bfc/shared';

export enum UISchemaBuiltinKeys {
default = 'default',
}

/** schema */
export type UISchema = {
[key in SDKTypes]?: UIWidget;
[key in SDKTypes | UISchemaBuiltinKeys]?: UIWidget;
};

/** widget */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,9 @@ const renderWidget = (inputData, schema: UIWidget, contextProps = {}): JSX.Eleme
return <Widget data={inputData} {...contextProps} {...props} />;
};

const renderFallbackElement = (data: BaseSchema) => <></>;

export const renderSDKType = (data: BaseSchema, context?: { menu: JSX.Element; onClick }): JSX.Element => {
const $type = get(data, '$type');
const schema: UIWidget = get(uiSchema, $type);
if (!schema) return renderFallbackElement(data);
const schema = get(uiSchema, $type, uiSchema.default);

return renderWidget(data, schema, context);
};

0 comments on commit 8a8d205

Please sign in to comment.