Allow non-flexible Purposes to add Purpose Restriction#6066
Allow non-flexible Purposes to add Purpose Restriction#6066gilluminate merged 3 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
256e9fe to
9026bcd
Compare
c716b42 to
dc6694b
Compare
| const toast = useToast(); | ||
| const [createRestriction] = useCreatePublisherRestrictionMutation(); | ||
| const [updateRestriction] = useUpdatePublisherRestrictionMutation(); | ||
| const [isPurposeFlexible, setIsPurposeFlexible] = useState(true); |
There was a problem hiding this comment.
I've tested the feature and it works correctly. However, I found a bit odd that the during the first render the initialValues are set to the original values, then the useEffect runs, and then the initialValues get changed.

Apparently this works fine with Formik, but I think with a couple small improvement this can be cleaned and avoid the changing values during rendering (and also avoiding the eslint rule disable).
The purpose flexible can be derived from the prop without needing a state
const isPurposeFlexible = !( purposeId && FORBIDDEN_LEGITIMATE_INTEREST_PURPOSE_IDS.includes(+purposeId) );
so it's value is the correct one even during the first render.
and the initial values is only used in the Formik component so it can be overriden there:
<Formik initialValues={{ ...initialValues, restriction_type: isPurposeFlexible ? initialValues.restriction_type : TCFRestrictionType.PURPOSE_RESTRICTION, }}
What do you think? Let me know if you see any issues with this approach.
There was a problem hiding this comment.
This is a great suggestion. Thank you! Updated.
lucanovera
left a comment
There was a problem hiding this comment.
@gilluminate I've tested and everything is working correctly 💯

I left a suggestion for the code and don't forget to add the changelog entry.
d744e1c to
82ec62c
Compare
fides
|
||||||||||||||||||||||||||||||
| Project |
fides
|
| Branch Review |
main
|
| Run status |
|
| Run duration | 00m 54s |
| Commit |
|
| Committer | Jason Gill |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
5
|
Upgrade your plan to view test results. | |
| View all changes introduced in this branch ↗︎ | |
Closes LJ-694
Description Of Changes
Removes restrictions on editing purpose restrictions for non-flexible purposes in TCF consent settings. Instead of blocking editing entirely, the UI now allows users to create restrictions for these purposes but limits them to only use Purpose Restriction type.
Code Changes
PublisherRestrictionsTablePurposeRestrictionFormModalto disable the Restriction Type dropdown for non-flexible purposes[purpose_id].tsx) that prevented accessing non-flexible purposesSteps to Confirm
/settings/consent)NOTE: Backend validation with throw an error for now, @JadeCara is working to address this
Pre-Merge Checklist
CHANGELOG.mdupdatedchange includes a high-risk change (i.e. potential for performance impact or unexpected regression) that should be flagged
maindowngrade()migration is correct and works