feat: activate and disable objects (#2194)

Closes #2144, Closes #2148, Closes #2154
This commit is contained in:
Thaïs
2023-10-24 08:07:00 +02:00
committed by GitHub
parent f94886d150
commit 26e8cd76be
8 changed files with 185 additions and 103 deletions

View File

@ -30,7 +30,7 @@ export const SettingsObjectDetail = () => {
const navigate = useNavigate();
const { pluralObjectName = '' } = useParams();
const { activeObjects } = useObjectMetadata();
const { activeObjects, disableObject } = useObjectMetadata();
const activeObject = activeObjects.find(
(activeObject) => activeObject.namePlural === pluralObjectName,
);
@ -62,6 +62,13 @@ export const SettingsObjectDetail = () => {
iconKey={activeObject.icon ?? undefined}
name={activeObject.labelPlural || ''}
isCustom={activeObject.isCustom}
onDisable={() => {
disableObject(activeObject);
navigate('/settings/objects');
}}
onEdit={() =>
navigate(`/settings/objects/${pluralObjectName}/edit`)
}
/>
)}
<Section>
@ -76,15 +83,17 @@ export const SettingsObjectDetail = () => {
<TableHeader>Data type</TableHeader>
<TableHeader></TableHeader>
</StyledObjectFieldTableRow>
<TableSection title="Active">
{activeFields?.map((fieldItem) => (
<SettingsObjectFieldItemTableRow
key={fieldItem.id}
fieldItem={fieldItem}
ActionIcon={IconDotsVertical}
/>
))}
</TableSection>
{!!activeFields?.length && (
<TableSection title="Active">
{activeFields.map((fieldItem) => (
<SettingsObjectFieldItemTableRow
key={fieldItem.id}
fieldItem={fieldItem}
ActionIcon={IconDotsVertical}
/>
))}
</TableSection>
)}
{!!disabledFields?.length && (
<TableSection isInitiallyExpanded={false} title="Disabled">
{disabledFields.map((fieldItem) => (