-
Notifications
You must be signed in to change notification settings - Fork 6
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: Use XControls in NextQueries and Layout #360
Merged
CachedaCodes
merged 15 commits into
main
from
feature/EMP-2722-Use-xControls-in-NQ-and-layout
Nov 13, 2023
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
cf615e7
feat(nextQueries): set maxNextQueriesPerGroup using xControls
annacv 554f8ef
feat(layout): set columns using xControls
annacv de13239
chore: rename export in composable to avoid large length imports
annacv 293c79a
feat: use xControls composable in semantics
annacv 2fed166
chore: change dress filter, collection not filterable anymore
annacv d77c080
feat: return one single computed to make composable scalable
annacv 9543790
feat: use the full object property path instead of 2 params
annacv 9498705
feat: use getSafePropertyChain utility function
annacv 4cfca1e
feat(composables): create use-store composable + use it in XControls …
annacv 74e6dd2
feat(app): rm provider as module is accessible using composable f()
annacv 9e8cd12
chore: rm test useXControls feat from custom-next-query-preview
annacv 49f0f15
chore: rename composable to avoid large string
annacv 8b41dca
Update src/composables/use-experience-controls.composable.ts
annacv 879ef27
chore: PR fixes
annacv f6b110d
chore: refactor
CachedaCodes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,30 @@ | ||
import { computed, ComputedRef } from 'vue'; | ||
import { getSafePropertyChain } from '@empathyco/x-utils'; | ||
import { ExperienceControlsState } from '@empathyco/x-components/experience-controls'; | ||
import { useStore } from './use-store.composable'; | ||
|
||
/** | ||
* Given a controls' object property chain, gets the experience controls values from the response. | ||
* A defaultValue can be set as a safeguard in case the controls response was empty. | ||
* | ||
* @returns An object containing the function to search for a configuration | ||
* and set the experience controls property value. | ||
*/ | ||
export const useExperienceControls = (): { | ||
getControlFromPath: <SomeType>(path: string, defaultValue?: SomeType) => ComputedRef<SomeType>; | ||
} => { | ||
const experienceControls = (useStore('experienceControls') as ExperienceControlsState).controls; | ||
|
||
const getControlFromPath = <SomeType>( | ||
path: string, | ||
defaultValue?: SomeType | ||
): ComputedRef<SomeType> => { | ||
return computed(() => { | ||
return getSafePropertyChain(experienceControls, path, defaultValue) as SomeType; | ||
}); | ||
}; | ||
|
||
return { | ||
getControlFromPath | ||
}; | ||
}; |
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,16 @@ | ||
// TODO: Change when useStore composable is added in x-components | ||
import { getCurrentInstance } from 'vue'; | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
import { RootXStoreState, StatusState, XModuleName, XModulesTree } from '@empathyco/x-components'; | ||
|
||
/** | ||
* Provides access to the global store object or to the specific store module if it's provided. | ||
* | ||
* @param storeModule - The {@link XModuleName}. | ||
* @returns A state object. | ||
*/ | ||
export function useStore(storeModule?: keyof XModulesTree): RootXStoreState | StatusState { | ||
return storeModule | ||
? getCurrentInstance()!.proxy.$root.$store.state.x[storeModule] | ||
: getCurrentInstance()!.proxy.$root.$store.state.x; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Add a TODO to change when we add the useStore composable in x