-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make workflow objects read only in frontend (#7545)
Expected behavior: - workflows can be added and deleted. Only name field is editable - versions and runs cannot be added nor deleted. No fields are editable Added two new utils for those needs: - `isReadOnlyObject` the similar logic between remote objects, versions and runs - `isFieldReadonlyFromObjectMetadataName` to easily block field edition from object context
- Loading branch information
Showing
16 changed files
with
190 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 0 additions & 5 deletions
5
packages/twenty-front/src/modules/object-metadata/hooks/useObjectIsRemote.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
packages/twenty-front/src/modules/object-metadata/utils/isObjectMetadataReadOnly.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ObjectMetadataItem } from '@/object-metadata/types/ObjectMetadataItem'; | ||
import { isWorkflowSubObjectMetadata } from '@/object-metadata/utils/isWorkflowSubObjectMetadata'; | ||
|
||
export const isObjectMetadataReadOnly = ( | ||
objectMetadataItem: Pick<ObjectMetadataItem, 'isRemote' | 'nameSingular'>, | ||
) => | ||
objectMetadataItem.isRemote || | ||
isWorkflowSubObjectMetadata(objectMetadataItem.nameSingular); |
7 changes: 7 additions & 0 deletions
7
packages/twenty-front/src/modules/object-metadata/utils/isWorkflowSubObjectMetadata.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; | ||
|
||
export const isWorkflowSubObjectMetadata = ( | ||
objectMetadataNameSingular?: string, | ||
) => | ||
objectMetadataNameSingular === CoreObjectNameSingular.WorkflowVersion || | ||
objectMetadataNameSingular === CoreObjectNameSingular.WorkflowRun; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...ages/twenty-front/src/modules/object-record/record-field/utils/isFieldMetadataReadOnly.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular'; | ||
import { isWorkflowSubObjectMetadata } from '@/object-metadata/utils/isWorkflowSubObjectMetadata'; | ||
import { FieldMetadata } from '@/object-record/record-field/types/FieldMetadata'; | ||
|
||
export const isFieldMetadataReadOnly = (fieldMetadata: FieldMetadata) => { | ||
if ( | ||
fieldMetadata.fieldName === 'noteTargets' || | ||
fieldMetadata.fieldName === 'taskTargets' | ||
) { | ||
return true; | ||
} | ||
|
||
return ( | ||
isWorkflowSubObjectMetadata(fieldMetadata.objectMetadataNameSingular) || | ||
(fieldMetadata.objectMetadataNameSingular === | ||
CoreObjectNameSingular.Workflow && | ||
fieldMetadata.fieldName !== 'name') | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.