Add Import CSV and Export CSV Permissions (#13421)
Co-authored-by: Félix Malfait <felix.malfait@gmail.com> Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
+2
-4
@@ -4,9 +4,7 @@ import { useRecoilValue } from 'recoil';
|
||||
import { WorkspaceActivationStatus } from 'twenty-shared/workspace';
|
||||
import { PermissionFlagType } from '~/generated/graphql';
|
||||
|
||||
export const useHasSettingsPermission = (
|
||||
permissionFlag?: PermissionFlagType,
|
||||
) => {
|
||||
export const useHasPermissionFlag = (permissionFlag?: PermissionFlagType) => {
|
||||
const currentWorkspace = useRecoilValue(currentWorkspaceState);
|
||||
const currentUserWorkspace = useRecoilValue(currentUserWorkspaceState);
|
||||
|
||||
@@ -22,7 +20,7 @@ export const useHasSettingsPermission = (
|
||||
return true;
|
||||
}
|
||||
|
||||
const currentUserWorkspaceSetting = currentUserWorkspace?.settingsPermissions;
|
||||
const currentUserWorkspaceSetting = currentUserWorkspace?.permissionFlags;
|
||||
|
||||
if (!currentUserWorkspaceSetting) {
|
||||
return false;
|
||||
+2
-5
@@ -3,14 +3,11 @@ import { useRecoilValue } from 'recoil';
|
||||
import { PermissionFlagType } from '~/generated/graphql';
|
||||
import { buildRecordFromKeysWithSameValue } from '~/utils/array/buildRecordFromKeysWithSameValue';
|
||||
|
||||
export const useSettingsPermissionMap = (): Record<
|
||||
PermissionFlagType,
|
||||
boolean
|
||||
> => {
|
||||
export const usePermissionFlagMap = (): Record<PermissionFlagType, boolean> => {
|
||||
const currentUserWorkspace = useRecoilValue(currentUserWorkspaceState);
|
||||
|
||||
const currentUserWorkspaceSettingsPermissions =
|
||||
currentUserWorkspace?.settingsPermissions;
|
||||
currentUserWorkspace?.permissionFlags;
|
||||
|
||||
const initialPermissions = buildRecordFromKeysWithSameValue(
|
||||
Object.values(PermissionFlagType),
|
||||
+23
-6
@@ -7,7 +7,13 @@ import styled from '@emotion/styled';
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { useRecoilState } from 'recoil';
|
||||
|
||||
import { H2Title, IconMail, IconTool } from 'twenty-ui/display';
|
||||
import {
|
||||
H2Title,
|
||||
IconFileExport,
|
||||
IconFileImport,
|
||||
IconMail,
|
||||
IconTool,
|
||||
} from 'twenty-ui/display';
|
||||
import { AnimatedExpandableContainer, Card, Section } from 'twenty-ui/layout';
|
||||
import { PermissionFlagType } from '~/generated-metadata/graphql';
|
||||
|
||||
@@ -45,19 +51,30 @@ export const SettingsRolePermissionsToolSection = ({
|
||||
Icon: IconMail,
|
||||
isToolPermission: true,
|
||||
},
|
||||
{
|
||||
key: PermissionFlagType.IMPORT_CSV,
|
||||
name: t`Import CSV`,
|
||||
description: t`Allow importing data from CSV files`,
|
||||
Icon: IconFileImport,
|
||||
isToolPermission: true,
|
||||
},
|
||||
{
|
||||
key: PermissionFlagType.EXPORT_CSV,
|
||||
name: t`Export CSV`,
|
||||
description: t`Allow exporting data to CSV files`,
|
||||
Icon: IconFileExport,
|
||||
isToolPermission: true,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<Section>
|
||||
<H2Title
|
||||
title={t`Action Permissions`}
|
||||
description={t`Permissions for performing automated actions.`}
|
||||
/>
|
||||
<H2Title title={t`Actions`} description={t`Actions permissions`} />
|
||||
<StyledCard rounded>
|
||||
<SettingsOptionCardContentToggle
|
||||
Icon={IconTool}
|
||||
title={t`All Actions Access`}
|
||||
description={t`Grants permission to perform all available actions without restriction.`}
|
||||
description={t`Grants permission to perform all available actions without restriction`}
|
||||
checked={settingsDraftRole.canAccessAllTools}
|
||||
disabled={!isEditable}
|
||||
onChange={() => {
|
||||
|
||||
Reference in New Issue
Block a user