Skip to content

Commit

Permalink
fix(app-file-manager): use bind prefix context to render extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 committed Aug 21, 2024
1 parent 641d166 commit 7bb3196
Showing 1 changed file with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CompositionScope } from "@webiny/app-admin";
import { CmsModel } from "@webiny/app-headless-cms/types";
import { ModelProvider } from "@webiny/app-headless-cms/admin/components/ModelProvider";
import { Fields } from "@webiny/app-headless-cms/admin/components/ContentEntryForm/Fields";
import { Bind, BindComponentProps } from "@webiny/form";
import { Bind, BindPrefix } from "@webiny/form";

const HideEmptyCells = styled.div`
.mdc-layout-grid__cell:empty {
Expand All @@ -16,13 +16,6 @@ interface ExtensionsProps {
model: CmsModel;
}

function BindWithPrefix(props: BindComponentProps) {
return (
<Bind {...props} name={`extensions.${props.name}`}>
{props.children}
</Bind>
);
}
export const Extensions = ({ model }: ExtensionsProps) => {
const extensionsField = useMemo(() => {
return model.fields.find(f => f.fieldId === "extensions");
Expand All @@ -42,15 +35,17 @@ export const Extensions = ({ model }: ExtensionsProps) => {
return (
<CompositionScope name={"fm.fileDetails.extensionFields"}>
<ModelProvider model={model}>
<HideEmptyCells>
<Fields
contentModel={model}
// @ts-expect-error
Bind={BindWithPrefix}
fields={fields}
layout={layout}
/>
</HideEmptyCells>
<BindPrefix name={"extensions"}>
<HideEmptyCells>
<Fields
contentModel={model}
// @ts-expect-error
Bind={Bind}
fields={fields}
layout={layout}
/>
</HideEmptyCells>
</BindPrefix>
</ModelProvider>
</CompositionScope>
);
Expand Down

0 comments on commit 7bb3196

Please sign in to comment.