From 9969433f8c5c761d855d5f6f5018d6b4906318bc Mon Sep 17 00:00:00 2001 From: Jaanus Sellin Date: Tue, 21 Mar 2023 11:10:07 +0200 Subject: [PATCH] refactor: not used cleanup (#3347) --- .../UsersList/UserTypeCell/UserTypeCell.tsx | 2 +- .../Notifications/NotificationsHeader.tsx | 7 ++-- frontend/src/component/menu/Header/Header.tsx | 1 - .../ContextBanner/ContextBanner.tsx | 39 ------------------- .../Project/ProjectStats/ProjectStats.tsx | 10 ----- .../useNotificationsApi.ts | 1 - .../useNotifications/useNotifications.ts | 2 +- .../api/getters/useProject/useProject.ts | 1 - .../models/createFeatureStrategySchema.ts | 2 + .../openapi/models/healthOverviewSchema.ts | 6 +++ .../healthOverviewSchemaDefaultStickiness.ts | 19 +++++++++ .../models/healthOverviewSchemaMode.ts | 18 +++++++++ .../src/openapi/models/healthReportSchema.ts | 6 +++ .../healthReportSchemaDefaultStickiness.ts | 19 +++++++++ .../openapi/models/healthReportSchemaMode.ts | 18 +++++++++ frontend/src/openapi/models/index.ts | 6 ++- frontend/src/openapi/models/projectSchema.ts | 5 ++- .../models/projectSchemaDefaultStickiness.ts | 19 +++++++++ .../src/openapi/models/projectSchemaMode.ts | 3 +- .../src/openapi/models/projectStatsSchema.ts | 2 - .../src/openapi/models/stickinessSchema.ts | 9 ----- 21 files changed, 122 insertions(+), 73 deletions(-) delete mode 100644 frontend/src/component/playground/Playground/PlaygroundResultsTable/ContextBanner/ContextBanner.tsx create mode 100644 frontend/src/openapi/models/healthOverviewSchemaDefaultStickiness.ts create mode 100644 frontend/src/openapi/models/healthOverviewSchemaMode.ts create mode 100644 frontend/src/openapi/models/healthReportSchemaDefaultStickiness.ts create mode 100644 frontend/src/openapi/models/healthReportSchemaMode.ts create mode 100644 frontend/src/openapi/models/projectSchemaDefaultStickiness.ts delete mode 100644 frontend/src/openapi/models/stickinessSchema.ts diff --git a/frontend/src/component/admin/users/UsersList/UserTypeCell/UserTypeCell.tsx b/frontend/src/component/admin/users/UsersList/UserTypeCell/UserTypeCell.tsx index 9760d71287..375dcab26a 100644 --- a/frontend/src/component/admin/users/UsersList/UserTypeCell/UserTypeCell.tsx +++ b/frontend/src/component/admin/users/UsersList/UserTypeCell/UserTypeCell.tsx @@ -1,4 +1,4 @@ -import { AttachMoneyRounded, MonetizationOn } from '@mui/icons-material'; +import { AttachMoneyRounded } from '@mui/icons-material'; import { styled, Tooltip } from '@mui/material'; import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender'; import { TextCell } from 'component/common/Table/cells/TextCell/TextCell'; diff --git a/frontend/src/component/common/Notifications/NotificationsHeader.tsx b/frontend/src/component/common/Notifications/NotificationsHeader.tsx index 3ddff8a6de..5aec88b3e4 100644 --- a/frontend/src/component/common/Notifications/NotificationsHeader.tsx +++ b/frontend/src/component/common/Notifications/NotificationsHeader.tsx @@ -1,6 +1,5 @@ -import Settings from '@mui/icons-material/Settings'; -import { Typography, IconButton, styled, Box } from '@mui/material'; -import { flexRow } from 'themes/themeStyles'; +import { Typography, styled, Box } from '@mui/material'; +import { FC } from 'react'; const StyledOuterContainerBox = styled(Box)(({ theme }) => ({ padding: theme.spacing(1.5, 3, 0.5, 3), @@ -15,7 +14,7 @@ const StyledInnerBox = styled(Box)(({ theme }) => ({ height: '4px', })); -export const NotificationsHeader: React.FC = ({ children }) => { +export const NotificationsHeader: FC = ({ children }) => { return ( <> diff --git a/frontend/src/component/menu/Header/Header.tsx b/frontend/src/component/menu/Header/Header.tsx index 31af6e1531..bde83f0ced 100644 --- a/frontend/src/component/menu/Header/Header.tsx +++ b/frontend/src/component/menu/Header/Header.tsx @@ -11,7 +11,6 @@ import { Switch, styled, Theme, - Box, } from '@mui/material'; import MenuIcon from '@mui/icons-material/Menu'; import SettingsIcon from '@mui/icons-material/Settings'; diff --git a/frontend/src/component/playground/Playground/PlaygroundResultsTable/ContextBanner/ContextBanner.tsx b/frontend/src/component/playground/Playground/PlaygroundResultsTable/ContextBanner/ContextBanner.tsx deleted file mode 100644 index 20bbaf78ea..0000000000 --- a/frontend/src/component/playground/Playground/PlaygroundResultsTable/ContextBanner/ContextBanner.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { colors } from 'themes/colors'; -import { Alert, styled } from '@mui/material'; -import { SdkContextSchema } from 'openapi'; - -interface IContextBannerProps { - environment: string; - projects?: string | string[]; - context: SdkContextSchema; -} - -const StyledContextFieldList = styled('ul')(({ theme }) => ({ - color: theme.palette.text.primary, - listStyleType: 'none', - padding: theme.spacing(2), -})); - -export const ContextBanner = ({ - environment, - projects = [], - context, -}: IContextBannerProps) => { - return ( - - Your results are generated based on this configuration: - -
  • environment: {environment}
  • -
  • - projects:{' '} - {Array.isArray(projects) ? projects.join(', ') : projects} -
  • - {Object.entries(context).map(([key, value]) => ( -
  • - {key}: {value} -
  • - ))} -
    -
    - ); -}; diff --git a/frontend/src/component/project/Project/ProjectStats/ProjectStats.tsx b/frontend/src/component/project/Project/ProjectStats/ProjectStats.tsx index 9ca09bd511..c713904634 100644 --- a/frontend/src/component/project/Project/ProjectStats/ProjectStats.tsx +++ b/frontend/src/component/project/Project/ProjectStats/ProjectStats.tsx @@ -52,7 +52,6 @@ export const ProjectStats = ({ stats }: IProjectStatsProps) => { const { avgTimeToProdCurrentWindow, - avgTimeToProdPastWindow, projectActivityCurrentWindow, projectActivityPastWindow, createdCurrentWindow, @@ -61,15 +60,6 @@ export const ProjectStats = ({ stats }: IProjectStatsProps) => { archivedPastWindow, } = stats; - const calculatePercentage = (partial: number, total: number) => { - const percentage = (partial * 100) / total; - - if (Number.isInteger(percentage)) { - return percentage; - } - return 0; - }; - return ( diff --git a/frontend/src/hooks/api/actions/useNotificationsApi/useNotificationsApi.ts b/frontend/src/hooks/api/actions/useNotificationsApi/useNotificationsApi.ts index 296a75ed5a..89c7e8c82f 100644 --- a/frontend/src/hooks/api/actions/useNotificationsApi/useNotificationsApi.ts +++ b/frontend/src/hooks/api/actions/useNotificationsApi/useNotificationsApi.ts @@ -1,4 +1,3 @@ -import { NotificationsSchemaItem } from 'openapi'; import useAPI from '../useApi/useApi'; export const useNotificationsApi = () => { diff --git a/frontend/src/hooks/api/getters/useNotifications/useNotifications.ts b/frontend/src/hooks/api/getters/useNotifications/useNotifications.ts index 5278228d66..c321094005 100644 --- a/frontend/src/hooks/api/getters/useNotifications/useNotifications.ts +++ b/frontend/src/hooks/api/getters/useNotifications/useNotifications.ts @@ -1,5 +1,5 @@ import useSWR, { SWRConfiguration } from 'swr'; -import { useCallback, useMemo } from 'react'; +import { useCallback } from 'react'; import { formatApiPath } from 'utils/formatPath'; import handleErrorResponses from '../httpErrorResponseHandler'; import { NotificationsSchema } from 'openapi'; diff --git a/frontend/src/hooks/api/getters/useProject/useProject.ts b/frontend/src/hooks/api/getters/useProject/useProject.ts index e02b9852d1..5925d718b0 100644 --- a/frontend/src/hooks/api/getters/useProject/useProject.ts +++ b/frontend/src/hooks/api/getters/useProject/useProject.ts @@ -17,7 +17,6 @@ const fallbackProject: IProject = { archivedCurrentWindow: 0, archivedPastWindow: 0, avgTimeToProdCurrentWindow: 0, - avgTimeToProdPastWindow: 0, createdCurrentWindow: 0, createdPastWindow: 0, projectActivityCurrentWindow: 0, diff --git a/frontend/src/openapi/models/createFeatureStrategySchema.ts b/frontend/src/openapi/models/createFeatureStrategySchema.ts index 079d1e02a5..f0c584980e 100644 --- a/frontend/src/openapi/models/createFeatureStrategySchema.ts +++ b/frontend/src/openapi/models/createFeatureStrategySchema.ts @@ -11,4 +11,6 @@ export interface CreateFeatureStrategySchema { sortOrder?: number; constraints?: ConstraintSchema[]; parameters?: ParametersSchema; + /** Ids of segments to use for this strategy */ + segments?: number[]; } diff --git a/frontend/src/openapi/models/healthOverviewSchema.ts b/frontend/src/openapi/models/healthOverviewSchema.ts index 331e58f6eb..65bb9ebbc1 100644 --- a/frontend/src/openapi/models/healthOverviewSchema.ts +++ b/frontend/src/openapi/models/healthOverviewSchema.ts @@ -3,6 +3,8 @@ * Do not edit manually. * See `gen:api` script in package.json */ +import type { HealthOverviewSchemaDefaultStickiness } from './healthOverviewSchemaDefaultStickiness'; +import type { HealthOverviewSchemaMode } from './healthOverviewSchemaMode'; import type { FeatureSchema } from './featureSchema'; import type { ProjectStatsSchema } from './projectStatsSchema'; @@ -10,6 +12,10 @@ export interface HealthOverviewSchema { version: number; name: string; description?: string | null; + /** A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy */ + defaultStickiness?: HealthOverviewSchemaDefaultStickiness; + /** A mode of the project affecting what actions are possible in this project. During a rollout of project modes this feature can be optional or `null` */ + mode?: HealthOverviewSchemaMode; members?: number; health?: number; environments?: string[]; diff --git a/frontend/src/openapi/models/healthOverviewSchemaDefaultStickiness.ts b/frontend/src/openapi/models/healthOverviewSchemaDefaultStickiness.ts new file mode 100644 index 0000000000..fe2d414ecb --- /dev/null +++ b/frontend/src/openapi/models/healthOverviewSchemaDefaultStickiness.ts @@ -0,0 +1,19 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ + +/** + * A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy + */ +export type HealthOverviewSchemaDefaultStickiness = + typeof HealthOverviewSchemaDefaultStickiness[keyof typeof HealthOverviewSchemaDefaultStickiness]; + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const HealthOverviewSchemaDefaultStickiness = { + default: 'default', + userId: 'userId', + sessionId: 'sessionId', + random: 'random', +} as const; diff --git a/frontend/src/openapi/models/healthOverviewSchemaMode.ts b/frontend/src/openapi/models/healthOverviewSchemaMode.ts new file mode 100644 index 0000000000..7aed36692b --- /dev/null +++ b/frontend/src/openapi/models/healthOverviewSchemaMode.ts @@ -0,0 +1,18 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ + +/** + * A mode of the project affecting what actions are possible in this project. During a rollout of project modes this feature can be optional or `null` + */ +export type HealthOverviewSchemaMode = + typeof HealthOverviewSchemaMode[keyof typeof HealthOverviewSchemaMode]; + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const HealthOverviewSchemaMode = { + open: 'open', + protected: 'protected', + null: null, +} as const; diff --git a/frontend/src/openapi/models/healthReportSchema.ts b/frontend/src/openapi/models/healthReportSchema.ts index 81cb72c331..d8cc23703f 100644 --- a/frontend/src/openapi/models/healthReportSchema.ts +++ b/frontend/src/openapi/models/healthReportSchema.ts @@ -3,6 +3,8 @@ * Do not edit manually. * See `gen:api` script in package.json */ +import type { HealthReportSchemaDefaultStickiness } from './healthReportSchemaDefaultStickiness'; +import type { HealthReportSchemaMode } from './healthReportSchemaMode'; import type { FeatureSchema } from './featureSchema'; import type { ProjectStatsSchema } from './projectStatsSchema'; @@ -10,6 +12,10 @@ export interface HealthReportSchema { version: number; name: string; description?: string | null; + /** A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy */ + defaultStickiness?: HealthReportSchemaDefaultStickiness; + /** A mode of the project affecting what actions are possible in this project. During a rollout of project modes this feature can be optional or `null` */ + mode?: HealthReportSchemaMode; members?: number; health?: number; environments?: string[]; diff --git a/frontend/src/openapi/models/healthReportSchemaDefaultStickiness.ts b/frontend/src/openapi/models/healthReportSchemaDefaultStickiness.ts new file mode 100644 index 0000000000..d23c534db2 --- /dev/null +++ b/frontend/src/openapi/models/healthReportSchemaDefaultStickiness.ts @@ -0,0 +1,19 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ + +/** + * A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy + */ +export type HealthReportSchemaDefaultStickiness = + typeof HealthReportSchemaDefaultStickiness[keyof typeof HealthReportSchemaDefaultStickiness]; + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const HealthReportSchemaDefaultStickiness = { + default: 'default', + userId: 'userId', + sessionId: 'sessionId', + random: 'random', +} as const; diff --git a/frontend/src/openapi/models/healthReportSchemaMode.ts b/frontend/src/openapi/models/healthReportSchemaMode.ts new file mode 100644 index 0000000000..fa3c26ba01 --- /dev/null +++ b/frontend/src/openapi/models/healthReportSchemaMode.ts @@ -0,0 +1,18 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ + +/** + * A mode of the project affecting what actions are possible in this project. During a rollout of project modes this feature can be optional or `null` + */ +export type HealthReportSchemaMode = + typeof HealthReportSchemaMode[keyof typeof HealthReportSchemaMode]; + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const HealthReportSchemaMode = { + open: 'open', + protected: 'protected', + null: null, +} as const; diff --git a/frontend/src/openapi/models/index.ts b/frontend/src/openapi/models/index.ts index 40384c5122..a4608458e9 100644 --- a/frontend/src/openapi/models/index.ts +++ b/frontend/src/openapi/models/index.ts @@ -120,7 +120,11 @@ export * from './groupsSchema'; export * from './healthCheckSchema'; export * from './healthCheckSchemaHealth'; export * from './healthOverviewSchema'; +export * from './healthOverviewSchemaDefaultStickiness'; +export * from './healthOverviewSchemaMode'; export * from './healthReportSchema'; +export * from './healthReportSchemaDefaultStickiness'; +export * from './healthReportSchemaMode'; export * from './idSchema'; export * from './importTogglesSchema'; export * from './importTogglesValidateItemSchema'; @@ -178,6 +182,7 @@ export * from './projectCreatedSchema'; export * from './projectEnvironmentSchema'; export * from './projectOverviewSchema'; export * from './projectSchema'; +export * from './projectSchemaDefaultStickiness'; export * from './projectSchemaMode'; export * from './projectStatsSchema'; export * from './projectUsers'; @@ -223,7 +228,6 @@ export * from './setUiConfigSchemaFrontendSettings'; export * from './sortOrderSchema'; export * from './splashSchema'; export * from './stateSchema'; -export * from './stickinessSchema'; export * from './strategiesSchema'; export * from './strategySchema'; export * from './strategySchemaParametersItem'; diff --git a/frontend/src/openapi/models/projectSchema.ts b/frontend/src/openapi/models/projectSchema.ts index 91e71dbca7..220f95cf81 100644 --- a/frontend/src/openapi/models/projectSchema.ts +++ b/frontend/src/openapi/models/projectSchema.ts @@ -4,6 +4,7 @@ * See `gen:api` script in package.json */ import type { ProjectSchemaMode } from './projectSchemaMode'; +import type { ProjectSchemaDefaultStickiness } from './projectSchemaDefaultStickiness'; /** * A definition of the project used for projects listing purposes @@ -25,6 +26,8 @@ export interface ProjectSchema { updatedAt?: string | null; /** `true` if the project was favorited, otherwise `false`. */ favorite?: boolean; - /** A mode of the project affecting what actions are possible in this project. During a rollout of project modes this feature can be optional or `null` */ + /** A mode of the project affecting what actions are possible in this project */ mode?: ProjectSchemaMode; + /** A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy */ + defaultStickiness?: ProjectSchemaDefaultStickiness; } diff --git a/frontend/src/openapi/models/projectSchemaDefaultStickiness.ts b/frontend/src/openapi/models/projectSchemaDefaultStickiness.ts new file mode 100644 index 0000000000..2a5b5e0eef --- /dev/null +++ b/frontend/src/openapi/models/projectSchemaDefaultStickiness.ts @@ -0,0 +1,19 @@ +/** + * Generated by Orval + * Do not edit manually. + * See `gen:api` script in package.json + */ + +/** + * A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy + */ +export type ProjectSchemaDefaultStickiness = + typeof ProjectSchemaDefaultStickiness[keyof typeof ProjectSchemaDefaultStickiness]; + +// eslint-disable-next-line @typescript-eslint/no-redeclare +export const ProjectSchemaDefaultStickiness = { + default: 'default', + userId: 'userId', + sessionId: 'sessionId', + random: 'random', +} as const; diff --git a/frontend/src/openapi/models/projectSchemaMode.ts b/frontend/src/openapi/models/projectSchemaMode.ts index 6caf0ebe64..c6977498c2 100644 --- a/frontend/src/openapi/models/projectSchemaMode.ts +++ b/frontend/src/openapi/models/projectSchemaMode.ts @@ -5,7 +5,7 @@ */ /** - * A mode of the project affecting what actions are possible in this project. During a rollout of project modes this feature can be optional or `null` + * A mode of the project affecting what actions are possible in this project */ export type ProjectSchemaMode = typeof ProjectSchemaMode[keyof typeof ProjectSchemaMode]; @@ -14,5 +14,4 @@ export type ProjectSchemaMode = export const ProjectSchemaMode = { open: 'open', protected: 'protected', - null: null, } as const; diff --git a/frontend/src/openapi/models/projectStatsSchema.ts b/frontend/src/openapi/models/projectStatsSchema.ts index 8aae1509cf..2a1223975b 100644 --- a/frontend/src/openapi/models/projectStatsSchema.ts +++ b/frontend/src/openapi/models/projectStatsSchema.ts @@ -14,8 +14,6 @@ Stats are divided into current and previous **windows**. export interface ProjectStatsSchema { /** The average time from when a feature was created to when it was enabled in the "production" environment during the current window */ avgTimeToProdCurrentWindow: number; - /** The average time from when a feature was created to when it was enabled in the "production" environment during the previous window */ - avgTimeToProdPastWindow: number; /** The number of feature toggles created during the current window */ createdCurrentWindow: number; /** The number of feature toggles created during the previous window */ diff --git a/frontend/src/openapi/models/stickinessSchema.ts b/frontend/src/openapi/models/stickinessSchema.ts deleted file mode 100644 index 5e917a2e2e..0000000000 --- a/frontend/src/openapi/models/stickinessSchema.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Generated by Orval - * Do not edit manually. - * See `gen:api` script in package.json - */ - -export interface StickinessSchema { - stickiness: string; -}