Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Project scoped stickiness (#3289)
Project scoped stickiness <!-- Thanks for creating a PR! To make it easier for reviewers and everyone else to understand what your changes relate to, please add some relevant content to the headings below. Feel free to ignore or delete sections that you don't think are relevant. Thank you! ❤️ --> Adds `projectScopedStickiness` flag to experimental.ts Refactor Stickiness select for reusability Modify FlexibleStrategy to respect the setting. Modify EnvironmentVariantModal to respect the setting ## About the changes <!-- Describe the changes introduced. What are they and why are they being introduced? Feel free to also add screenshots or steps to view the changes if they're visual. --> <!-- Does it close an issue? Multiple? --> Closes # <!-- (For internal contributors): Does it relate to an issue on public roadmap? --> <!-- Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item: # --> ### Important files <!-- PRs can contain a lot of changes, but not all changes are equally important. Where should a reviewer start looking to get an overview of the changes? Are any files particularly important? --> ## Discussion points <!-- Anything about the PR you'd like to discuss before it gets merged? Got any questions or doubts? --> --------- Signed-off-by: andreas-unleash <andreas@getunleash.ai>
- Loading branch information
1 parent
99a5b96
commit 3193423
Showing
15 changed files
with
210 additions
and
45 deletions.
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
57 changes: 57 additions & 0 deletions
57
...rc/component/feature/StrategyTypes/FlexibleStrategy/StickinessSelect/StickinessSelect.tsx
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,57 @@ | ||
import Select from 'component/common/select'; | ||
import { SelectChangeEvent } from '@mui/material'; | ||
import useUnleashContext from 'hooks/api/getters/useUnleashContext/useUnleashContext'; | ||
const builtInStickinessOptions = [ | ||
{ key: 'default', label: 'default' }, | ||
{ key: 'userId', label: 'userId' }, | ||
{ key: 'sessionId', label: 'sessionId' }, | ||
{ key: 'random', label: 'random' }, | ||
]; | ||
|
||
interface IStickinessSelectProps { | ||
label: string; | ||
value: string | undefined; | ||
editable: boolean; | ||
onChange: (event: SelectChangeEvent) => void; | ||
dataTestId?: string; | ||
} | ||
export const StickinessSelect = ({ | ||
label, | ||
editable, | ||
value, | ||
onChange, | ||
dataTestId, | ||
}: IStickinessSelectProps) => { | ||
const { context } = useUnleashContext(); | ||
|
||
const resolveStickinessOptions = () => | ||
builtInStickinessOptions.concat( | ||
context | ||
.filter(contextDefinition => contextDefinition.stickiness) | ||
.filter( | ||
contextDefinition => | ||
!builtInStickinessOptions.find( | ||
builtInStickinessOption => | ||
builtInStickinessOption.key === | ||
contextDefinition.name | ||
) | ||
) | ||
.map(c => ({ key: c.name, label: c.name })) | ||
); | ||
|
||
const stickinessOptions = resolveStickinessOptions(); | ||
|
||
return ( | ||
<Select | ||
id="stickiness-select" | ||
name="stickiness" | ||
label={label} | ||
options={stickinessOptions} | ||
value={value} | ||
disabled={!editable} | ||
data-testid={dataTestId} | ||
onChange={onChange} | ||
style={{ width: 'inherit', minWidth: '100%' }} | ||
/> | ||
); | ||
}; |
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
Oops, something went wrong.