diff --git a/packages/dataclass-editor/src/context/AppContext.tsx b/packages/dataclass-editor/src/context/AppContext.tsx index cf334f5d..a27eed44 100644 --- a/packages/dataclass-editor/src/context/AppContext.tsx +++ b/packages/dataclass-editor/src/context/AppContext.tsx @@ -26,7 +26,8 @@ const appContext = createContext({ export const AppProvider = appContext.Provider; export const useAppContext = () => { - return useContext(appContext); + const context = useContext(appContext); + return { ...context, isHdData: context.context.file.includes('src_hd') }; }; type EntityClassContext = { diff --git a/packages/dataclass-editor/src/context/test-utils/test-utils.tsx b/packages/dataclass-editor/src/context/test-utils/test-utils.tsx index 46a97d31..d19fb778 100644 --- a/packages/dataclass-editor/src/context/test-utils/test-utils.tsx +++ b/packages/dataclass-editor/src/context/test-utils/test-utils.tsx @@ -30,7 +30,7 @@ type ContextHelperProps = { const ContextHelper = (props: ContextHelperProps & { children: ReactNode }) => { const appContext = { - context: props.appContext?.context ?? ({} as DataClassEditorDataContext), + context: props.appContext?.context ?? ({ file: '' } as DataClassEditorDataContext), dataClass: props.appContext?.dataClass ?? ({} as DataClass), setDataClass: props.appContext?.setDataClass ?? (() => {}), selectedField: props.appContext?.selectedField, diff --git a/packages/dataclass-editor/src/detail/dataclass/DataClassDetailContent.tsx b/packages/dataclass-editor/src/detail/dataclass/DataClassDetailContent.tsx index b3188c9e..392d321a 100644 --- a/packages/dataclass-editor/src/detail/dataclass/DataClassDetailContent.tsx +++ b/packages/dataclass-editor/src/detail/dataclass/DataClassDetailContent.tsx @@ -8,7 +8,7 @@ import { EntityClassDatabaseTable } from './entity/EntityClassDatabaseTable'; import { useDataClassProperty } from './useDataClassProperty'; export const DataClassDetailContent = () => { - const { dataClass, setDataClass } = useAppContext(); + const { dataClass, setDataClass, isHdData } = useAppContext(); const { setProperty } = useDataClassProperty(); return ( @@ -22,7 +22,7 @@ export const DataClassDetailContent = () => { annotations={dataClass.annotations} setAnnotations={(newAnnotations: Array) => setProperty('annotations', newAnnotations)} /> - + {!isHdData && } diff --git a/packages/dataclass-editor/src/detail/field/FieldDetailContent.tsx b/packages/dataclass-editor/src/detail/field/FieldDetailContent.tsx index c4caae8c..68f88ca8 100644 --- a/packages/dataclass-editor/src/detail/field/FieldDetailContent.tsx +++ b/packages/dataclass-editor/src/detail/field/FieldDetailContent.tsx @@ -7,8 +7,10 @@ import { FieldEntityDatabaseField } from './entity/FieldEntityDatabaseField'; import { FieldNameTypeComment } from './FieldNameTypeComment'; import { FieldProperties } from './FieldProperties'; import { useFieldProperty } from './useFieldProperty'; +import { useAppContext } from '../../context/AppContext'; export const FieldDetailContent = () => { + const { isHdData } = useAppContext(); const { field, setField } = useField(); const { setProperty } = useFieldProperty(); @@ -19,7 +21,7 @@ export const FieldDetailContent = () => { - + {!isHdData && } ) => setProperty('annotations', annotations)} diff --git a/packages/dataclass-editor/src/master/DataClassMasterToolbar.tsx b/packages/dataclass-editor/src/master/DataClassMasterToolbar.tsx index ef3b0c10..0e3bd9bf 100644 --- a/packages/dataclass-editor/src/master/DataClassMasterToolbar.tsx +++ b/packages/dataclass-editor/src/master/DataClassMasterToolbar.tsx @@ -23,9 +23,8 @@ type DataClassMasterToolbarProps = { }; export const DataClassMasterToolbar = ({ title }: DataClassMasterToolbarProps) => { - const { context, detail, setDetail } = useAppContext(); + const { detail, setDetail, isHdData } = useAppContext(); const { theme, setTheme, disabled } = useTheme(); - const isFormData = context.file.includes('src_hd'); const openForm = useAction('openForm'); const openProcess = useAction('openProcess'); @@ -33,7 +32,7 @@ export const DataClassMasterToolbar = ({ title }: DataClassMasterToolbarProps) = {title} - {isFormData && ( + {isHdData && ( <>