Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make workflow objects read only in frontend #7545

Merged
merged 7 commits into from
Oct 10, 2024

Conversation

thomtrp
Copy link
Contributor

@thomtrp thomtrp commented Oct 9, 2024

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

@charlesBochet
Copy link
Member

@thomtrp the CI is red because of the linter!

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This pull request introduces changes to make workflow objects read-only in the frontend, implementing new utility functions and modifying existing components to enforce read-only behavior for specific workflow-related objects.

  • Added isWorkflowSubObject utility function in isWorkflowSubObject.ts to identify WorkflowVersion and WorkflowRun objects
  • Replaced isRemoteObject with isReadOnlyObject in useRecordActionBar.tsx to determine read-only status for records
  • Implemented isFieldReadonlyFromObjectMetadataName in useIsFieldReadOnly.ts to control field editability based on object metadata
  • Modified RecordIndexPageHeader.tsx and RecordTableEmptyStateDisplay.tsx to conditionally render add buttons for non-read-only objects
  • Updated WorkflowWorkspaceEntity in the backend to cascade delete related entities when a workflow is deleted

12 file(s) reviewed, 11 comment(s)
Edit PR Review Bot Settings

@thomtrp thomtrp force-pushed the tt-set-workflows-as-read-only-on-frontend branch from 1c7bcf6 to 402228d Compare October 9, 2024 15:48
@thomtrp thomtrp removed their assignment Oct 9, 2024
@thomtrp
Copy link
Contributor Author

thomtrp commented Oct 9, 2024

the CI is red because of the linter!

@charlesBochet CI is fixed

@charlesBochet
Copy link
Member

the CI is red because of the linter!

@charlesBochet CI is fixed

You bet :D

@thomtrp thomtrp force-pushed the tt-set-workflows-as-read-only-on-frontend branch from 98133c4 to e9bb2d0 Compare October 10, 2024 08:32
@thomtrp
Copy link
Contributor Author

thomtrp commented Oct 10, 2024

the CI is red because of the linter!

@charlesBochet CI is fixed

You bet :D

For good this time 😂

return (
fieldDefinition.metadata.fieldName === 'noteTargets' ||
fieldDefinition.metadata.fieldName === 'taskTargets' ||
metadata.fieldName === 'noteTargets' ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move it to your new util

Copy link
Member

@charlesBochet charlesBochet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@thomtrp thomtrp force-pushed the tt-set-workflows-as-read-only-on-frontend branch from 1a56bfc to 87f665a Compare October 10, 2024 12:40
@thomtrp thomtrp merged commit c055d16 into main Oct 10, 2024
16 checks passed
@thomtrp thomtrp deleted the tt-set-workflows-as-read-only-on-frontend branch October 10, 2024 13:29
harshit078 pushed a commit to harshit078/twenty that referenced this pull request Oct 14, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants