feat: activate and disable objects (#2194)
Closes #2144, Closes #2148, Closes #2154
This commit is contained in:
@ -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) => (
|
||||
|
||||
@ -17,7 +17,7 @@ export const SettingsObjectEdit = () => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const { pluralObjectName = '' } = useParams();
|
||||
const { activeObjects } = useObjectMetadata();
|
||||
const { activeObjects, disableObject } = useObjectMetadata();
|
||||
const activeObject = activeObjects.find(
|
||||
(activeObject) => activeObject.namePlural === pluralObjectName,
|
||||
);
|
||||
@ -52,17 +52,20 @@ export const SettingsObjectEdit = () => {
|
||||
pluralName={activeObject.labelPlural}
|
||||
description={activeObject.description ?? undefined}
|
||||
/>
|
||||
<Section>
|
||||
<H2Title title="Danger zone" description="Disable object" />
|
||||
<Button
|
||||
Icon={IconArchive}
|
||||
title="Disable"
|
||||
size="small"
|
||||
onClick={() => {
|
||||
disableObject(activeObject);
|
||||
navigate('/settings/objects');
|
||||
}}
|
||||
/>
|
||||
</Section>
|
||||
</>
|
||||
)}
|
||||
<Section>
|
||||
<H2Title title="Danger zone" description="Disable object" />
|
||||
<Button
|
||||
Icon={IconArchive}
|
||||
title="Disable"
|
||||
size="small"
|
||||
onClick={() => undefined}
|
||||
/>
|
||||
</Section>
|
||||
</SettingsPageContainer>
|
||||
</SubMenuTopBarContainer>
|
||||
);
|
||||
|
||||
@ -87,15 +87,17 @@ export const SettingsObjectNewFieldStep1 = () => {
|
||||
<TableHeader>Data type</TableHeader>
|
||||
<TableHeader></TableHeader>
|
||||
</StyledObjectFieldTableRow>
|
||||
<TableSection isInitiallyExpanded={false} title="Active">
|
||||
{activeFields?.map((fieldItem) => (
|
||||
<SettingsObjectFieldItemTableRow
|
||||
key={fieldItem.id}
|
||||
fieldItem={fieldItem}
|
||||
ActionIcon={IconMinus}
|
||||
/>
|
||||
))}
|
||||
</TableSection>
|
||||
{!!activeFields?.length && (
|
||||
<TableSection isInitiallyExpanded={false} title="Active">
|
||||
{activeFields.map((fieldItem) => (
|
||||
<SettingsObjectFieldItemTableRow
|
||||
key={fieldItem.id}
|
||||
fieldItem={fieldItem}
|
||||
ActionIcon={IconMinus}
|
||||
/>
|
||||
))}
|
||||
</TableSection>
|
||||
)}
|
||||
{!!disabledFields?.length && (
|
||||
<TableSection title="Disabled">
|
||||
{disabledFields.map((fieldItem) => (
|
||||
|
||||
@ -33,7 +33,8 @@ export const SettingsObjects = () => {
|
||||
const theme = useTheme();
|
||||
const navigate = useNavigate();
|
||||
|
||||
const { activeObjects, disabledObjects } = useObjectMetadata();
|
||||
const { activateObject, activeObjects, disabledObjects } =
|
||||
useObjectMetadata();
|
||||
|
||||
return (
|
||||
<SubMenuTopBarContainer Icon={IconSettings} title="Settings">
|
||||
@ -62,23 +63,25 @@ export const SettingsObjects = () => {
|
||||
<TableHeader align="right">Instances</TableHeader>
|
||||
<TableHeader></TableHeader>
|
||||
</StyledObjectTableRow>
|
||||
<TableSection title="Active">
|
||||
{activeObjects.map((objectItem) => (
|
||||
<SettingsObjectItemTableRow
|
||||
key={objectItem.namePlural}
|
||||
objectItem={objectItem}
|
||||
action={
|
||||
<StyledIconChevronRight
|
||||
size={theme.icon.size.md}
|
||||
stroke={theme.icon.stroke.sm}
|
||||
/>
|
||||
}
|
||||
onClick={() =>
|
||||
navigate(`/settings/objects/${objectItem.namePlural}`)
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</TableSection>
|
||||
{!!activeObjects.length && (
|
||||
<TableSection title="Active">
|
||||
{activeObjects.map((objectItem) => (
|
||||
<SettingsObjectItemTableRow
|
||||
key={objectItem.namePlural}
|
||||
objectItem={objectItem}
|
||||
action={
|
||||
<StyledIconChevronRight
|
||||
size={theme.icon.size.md}
|
||||
stroke={theme.icon.stroke.sm}
|
||||
/>
|
||||
}
|
||||
onClick={() =>
|
||||
navigate(`/settings/objects/${objectItem.namePlural}`)
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</TableSection>
|
||||
)}
|
||||
{!!disabledObjects.length && (
|
||||
<TableSection title="Disabled">
|
||||
{disabledObjects.map((objectItem) => (
|
||||
@ -88,8 +91,8 @@ export const SettingsObjects = () => {
|
||||
action={
|
||||
<SettingsObjectDisabledMenuDropDown
|
||||
scopeKey={objectItem.namePlural}
|
||||
handleActivate={() => undefined}
|
||||
handleErase={() => undefined}
|
||||
onActivate={() => activateObject(objectItem)}
|
||||
onErase={() => undefined}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user