From e8511789fd0a05b18f22ba7413f8c1f392bc57e3 Mon Sep 17 00:00:00 2001 From: Jaanus Sellin Date: Wed, 26 Jun 2024 11:39:53 +0200 Subject: [PATCH] feat: command menu items can have description as tooltip now (#7455) ![image](https://github.com/Unleash/unleash/assets/964450/7a55a1a7-7aea-4f9c-96ac-46adf2edd36f) --- .../src/component/commandBar/CommandFeatures.tsx | 1 + .../RecentlyVisited/CommandResultGroup.tsx | 16 ++++++++++++---- .../common/TooltipResolver/TooltipResolver.tsx | 2 +- .../ProjectFeatureToggles.tsx | 1 + .../src/openapi/models/createProjectSchema.ts | 2 +- ...ProjectSchemaChangeRequestEnvironmentsItem.ts | 2 +- .../models/featureSearchResponseSchema.ts | 2 +- .../src/openapi/models/projectCreatedSchema.ts | 4 ++-- frontend/src/utils/formatAccessText.ts | 4 ++-- .../spec/feature-search-response-schema.ts | 1 + 10 files changed, 23 insertions(+), 12 deletions(-) diff --git a/frontend/src/component/commandBar/CommandFeatures.tsx b/frontend/src/component/commandBar/CommandFeatures.tsx index ee486472cf..341025f667 100644 --- a/frontend/src/component/commandBar/CommandFeatures.tsx +++ b/frontend/src/component/commandBar/CommandFeatures.tsx @@ -21,6 +21,7 @@ export const CommandFeatures = ({ searchString }: ICommandBar) => { const flags: CommandResultGroupItem[] = features.map((feature) => ({ name: feature.name, link: `/projects/${feature.project}/features/${feature.name}`, + description: feature.description, })); return ( diff --git a/frontend/src/component/commandBar/RecentlyVisited/CommandResultGroup.tsx b/frontend/src/component/commandBar/RecentlyVisited/CommandResultGroup.tsx index 6ae58c1376..47fa48060e 100644 --- a/frontend/src/component/commandBar/RecentlyVisited/CommandResultGroup.tsx +++ b/frontend/src/component/commandBar/RecentlyVisited/CommandResultGroup.tsx @@ -10,7 +10,8 @@ import { import { Link } from 'react-router-dom'; import type { Theme } from '@mui/material/styles/createTheme'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; -import { StyledProjectIcon } from '../../layout/MainLayout/NavigationSidebar/IconRenderer'; +import { StyledProjectIcon } from 'component/layout/MainLayout/NavigationSidebar/IconRenderer'; +import { TooltipResolver } from 'component/common/TooltipResolver/TooltipResolver'; const listItemButtonStyle = (theme: Theme) => ({ borderRadius: theme.spacing(0.5), @@ -37,6 +38,7 @@ const StyledListItemText = styled(ListItemText)(({ theme }) => ({ export interface CommandResultGroupItem { name: string; link: string; + description?: string | null; } interface CommandResultGroupProps { @@ -76,9 +78,15 @@ export const CommandResultGroup = ({ elseShow={{icon}} /> - - {item.name} - + + + {item.name} + + ))} diff --git a/frontend/src/component/common/TooltipResolver/TooltipResolver.tsx b/frontend/src/component/common/TooltipResolver/TooltipResolver.tsx index 168ad6c6a1..02e08785a8 100644 --- a/frontend/src/component/common/TooltipResolver/TooltipResolver.tsx +++ b/frontend/src/component/common/TooltipResolver/TooltipResolver.tsx @@ -3,7 +3,7 @@ import { Tooltip, type TooltipProps } from '@mui/material'; import { HtmlTooltip } from '../HtmlTooltip/HtmlTooltip'; export interface ITooltipResolverProps extends Omit { - title?: string; + title?: string | null; titleComponent?: ReactNode; variant?: 'default' | 'custom'; } diff --git a/frontend/src/component/project/Project/PaginatedProjectFeatureToggles/ProjectFeatureToggles.tsx b/frontend/src/component/project/Project/PaginatedProjectFeatureToggles/ProjectFeatureToggles.tsx index 9172b56dad..a8614781bf 100644 --- a/frontend/src/component/project/Project/PaginatedProjectFeatureToggles/ProjectFeatureToggles.tsx +++ b/frontend/src/component/project/Project/PaginatedProjectFeatureToggles/ProjectFeatureToggles.tsx @@ -318,6 +318,7 @@ export const ProjectFeatureToggles = ({ id: index, type: '-', name: `Feature name ${index}`, + description: '', createdAt: new Date().toISOString(), createdBy: { id: 0, diff --git a/frontend/src/openapi/models/createProjectSchema.ts b/frontend/src/openapi/models/createProjectSchema.ts index e38fcd4426..c7ff0dc742 100644 --- a/frontend/src/openapi/models/createProjectSchema.ts +++ b/frontend/src/openapi/models/createProjectSchema.ts @@ -20,7 +20,7 @@ export interface CreateProjectSchema { */ description?: string | null; /** - * A list of environments that should be enabled for this project. The list must contain at least one environment. If this property is missing, Unleash will default to enabling all non-deprecated environments for the project. This is a beta feature and is not yet generally available. + * A list of environments that should be enabled for this project. When provided, the list must contain at least one environment. If this property is missing, Unleash will default to enabling all non-deprecated environments for the project. * @minItems 1 */ environments?: string[]; diff --git a/frontend/src/openapi/models/createProjectSchemaChangeRequestEnvironmentsItem.ts b/frontend/src/openapi/models/createProjectSchemaChangeRequestEnvironmentsItem.ts index c66fe16d1c..f5a121efdb 100644 --- a/frontend/src/openapi/models/createProjectSchemaChangeRequestEnvironmentsItem.ts +++ b/frontend/src/openapi/models/createProjectSchemaChangeRequestEnvironmentsItem.ts @@ -7,6 +7,6 @@ export type CreateProjectSchemaChangeRequestEnvironmentsItem = { /** The name of the environment to configure change requests for. */ name: string; - /** The number of approvals required for a change request to be fully approved and ready to applied in this environment. If no value is provided, it will be set to the default number, which is 1. Values will be clamped to between 1 and 10 inclusive. this is a beta feature is not yet generally available. */ + /** The number of approvals required for a change request to be fully approved and ready to applied in this environment. If no value is provided, it will be set to the default number, which is 1. Values will be clamped to between 1 and 10 inclusive. */ requiredApprovals?: number; }; diff --git a/frontend/src/openapi/models/featureSearchResponseSchema.ts b/frontend/src/openapi/models/featureSearchResponseSchema.ts index 6a976cfd77..14d1d75673 100644 --- a/frontend/src/openapi/models/featureSearchResponseSchema.ts +++ b/frontend/src/openapi/models/featureSearchResponseSchema.ts @@ -38,7 +38,7 @@ export interface FeatureSearchResponseSchema { * Detailed description of the feature * @nullable */ - description?: string | null; + description: string | null; /** The list of environments where the feature can be used */ environments: FeatureSearchEnvironmentSchema[]; /** `true` if the feature was favorited, otherwise `false`. */ diff --git a/frontend/src/openapi/models/projectCreatedSchema.ts b/frontend/src/openapi/models/projectCreatedSchema.ts index d3ca092df5..3a203d3821 100644 --- a/frontend/src/openapi/models/projectCreatedSchema.ts +++ b/frontend/src/openapi/models/projectCreatedSchema.ts @@ -10,7 +10,7 @@ import type { ProjectCreatedSchemaMode } from './projectCreatedSchemaMode'; * Details about the newly created project. */ export interface ProjectCreatedSchema { - /** The list of environments that have change requests enabled. This is a beta feature and may be subject to change. */ + /** The list of environments that have change requests enabled. */ changeRequestEnvironments?: ProjectCreatedSchemaChangeRequestEnvironmentsItem[]; /** A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy */ defaultStickiness?: string; @@ -20,7 +20,7 @@ export interface ProjectCreatedSchema { */ description?: string | null; /** - * The environments enabled for the project. This is a beta feature and may be subject to change. + * The environments enabled for the project. * @minItems 1 */ environments?: string[]; diff --git a/frontend/src/utils/formatAccessText.ts b/frontend/src/utils/formatAccessText.ts index fa5570b4b2..dfa2138a57 100644 --- a/frontend/src/utils/formatAccessText.ts +++ b/frontend/src/utils/formatAccessText.ts @@ -2,8 +2,8 @@ export const ACCESS_DENIED_TEXT = 'Access denied'; export const formatAccessText = ( hasAccess: boolean, - hasAccessText?: string, -): string | undefined => { + hasAccessText?: string | null, +): string | undefined | null => { if (hasAccess) { return hasAccessText; } diff --git a/src/lib/openapi/spec/feature-search-response-schema.ts b/src/lib/openapi/spec/feature-search-response-schema.ts index e951452d8f..3bb5e64f6d 100644 --- a/src/lib/openapi/spec/feature-search-response-schema.ts +++ b/src/lib/openapi/spec/feature-search-response-schema.ts @@ -14,6 +14,7 @@ export const featureSearchResponseSchema = { additionalProperties: false, required: [ 'name', + 'description', 'dependencyType', 'type', 'project',