Overview
To enhance code reusability and promote consistent access of the AI Flag status across various components, we need to create a global getter function. This function will provide a centralized way to retrieve the current status of the AI Flag without duplicating code or maintaining multiple instances of the flag. By adding this global getter, we ensure that all parts of the Studio access the AI Flag consistently, and this ultimately provides a direct way to check if a logged in user has access to the AI feature on the front-end in Studio.
Description and outcomes
- Add the global getter function to
vuex/session/index.js getters
- Name it
isAIFeatureEnabled
- Abstract the function’s internal implementation details of the AI flag storage.
- Each user has a field name
feature_flags that contains mapping called ai_feature that can be used to check for the status.
- The
currentUser can be obtained from the global session, state.session.currentUser
- Write tests to verify that the global getter function correctly retrieves the AI flag status, not forgetting the edge cases(e.g enabled and disabled statuses)
Accessibility requirements
Not applicable
Acceptance criteria
- The global getter function, named
isAIFeatureEnabled, is added to vuex/session/index.js getters
- The function returns the current status of the AI flag for a logged in user
- Unit tests for the global getter function are written to verify its correctness and behavior.
Resources
Overview
To enhance code reusability and promote consistent access of the AI Flag status across various components, we need to create a global getter function. This function will provide a centralized way to retrieve the current status of the AI Flag without duplicating code or maintaining multiple instances of the flag. By adding this global getter, we ensure that all parts of the Studio access the AI Flag consistently, and this ultimately provides a direct way to check if a logged in user has access to the AI feature on the front-end in Studio.
Description and outcomes
vuex/session/index.jsgettersisAIFeatureEnabledfeature_flagsthat contains mapping calledai_featurethat can be used to check for the status.currentUsercan be obtained from the global session,state.session.currentUserAccessibility requirements
Not applicable
Acceptance criteria
isAIFeatureEnabled, is added tovuex/session/index.js gettersResources