da5ae34109
Note and task tabs in side panel should only show if user has reading permission on them. "Go to companies", "Go to workflows", etc. in command menu should only show is user has reading permission on related objects. <img width="507" alt="Capture d’écran 2025-06-17 à 11 09 50" src="https://github.com/user-attachments/assets/3a2a4c25-0b9b-4ee6-b18f-b019b8a56d47" /> <img width="505" alt="Capture d’écran 2025-06-17 à 11 09 56" src="https://github.com/user-attachments/assets/8a219955-cc8e-4dbf-a4f9-a50e1aaa4b59" /> **How to test** Assign a user with a custom role that has **no** read permissions on notes/tasks/workflows/companies/opportunities/people (no need to test them all but at least one between note and tasks; workflows; one between companies/opportunities/people). Check that you don't see the related tab / action. --------- Co-authored-by: Charles Bochet <charles@twenty.com>
33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
import { DEFAULT_RECORD_ACTIONS_CONFIG } from '@/action-menu/actions/record-actions/constants/DefaultRecordActionsConfig';
|
|
import { WORKFLOW_ACTIONS_CONFIG } from '@/action-menu/actions/record-actions/constants/WorkflowActionsConfig';
|
|
import { WORKFLOW_RUNS_ACTIONS_CONFIG } from '@/action-menu/actions/record-actions/constants/WorkflowRunsActionsConfig';
|
|
import { WORKFLOW_VERSIONS_ACTIONS_CONFIG } from '@/action-menu/actions/record-actions/constants/WorkflowVersionsActionsConfig';
|
|
import { ActionConfig } from '@/action-menu/actions/types/ActionConfig';
|
|
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
|
|
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem';
|
|
import { isDefined } from 'twenty-shared/utils';
|
|
|
|
export const getActionConfig = ({
|
|
objectMetadataItem,
|
|
}: {
|
|
objectMetadataItem?: ObjectMetadataItem;
|
|
}): Record<string, ActionConfig> => {
|
|
if (!isDefined(objectMetadataItem)) {
|
|
return {};
|
|
}
|
|
|
|
switch (objectMetadataItem.nameSingular) {
|
|
case CoreObjectNameSingular.Workflow: {
|
|
return WORKFLOW_ACTIONS_CONFIG;
|
|
}
|
|
case CoreObjectNameSingular.WorkflowVersion: {
|
|
return WORKFLOW_VERSIONS_ACTIONS_CONFIG;
|
|
}
|
|
case CoreObjectNameSingular.WorkflowRun: {
|
|
return WORKFLOW_RUNS_ACTIONS_CONFIG;
|
|
}
|
|
default:
|
|
return DEFAULT_RECORD_ACTIONS_CONFIG;
|
|
}
|
|
};
|