-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat: conditional field deletion warning #1337
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Ryan Kontos <[email protected]>
Signed-off-by: Ryan Kontos <[email protected]>
Signed-off-by: Ryan Kontos <[email protected]>
Signed-off-by: Ryan Kontos <[email protected]>
Signed-off-by: Ryan Kontos <[email protected]>
Signed-off-by: Ryan Kontos <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally good, just a few comments and I think a change in behaviour - don't let them delete a field that is used.
const allFields = useAppSelector( | ||
state => state.notebook['ui-specification'].fields | ||
); | ||
const allFviews = useAppSelector( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You already have this above in views
*/ | ||
const findFieldUsage = ( | ||
fieldName: string, | ||
allFields: Record<string, any>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I've not come across this before, very useful. Shame about the name though since we have many Record* types!
/** | ||
* Finds where a field is used in conditions or templated string fields | ||
*/ | ||
const findFieldUsage = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good but probably belongs in condition.tsx, might be useful in other places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Funny you say that, I originally had it in condition.tsx and decided to move it when I added template support
Cancel | ||
</Button> | ||
<Button onClick={confirmDelete} color="error"> | ||
Delete Anyway |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would prefer to forbid deleting the field if it is used in conditions - ask them to go delete the conditions first. Then we don't end up with invalid notebooks.
feat: conditional field deletion warning
JIRA Ticket
<JIRA_TICKET>
Description
This PR introduces a warning dialogue when attempting to delete a field that is referenced in:
This ensures that deleting a field does not break existing conditions or fields.
Proposed Changes
findFieldUsage()
infield-editor.tsx
to detect references to a field in:isFieldUsedInCondition
incondition.tsx
to recursively check if a given field is used within a given condition.How to Test
animal_field
)Show if animal_field == "Elephant"
)"The animal is {{animal_field}}"
)Additional Information
Checklist