import { Typography, TypographyProps, styled } from '@mui/material'; import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'; import { Badge } from 'component/common/Badge/Badge'; import { Step } from 'react-joyride'; import { specificUser, gradualRollout, variants } from './demo-setup'; import { basePath, formatAssetPath } from 'utils/formatPath'; import demoUserId from 'assets/img/demo-userid.png'; export interface ITutorialTopicStep extends Step { href?: string; nextButton?: boolean; backCloseModal?: boolean; backCollapseExpanded?: boolean; preventDefault?: boolean; anyClick?: boolean; optional?: boolean; focus?: boolean | string; delay?: number; } export interface ITutorialTopic { title: string; setup?: () => Promise; steps: ITutorialTopicStep[]; } const Description = (props: TypographyProps) => ( ); const StyledImg = styled('img')(({ theme }) => ({ borderRadius: theme.shape.borderRadius, })); const PROJECT = 'demo-app'; const ENVIRONMENT = 'dev'; export const TOPICS: ITutorialTopic[] = [ { title: 'Enable/disable a feature toggle', steps: [ { href: `/projects/${PROJECT}?sort=name`, target: 'body', placement: 'center', content: ( <> Feature toggles {' '} are the central concept of Unleash. Feature toggles are organized within{' '} projects . ), nextButton: true, }, { href: `/projects/${PROJECT}?sort=name`, target: `div[data-testid="TOGGLE-demoApp.step1-${ENVIRONMENT}"]`, content: ( <> Enable or disable the feature for everyone by toggling the highlighted switch. }> Look at the demo page to see your changes! ), nextButton: true, }, ], }, { title: 'Enable for a specific user', setup: specificUser, steps: [ { href: `/projects/${PROJECT}?sort=name`, 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}?sort=name`, target: `a[href="${basePath}/projects/${PROJECT}/features/demoApp.step2"]`, content: ( First, open the feature toggle configuration for{' '} demoApp.step2 by using this link. ), 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 using this button. ), }, { target: `a[href="${basePath}/projects/${PROJECT}/features/demoApp.step2/strategies/create?environmentId=${ENVIRONMENT}&strategyName=default&defaultStrategy=false"]`, content: ( Select the Standard strategy type. ), placement: 'right', optional: true, 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. Add a constraint by using this button. ), backCloseModal: true, }, { target: '#context-field-select', content: ( <> Unleash context {' '} contains information relating to the current feature toggle request. Select the context field by using this dropdown. ), 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. When you're done, use the "Next" button in the dialog. ), placement: 'right', nextButton: true, focus: 'input', }, { target: 'button[data-testid="CONSTRAINT_VALUES_ADD_BUTTON"]', content: ( Add the constraint value by using this button. ), }, { target: 'button[data-testid="CONSTRAINT_SAVE_BUTTON"]', content: ( Save the constraint by using this button. ), }, { target: 'button[data-testid="STRATEGY_FORM_SUBMIT_ID"]', content: ( Save and apply your strategy by using this button. ), backCloseModal: true, }, { target: 'button[data-testid="DIALOGUE_CONFIRM_ID"]', content: ( Confirm your changes by using this button. ), optional: true, backCloseModal: true, }, { href: `/projects/${PROJECT}?sort=name`, target: `div[data-testid="TOGGLE-demoApp.step2-${ENVIRONMENT}"]`, content: ( <> Finally, enable or disable the feature for your user by toggling the highlighted switch. }> Look at the demo page to see your changes! ), nextButton: true, delay: 500, }, ], }, { title: 'Adjust gradual rollout', setup: gradualRollout, steps: [ { href: `/projects/${PROJECT}?sort=name`, 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}?sort=name`, target: `a[href="${basePath}/projects/${PROJECT}/features/demoApp.step3"]`, content: ( First, open the feature toggle configuration for{' '} demoApp.step3 by using this link. ), 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 by using the arrow button. ), }, { target: `div[data-testid="FEATURE_ENVIRONMENT_ACCORDION_${ENVIRONMENT}"].Mui-expanded a[data-testid="STRATEGY_EDIT-flexibleRollout"]`, content: ( Edit the existing gradual rollout strategy by using the "Edit" button. ), backCollapseExpanded: true, }, { target: 'span[data-testid="ROLLOUT_SLIDER_ID"]', content: ( <> Change the rollout percentage by adjusting the percentage slider. When you're done, use the "Next" button in the dialog. ), backCloseModal: true, nextButton: true, }, { target: 'button[data-testid="STRATEGY_FORM_SUBMIT_ID"]', content: ( Save and apply your strategy by using this button. ), }, { target: 'button[data-testid="DIALOGUE_CONFIRM_ID"]', content: ( Confirm your changes by using this button. ), optional: true, backCloseModal: true, }, { href: `/projects/${PROJECT}?sort=name`, target: `div[data-testid="TOGGLE-demoApp.step3-${ENVIRONMENT}"]`, content: ( <> Finally, enable or disable the feature with the new variant by toggling the highlighted switch. }> Look at the demo page to see your changes! ), nextButton: true, delay: 500, }, ], }, { title: 'Adjust variants', setup: variants, steps: [ { href: `/projects/${PROJECT}?sort=name`, target: 'body', placement: 'center', content: ( <> Strategy 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 strategy. ), nextButton: true, }, { href: `/projects/${PROJECT}?sort=name`, target: `a[href="${basePath}/projects/${PROJECT}/features/demoApp.step4"]`, content: ( First, open the feature toggle configuration for{' '} demoApp.step4 by using this link. ), preventDefault: true, }, { href: `/projects/${PROJECT}/features/demoApp.step4`, target: `div[data-testid="FEATURE_ENVIRONMENT_ACCORDION_${ENVIRONMENT}"] button`, content: ( Add a new strategy to this environment by using this button. ), }, { 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. Add a constraint by using this button. ), backCloseModal: true, }, { target: '#context-field-select', content: ( <> Unleash context {' '} contains information relating to the current feature toggle request. Select the context field by using this dropdown. ), 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. When you're done, use the "Next" button in the dialog. ), placement: 'right', nextButton: true, focus: 'input', }, { target: 'button[data-testid="CONSTRAINT_VALUES_ADD_BUTTON"]', content: ( Add the constraint value by using this button. ), }, { target: 'button[data-testid="CONSTRAINT_SAVE_BUTTON"]', content: ( Save the constraint by using this button. ), }, { target: 'button[data-testid="ADD_STRATEGY_VARIANT_BUTTON"]', content: ( <> Strategy variants {' '} allow to attach one or more values to your{' '} activation strategy {' '} . Add a strategy variant by using this button. ), backCloseModal: true, }, { target: 'div[data-testid="VARIANT"]:last-of-type div[data-testid="VARIANT_NAME_INPUT"]', content: ( <> Enter a name for your variant e.g.{' '} color When you're done, use the "Next" button in the dialog. ), nextButton: true, focus: 'input', backCloseModal: true, }, { target: 'div[data-testid="VARIANT"]:last-of-type #variant-payload-value', content: ( <> Enter a{' '} color {' '} as the payload. It will be passed along and used in the demo website. It can be any color. For example, you can use one of these: teal,{' '} orange or{' '} purple When you're done, use the "Next" button in the dialog. ), nextButton: true, focus: true, }, { target: 'button[data-testid="STRATEGY_FORM_SUBMIT_ID"]', content: ( Save and apply your strategy by using this button. ), backCloseModal: true, }, { href: `/projects/${PROJECT}?sort=name`, target: `div[data-testid="TOGGLE-demoApp.step4-${ENVIRONMENT}"]`, content: ( <> Finally, enable or disable the feature with the new variant by toggling the highlighted switch. }> Look at the demo page to see your changes! ), nextButton: true, delay: 500, }, ], }, ];