import { Typography, TypographyProps } from '@mui/material'; import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'; import { Badge } from 'component/common/Badge/Badge'; import { Step } from 'react-joyride'; import { gradualRollout, variants } from './demo-setup'; import { basePath } from 'utils/formatPath'; export interface ITutorialTopicStep extends Step { href?: string; nextButton?: boolean; backCloseModal?: boolean; backCollapseExpanded?: boolean; preventDefault?: boolean; anyClick?: boolean; optional?: boolean; } export interface ITutorialTopic { title: string; setup?: () => Promise; steps: ITutorialTopicStep[]; } const Description = (props: TypographyProps) => ( ); const PROJECT = 'demo-app'; const ENVIRONMENT = 'dev'; export const TOPICS: ITutorialTopic[] = [ { title: 'Enable/disable a feature toggle', steps: [ { href: `/projects/${PROJECT}`, target: 'body', placement: 'center', content: ( <> Feature toggles {' '} are the central concept of Unleash. Feature toggles are organized within{' '} projects . ), nextButton: true, }, { href: `/projects/${PROJECT}`, target: `div[data-testid="TOGGLE-demoApp.step1-${ENVIRONMENT}"]`, content: ( <> The simplest way to use a feature toggle is to enable or disable it for everyone (on/off). } > Look at the demo page when toggling! ), nextButton: true, }, ], }, { title: 'Enable for a specific user', steps: [ { href: `/projects/${PROJECT}`, target: 'body', placement: 'center', content: ( <> Activation strategies {' '} give you more control over when a feature should be enabled. Let's try enabling a feature toggle only for a specific user. ), nextButton: true, }, { href: `/projects/${PROJECT}`, target: `a[href="${basePath}/projects/${PROJECT}/features/demoApp.step2"]`, content: ( First, let's open the feature toggle configuration for{' '} demoApp.step2 ), preventDefault: true, }, { href: `/projects/${PROJECT}/features/demoApp.step2`, target: `div[data-testid="FEATURE_ENVIRONMENT_ACCORDION_${ENVIRONMENT}"] button`, content: ( Add a new strategy to this environment by clicking this button. ), }, { target: `a[href="${basePath}/projects/${PROJECT}/features/demoApp.step2/strategies/create?environmentId=${ENVIRONMENT}&strategyName=default"]`, content: ( Select the Standard strategy type. ), placement: 'right', backCloseModal: true, }, { target: 'button[data-testid="ADD_CONSTRAINT_BUTTON"]', content: ( <> Strategy constraints {' '} are conditions that must be satisfied for an{' '} activation strategy {' '} to be evaluated for a feature toggle. Click this button to add a constraint. ), backCloseModal: true, }, { target: '#context-field-select', content: ( Unleash context {' '} contains information relating to the current feature toggle request. ), backCloseModal: true, anyClick: true, }, { target: 'li[data-testid="SELECT_ITEM_ID-userId"]', content: ( Select the userId context field. ), placement: 'right', backCloseModal: true, }, { target: 'div[data-testid="CONSTRAINT_VALUES_INPUT"]', content: ( <> Enter your userId } > You can find your userId on the demo page. ), nextButton: true, }, { target: 'button[data-testid="CONSTRAINT_VALUES_ADD_BUTTON"]', content: Add the constraint value., }, { target: 'button[data-testid="CONSTRAINT_SAVE_BUTTON"]', content: Save the constraint., }, { target: 'button[data-testid="STRATEGY_FORM_SUBMIT_ID"]', content: ( <> Save your strategy to apply it. } > Look at the demo page after saving! ), backCloseModal: true, }, { target: 'button[data-testid="DIALOGUE_CONFIRM_ID"]', content: ( <> Confirm your changes. } > Look at the demo page after saving! ), optional: true, backCloseModal: true, }, ], }, { title: 'Adjust gradual rollout', setup: gradualRollout, steps: [ { href: `/projects/${PROJECT}`, target: 'body', placement: 'center', content: ( <> Gradual rollout {' '} is one of the available{' '} activation strategies . Let's try enabling a feature toggle only for a certain percentage of users. ), nextButton: true, }, { href: `/projects/${PROJECT}`, target: `a[href="${basePath}/projects/${PROJECT}/features/demoApp.step3"]`, content: ( First, let's open the feature toggle configuration for{' '} demoApp.step3 ), preventDefault: true, }, { href: `/projects/${PROJECT}/features/demoApp.step3`, target: `div[data-testid="FEATURE_ENVIRONMENT_ACCORDION_${ENVIRONMENT}"] .MuiAccordionSummary-expandIconWrapper`, content: ( Expand the environment card to see all the defined strategies. ), }, { target: `div[data-testid="FEATURE_ENVIRONMENT_ACCORDION_${ENVIRONMENT}"].Mui-expanded a[data-testid="STRATEGY_EDIT-flexibleRollout"]`, content: ( Edit the existing gradual rollout strategy. ), backCollapseExpanded: true, }, { target: 'span[data-testid="ROLLOUT_SLIDER_ID"]', content: ( Change the rollout percentage. ), backCloseModal: true, nextButton: true, }, { target: 'button[data-testid="STRATEGY_FORM_SUBMIT_ID"]', content: ( <> Save your strategy to apply it. } > Look at the demo page after saving! ), }, { target: 'button[data-testid="DIALOGUE_CONFIRM_ID"]', content: ( <> Confirm your changes. } > Look at the demo page after saving! ), optional: true, backCloseModal: true, }, ], }, { title: 'Adjust variants', setup: variants, steps: [ { href: `/projects/${PROJECT}`, target: 'body', placement: 'center', content: ( <> Feature toggle variants {' '} allow you to define different values for a feature toggle. They can be used for A/B testing or segmenting your users. Let's try adding a variant to a feature toggle, along with an override so our user can see it. ), nextButton: true, }, { href: `/projects/${PROJECT}`, target: `a[href="${basePath}/projects/${PROJECT}/features/demoApp.step4"]`, content: ( First, let's open the feature toggle configuration for{' '} demoApp.step4 ), preventDefault: true, }, { href: `/projects/${PROJECT}/features/demoApp.step4`, target: 'button[data-testid="TAB-Variants"]', content: Select the variants tab., }, { target: 'button[data-testid="EDIT_VARIANTS_BUTTON"]', content: Edit the existing variants., }, { target: 'button[data-testid="MODAL_ADD_VARIANT_BUTTON"]', content: ( Add a new variant to the list. ), backCloseModal: true, }, { target: 'div[data-testid="VARIANT"]:last-of-type div[data-testid="VARIANT_NAME_INPUT"]', content: ( <> Enter a new variant name. We recommend choosing a{' '} color . Example: aqua ), backCloseModal: true, nextButton: true, }, { target: 'div[data-testid="VARIANT"]:last-of-type #variant-payload-value', content: ( Enter the{' '} color {' '} you chose on the previous step as the payload. ), nextButton: true, }, { target: 'div[data-testid="VARIANT"]:last-of-type button[data-testid="VARIANT_ADD_OVERRIDE_BUTTON"]', content: ( Let's also add an override for our user. ), }, { target: 'div[data-testid="VARIANT"]:last-of-type #override-context-name', content: Choose a context field., anyClick: true, backCloseModal: true, }, { target: 'li[data-testid="SELECT_ITEM_ID-userId"]', content: ( Select the userId context field. ), placement: 'right', backCloseModal: true, }, { target: 'div[data-testid="VARIANT"]:last-of-type div[data-testid="OVERRIDE_VALUES"]', content: ( <> Enter your userId } > You can find your userId on the demo page. ), nextButton: true, backCloseModal: true, }, { target: 'button[data-testid="DIALOGUE_CONFIRM_ID"]', content: ( <> Save your variants to apply them. } > Look at the demo page after saving! ), }, ], }, ];