mirror of
https://github.com/twentyhq/twenty
synced 2026-04-21 13:37:22 +00:00
parent
13b32a22b6
commit
38a03abc06
5 changed files with 72 additions and 47 deletions
|
|
@ -15,10 +15,11 @@ export const useNavigateSettings = () => {
|
|||
replace?: boolean;
|
||||
state?: any;
|
||||
},
|
||||
hash?: string,
|
||||
) => {
|
||||
openSettingsMenu();
|
||||
|
||||
const path = getSettingsPath(to, params, queryParams);
|
||||
const path = getSettingsPath(to, params, queryParams, hash);
|
||||
return navigate(path, options);
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@ import { isNonEmptyString } from '@sniptt/guards';
|
|||
import { useState } from 'react';
|
||||
import { SettingsPath } from 'twenty-shared/types';
|
||||
import {
|
||||
AppTooltip,
|
||||
H1Title,
|
||||
H1TitleFontColor,
|
||||
H2Title,
|
||||
IconShare,
|
||||
IconTrash,
|
||||
AppTooltip,
|
||||
TooltipDelay,
|
||||
} from 'twenty-ui/display';
|
||||
import { Button } from 'twenty-ui/input';
|
||||
|
|
@ -50,8 +50,10 @@ const StyledDangerButtonGroup = styled.div`
|
|||
|
||||
export const SettingsAdminApplicationRegistrationDangerZone = ({
|
||||
registration,
|
||||
fromAdmin = false,
|
||||
}: {
|
||||
registration: ApplicationRegistration;
|
||||
fromAdmin?: boolean;
|
||||
}) => {
|
||||
const { t } = useLingui();
|
||||
const navigate = useNavigateSettings();
|
||||
|
|
@ -97,7 +99,28 @@ export const SettingsAdminApplicationRegistrationDangerZone = ({
|
|||
await deleteRegistration({
|
||||
variables: { id: applicationRegistrationId },
|
||||
});
|
||||
navigate(SettingsPath.Applications);
|
||||
|
||||
if (fromAdmin) {
|
||||
navigate(
|
||||
SettingsPath.AdminPanel,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
'#app',
|
||||
);
|
||||
} else {
|
||||
navigate(
|
||||
SettingsPath.Applications,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
'#developer',
|
||||
);
|
||||
}
|
||||
|
||||
enqueueSuccessSnackBar({
|
||||
message: t`App deleted successfully`,
|
||||
});
|
||||
} catch {
|
||||
enqueueErrorSnackBar({
|
||||
message: t`Error deleting app`,
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ export const SettingsAdminApplicationRegistrationDetail = () => {
|
|||
return (
|
||||
<SettingsApplicationRegistrationGeneralTab
|
||||
registration={registration}
|
||||
displayAdminToggles
|
||||
fromAdmin
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,15 +8,15 @@ import { SettingsAdminApplicationRegistrationGeneralToggles } from '~/pages/sett
|
|||
|
||||
export const SettingsApplicationRegistrationGeneralTab = ({
|
||||
registration,
|
||||
displayAdminToggles,
|
||||
fromAdmin,
|
||||
}: {
|
||||
registration: ApplicationRegistration;
|
||||
displayAdminToggles?: boolean;
|
||||
fromAdmin?: boolean;
|
||||
}) => {
|
||||
return (
|
||||
<>
|
||||
<SettingsApplicationRegistrationGeneralInfo registration={registration} />
|
||||
{displayAdminToggles && (
|
||||
{fromAdmin && (
|
||||
<SettingsAdminApplicationRegistrationGeneralToggles
|
||||
registration={registration}
|
||||
/>
|
||||
|
|
@ -26,6 +26,7 @@ export const SettingsApplicationRegistrationGeneralTab = ({
|
|||
/>
|
||||
<SettingsAdminApplicationRegistrationDangerZone
|
||||
registration={registration}
|
||||
fromAdmin={fromAdmin}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -65,48 +65,48 @@ export const SettingsAvailableApplicationDetailContentTab = ({
|
|||
}
|
||||
}
|
||||
|
||||
return Array.from(groupMap.values()).map((group) => {
|
||||
const appObject = objects.find(
|
||||
(obj) => obj.universalIdentifier === group.objectUniversalIdentifier,
|
||||
);
|
||||
|
||||
if (isDefined(appObject)) {
|
||||
return {
|
||||
key: appObject.nameSingular,
|
||||
labelPlural: appObject.labelPlural,
|
||||
icon: appObject.icon ?? undefined,
|
||||
fieldsCount: group.count,
|
||||
tagItem: { applicationId },
|
||||
};
|
||||
}
|
||||
|
||||
const standardObjectName = findObjectNameByUniversalIdentifier(
|
||||
group.objectUniversalIdentifier,
|
||||
);
|
||||
|
||||
const objectMetadataItem = isDefined(standardObjectName)
|
||||
? objectMetadataItems.find(
|
||||
(item) => item.nameSingular === standardObjectName,
|
||||
)
|
||||
: undefined;
|
||||
|
||||
if (!isDefined(objectMetadataItem)) {
|
||||
throw new Error(
|
||||
`Could not resolve object for universalIdentifier: ${group.objectUniversalIdentifier}`,
|
||||
return Array.from(groupMap.values())
|
||||
.map((group) => {
|
||||
const appObject = objects.find(
|
||||
(obj) => obj.universalIdentifier === group.objectUniversalIdentifier,
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
key: objectMetadataItem.nameSingular,
|
||||
labelPlural: objectMetadataItem.labelPlural,
|
||||
icon: objectMetadataItem.icon ?? undefined,
|
||||
fieldsCount: group.count,
|
||||
link: getSettingsPath(SettingsPath.ObjectDetail, {
|
||||
objectNamePlural: objectMetadataItem.namePlural,
|
||||
}),
|
||||
tagItem: {},
|
||||
};
|
||||
});
|
||||
if (isDefined(appObject)) {
|
||||
return {
|
||||
key: appObject.nameSingular,
|
||||
labelPlural: appObject.labelPlural,
|
||||
icon: appObject.icon ?? undefined,
|
||||
fieldsCount: group.count,
|
||||
tagItem: { applicationId },
|
||||
};
|
||||
}
|
||||
|
||||
const standardObjectName = findObjectNameByUniversalIdentifier(
|
||||
group.objectUniversalIdentifier,
|
||||
);
|
||||
|
||||
const objectMetadataItem = isDefined(standardObjectName)
|
||||
? objectMetadataItems.find(
|
||||
(item) => item.nameSingular === standardObjectName,
|
||||
)
|
||||
: undefined;
|
||||
|
||||
if (!isDefined(objectMetadataItem)) {
|
||||
return;
|
||||
}
|
||||
|
||||
return {
|
||||
key: objectMetadataItem.nameSingular,
|
||||
labelPlural: objectMetadataItem.labelPlural,
|
||||
icon: objectMetadataItem.icon ?? undefined,
|
||||
fieldsCount: group.count,
|
||||
link: getSettingsPath(SettingsPath.ObjectDetail, {
|
||||
objectNamePlural: objectMetadataItem.namePlural,
|
||||
}),
|
||||
tagItem: {},
|
||||
};
|
||||
})
|
||||
.filter(isDefined);
|
||||
}, [fields, objectMetadataItems, objects, applicationId]);
|
||||
|
||||
const roles = content?.roles ?? [];
|
||||
|
|
|
|||
Loading…
Reference in a new issue