1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-10 01:16:39 +02:00

feat: show documentation relating to the specific thing your configuring in the new project form (#6993)

This PR updates the documentation text in the new project form to show
the documentation relating to the specific thing you're configuring.
This commit is contained in:
Thomas Heartman 2024-05-07 08:56:53 +02:00 committed by GitHub
parent 77d5156eba
commit 913f81b40c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 61 additions and 9 deletions

View File

@ -16,6 +16,7 @@ import { GO_BACK } from 'constants/navigate';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker'; import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
import { Button, styled } from '@mui/material'; import { Button, styled } from '@mui/material';
import { useUiFlag } from 'hooks/useUiFlag'; import { useUiFlag } from 'hooks/useUiFlag';
import { useState } from 'react';
const CREATE_PROJECT_BTN = 'CREATE_PROJECT_BTN'; const CREATE_PROJECT_BTN = 'CREATE_PROJECT_BTN';
@ -51,6 +52,14 @@ const CreateProject = () => {
errors, errors,
} = useProjectForm(); } = useProjectForm();
const generalDocumentation =
'Projects allows you to group feature toggles together in the management UI.';
const [documentation, setDocumentation] = useState(generalDocumentation);
const clearDocumentationOverride = () =>
setDocumentation(generalDocumentation);
const useNewProjectForm = useUiFlag('newCreateProjectUI'); const useNewProjectForm = useUiFlag('newCreateProjectUI');
const { createProject, loading } = useProjectApi(); const { createProject, loading } = useProjectApi();
@ -102,7 +111,7 @@ const CreateProject = () => {
<FormTemplate <FormTemplate
disablePadding disablePadding
loading={loading} loading={loading}
description='Projects allows you to group feature toggles together in the management UI.' description={documentation}
documentationLink='https://docs.getunleash.io/reference/projects' documentationLink='https://docs.getunleash.io/reference/projects'
documentationLinkLabel='Projects documentation' documentationLinkLabel='Projects documentation'
formatApiCode={formatApiCode} formatApiCode={formatApiCode}
@ -131,6 +140,8 @@ const CreateProject = () => {
mode='Create' mode='Create'
clearErrors={clearErrors} clearErrors={clearErrors}
validateProjectId={validateProjectId} validateProjectId={validateProjectId}
overrideDocumentation={setDocumentation}
clearDocumentationOverride={clearDocumentationOverride}
> >
<StyledButton onClick={handleCancel}>Cancel</StyledButton> <StyledButton onClick={handleCancel}>Cancel</StyledButton>
<CreateButton <CreateButton

View File

@ -109,6 +109,8 @@ type FormProps = {
mode: 'Create' | 'Edit'; mode: 'Create' | 'Edit';
clearErrors: () => void; clearErrors: () => void;
validateProjectId: () => void; validateProjectId: () => void;
overrideDocumentation: (description: string) => void;
clearDocumentationOverride: () => void;
}; };
const PROJECT_NAME_INPUT = 'PROJECT_NAME_INPUT'; const PROJECT_NAME_INPUT = 'PROJECT_NAME_INPUT';
@ -137,6 +139,8 @@ export const NewProjectForm: React.FC<FormProps> = ({
errors, errors,
mode, mode,
clearErrors, clearErrors,
overrideDocumentation,
clearDocumentationOverride,
}) => { }) => {
const { isEnterprise } = useUiConfig(); const { isEnterprise } = useUiConfig();
const { environments: allEnvironments } = useEnvironments(); const { environments: allEnvironments } = useEnvironments();
@ -219,6 +223,12 @@ export const NewProjectForm: React.FC<FormProps> = ({
label: 'Filter project environments', label: 'Filter project environments',
placeholder: 'Select project environments', placeholder: 'Select project environments',
}} }}
onOpen={() =>
overrideDocumentation(
`Each feature toggle can have a separate configuration per environment. This setting configures which environments your project should start with.`,
)
}
onClose={clearDocumentationOverride}
/> />
<SingleSelectList <SingleSelectList
@ -237,6 +247,12 @@ export const NewProjectForm: React.FC<FormProps> = ({
label: 'Filter stickiness options', label: 'Filter stickiness options',
placeholder: 'Select default stickiness', placeholder: 'Select default stickiness',
}} }}
onOpen={() =>
overrideDocumentation(
'Stickiness is used to guarantee that your users see the same result when using a gradual rollout. Default stickiness allows you to choose which field is used by default in this project.',
)
}
onClose={clearDocumentationOverride}
/> />
<ConditionallyRender <ConditionallyRender
@ -255,6 +271,12 @@ export const NewProjectForm: React.FC<FormProps> = ({
label: 'Filter project mode options', label: 'Filter project mode options',
placeholder: 'Select project mode', placeholder: 'Select project mode',
}} }}
onOpen={() =>
overrideDocumentation(
'Mode defines who should be allowed to interact and see your project. Private mode hides the project from anyone except the project owner and members.',
)
}
onClose={clearDocumentationOverride}
/> />
} }
/> />
@ -294,6 +316,12 @@ export const NewProjectForm: React.FC<FormProps> = ({
projectChangeRequestConfiguration={ projectChangeRequestConfiguration={
projectChangeRequestConfiguration projectChangeRequestConfiguration
} }
onOpen={() =>
overrideDocumentation(
'Change requests can be configured per environment and require changes to go through an approval process before being applied.',
)
}
onClose={clearDocumentationOverride}
/> />
} }
/> />

View File

@ -79,6 +79,8 @@ type CombinedSelectProps = {
placeholder: string; placeholder: string;
}; };
multiselect?: { selectedOptions: Set<string> }; multiselect?: { selectedOptions: Set<string> };
onOpen?: () => void;
onClose?: () => void;
}; };
const CombinedSelect: FC<CombinedSelectProps> = ({ const CombinedSelect: FC<CombinedSelectProps> = ({
@ -87,6 +89,8 @@ const CombinedSelect: FC<CombinedSelectProps> = ({
button, button,
search, search,
multiselect, multiselect,
onOpen = () => {},
onClose = () => {},
}) => { }) => {
const ref = useRef<HTMLDivElement>(null); const ref = useRef<HTMLDivElement>(null);
const [anchorEl, setAnchorEl] = useState<HTMLDivElement | null>(); const [anchorEl, setAnchorEl] = useState<HTMLDivElement | null>();
@ -95,16 +99,18 @@ const CombinedSelect: FC<CombinedSelectProps> = ({
const open = () => { const open = () => {
setSearchText(''); setSearchText('');
setAnchorEl(ref.current); setAnchorEl(ref.current);
onOpen();
}; };
const onClose = () => { const handleClose = () => {
setAnchorEl(null); setAnchorEl(null);
onClose();
}; };
const onSelection = (selected: string) => { const onSelection = (selected: string) => {
onChange(selected); onChange(selected);
if (!multiselect) { if (!multiselect) {
onClose(); handleClose();
} }
}; };
@ -135,7 +141,7 @@ const CombinedSelect: FC<CombinedSelectProps> = ({
<StyledPopover <StyledPopover
open={Boolean(anchorEl)} open={Boolean(anchorEl)}
anchorEl={anchorEl} anchorEl={anchorEl}
onClose={onClose} onClose={handleClose}
anchorOrigin={{ anchorOrigin={{
vertical: 'bottom', vertical: 'bottom',
horizontal: 'left', horizontal: 'left',
@ -222,7 +228,7 @@ const CombinedSelect: FC<CombinedSelectProps> = ({
type MultiselectListProps = Pick< type MultiselectListProps = Pick<
CombinedSelectProps, CombinedSelectProps,
'options' | 'button' | 'search' 'options' | 'button' | 'search' | 'onOpen' | 'onClose'
> & { > & {
selectedOptions: Set<string>; selectedOptions: Set<string>;
onChange: (values: Set<string>) => void; onChange: (values: Set<string>) => void;
@ -258,14 +264,17 @@ export const MultiselectList: FC<MultiselectListProps> = ({
type SingleSelectListProps = Pick< type SingleSelectListProps = Pick<
CombinedSelectProps, CombinedSelectProps,
'options' | 'button' | 'search' | 'onChange' 'options' | 'button' | 'search' | 'onChange' | 'onOpen' | 'onClose'
>; >;
export const SingleSelectList: FC<SingleSelectListProps> = (props) => { export const SingleSelectList: FC<SingleSelectListProps> = (props) => {
return <CombinedSelect {...props} />; return <CombinedSelect {...props} />;
}; };
type TableSelectProps = Pick<CombinedSelectProps, 'button' | 'search'> & { type TableSelectProps = Pick<
CombinedSelectProps,
'button' | 'search' | 'onOpen' | 'onClose'
> & {
updateProjectChangeRequestConfiguration: { updateProjectChangeRequestConfiguration: {
disableChangeRequests: (env: string) => void; disableChangeRequests: (env: string) => void;
enableChangeRequests: (env: string, requiredApprovals: number) => void; enableChangeRequests: (env: string, requiredApprovals: number) => void;
@ -287,6 +296,8 @@ export const TableSelect: FC<TableSelectProps> = ({
projectChangeRequestConfiguration, projectChangeRequestConfiguration,
updateProjectChangeRequestConfiguration, updateProjectChangeRequestConfiguration,
activeEnvironments, activeEnvironments,
onOpen = () => {},
onClose = () => {},
}) => { }) => {
const configured = useMemo(() => { const configured = useMemo(() => {
return Object.fromEntries( return Object.fromEntries(
@ -327,10 +338,12 @@ export const TableSelect: FC<TableSelectProps> = ({
const open = () => { const open = () => {
setSearchText(''); setSearchText('');
setAnchorEl(ref.current); setAnchorEl(ref.current);
onOpen();
}; };
const onClose = () => { const handleClose = () => {
setAnchorEl(null); setAnchorEl(null);
onClose();
}; };
const filteredEnvs = tableEnvs.filter((env) => const filteredEnvs = tableEnvs.filter((env) =>
@ -370,7 +383,7 @@ export const TableSelect: FC<TableSelectProps> = ({
<StyledPopover <StyledPopover
open={Boolean(anchorEl)} open={Boolean(anchorEl)}
anchorEl={anchorEl} anchorEl={anchorEl}
onClose={onClose} onClose={handleClose}
anchorOrigin={{ anchorOrigin={{
vertical: 'bottom', vertical: 'bottom',
horizontal: 'left', horizontal: 'left',