1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-01 00:08:27 +01:00
unleash.unleash/frontend/src/interfaces/featureToggle.ts

144 lines
2.9 KiB
TypeScript
Raw Normal View History

import type { IFeatureStrategy } from './strategy';
import type { ITag } from './tags';
/**
* @deprecated use FeatureSchema from openapi
*/
export interface IFeatureFlagListItem {
type: string;
name: string;
stale?: boolean;
lastSeenAt?: string;
createdAt: string;
environments: IEnvironments[];
tags?: ITag[];
2022-12-01 13:10:42 +01:00
favorite?: boolean;
}
export interface IEnvironments {
name: string;
enabled: boolean;
variantCount: number;
lastSeenAt?: string | null;
type?: string;
hasStrategies?: boolean;
hasEnabledStrategies?: boolean;
yes?: number;
no?: number;
}
export type ILastSeenEnvironments = Pick<
IEnvironments,
'name' | 'enabled' | 'lastSeenAt' | 'yes' | 'no'
>;
export type Lifecycle = {
stage: 'initial' | 'pre-live' | 'live' | 'completed' | 'archived';
status?: string;
enteredStageAt: string;
};
export type Collaborator = {
id: number;
name: string;
imageUrl: string;
};
export type CollaboratorData = {
users: Collaborator[];
};
/**
* @deprecated use FeatureSchema from openapi
*/
export interface IFeatureToggle {
stale: boolean;
archived: boolean;
enabled?: boolean;
createdAt: string;
lastSeenAt?: string;
description?: string;
environments: IFeatureEnvironment[];
name: string;
favorite: boolean;
project: string;
type: string;
variants: IFeatureVariant[];
impressionData: boolean;
strategies?: IFeatureStrategy[];
dependencies: Array<IDependency>;
lifecycle?: Lifecycle;
children: Array<string>;
createdBy?: {
Wip: split out avatar group; use same tooltip for all avatars (#7681) Extracts the Avatar Group component into a `common` component and adds a standard tooltip to all avatars. Relates to linear issue 1-2606 This is a suggestion / proof of concept for how we can solve it. While I think we can merge this as is, I'd also be happy to take any discussions on other ways to approach it etc. ## Why are these changes made together? Because extracting the avatar group without adding the new tooltip data made the existing tooltip misbehave (it'd show up in the top left of the screen, not synced to the avatar in any way). I probably could have (and still can if you think it's prudent) split it out such that the avatar gets a standardized tooltip first (and disable it for the group card avatars), and split out the avatars in a follow-up. Happy to do that if you think it's better. ## What does this mean? It used to be that we had no consistent way of dealing with avatars and tooltips. Some places had them, some places didn't. This change makes it so that all avatars that we can show tooltips for will get the same tooltip. Previously, we had at least 4 different ways of dealing with tooltips: - The HTML tooltip (that would be standardized with this PR) in the project flags table ![image](https://github.com/user-attachments/assets/91098d31-a5e3-4091-9125-332fe5d106fd) - The "title" that you'd get on your user avatar ![image](https://github.com/user-attachments/assets/39062b61-db8c-4bd5-9fa3-3ecc9bc192ee) - The group card list tooltip ![image](https://github.com/user-attachments/assets/0d4a696a-e944-446c-8bff-4dcec02d8afb) - And sometimes you'd get nothing at all ![image](https://github.com/user-attachments/assets/8975afaf-9ca1-4eb6-b443-9ab94b52bbd8) with this change, we'll always show the same kind of tooltip if we can: ![image](https://github.com/user-attachments/assets/974c592c-c844-4b65-8a55-05e84d3df130) ## What goes in the tooltip? We use the `UserAvatar` component for a fair few different things and I didn't want to extract separate components for all the different use cases. Instead, I wanted to get an overview over what we use it for and what is relevant info to show. I found all the places we used it and tried to form an opinion. This tooltip will work with a user's email, name, username, and id. If there is no user (such as for empty avatars and avatars displaying only "+n" for remaining members), we show no tooltip. Following the example set by the group card avatars, we'll try to use email or username (in that order) as the main bit of text. If the user has an email or a username and also a name, the name will be used as secondary text. If the user does not have an email or username, but has a name, we'll use the name as the main text. If the user does not have an email, a username, or a name, we'll try to show "User ID: N" if they have an id. If they do not have a username, a name, an email, or an ID, we bail out and show nothing. ## Why can you disable the tooltip? In some cases, you might want to disable the tooltip because you have more information to feed into it. An example of that is in the project flags table, where we want to show more information in cases where the user is 'unknown': ![image](https://github.com/user-attachments/assets/758b4e86-e934-47e3-91ce-ce900f76bc54) ## Additional fixes This PR also adds a few lines of CSS to fix a minor avatar layout bug. Before: ![image](https://github.com/user-attachments/assets/0150efbf-c51a-40bb-898f-7ddd3565ce21) After: ![image](https://github.com/user-attachments/assets/f337cf68-c572-4610-b1de-a27749325da8)
2024-08-01 10:45:24 +02:00
id: number;
name: string;
imageUrl: string;
};
collaborators?: CollaboratorData;
}
export interface IDependency {
feature: string;
2024-03-29 19:28:49 +01:00
enabled?: boolean;
variants?: string[];
}
export interface IFeatureEnvironment {
2021-10-15 12:49:14 +02:00
type: string;
name: string;
enabled: boolean;
Feat/environment strategies (#339) * feat: strategies list * feat: dnd * fix: resolve reference issues * feat: configure strategy wip * feat: rearrange list * feat: add debounce and execution plan * feat: add separator * feat: update strategy * fix: feature strategy accordion key * fix: localize parameter update logic * feat: ts conversion * fix: perf issues * feat: production guard * fix: clean up environment list * fix: implement markup hooks for environment list * feat: wip constraints * fix: handle nested data structure reference issue * fix: clone deep on child props * fix: remove constraints check * fix: revert to strategies length * fix: refactor useFeature * feat: cache revalidation * fix: set correct starting tab * fix: reset params on adding new strategy * fix: refactor to use useSWR instead of local cache * fix: check dirty directly from new params * fix: dialogue ts * fix: Clean-up typescript warnings * fix: some more typescript nits * feat: strategy execution * feat: strategy execution for environment * fix: refactor execution separator * fix: remove unused property * fix: add header * fix: 0 value for rollout * fix: update snapshots * fix: remove empty deps * fix: use constant for env type * fix: use default for useFeatureStrategy * fix: update snapshot * Update src/component/feature/FeatureView2/FeatureStrategies/FeatureStrategiesEnvironments/FeatureStrategiesEnvironmentList/useDeleteStrategyMarkup.tsx Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai> * Update src/component/feature/FeatureView2/FeatureStrategies/FeatureStrategyExecution/FeatureStrategyExecution.tsx Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai> * Update src/component/feature/strategy/EditStrategyModal/general-strategy.jsx Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai> Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai> Co-authored-by: UnleashTeam <79193084+UnleashTeam@users.noreply.github.com>
2021-09-27 13:35:32 +02:00
strategies: IFeatureStrategy[];
variants?: IFeatureVariant[];
lastSeenAt?: string;
yes?: number;
no?: number;
}
export interface IFeatureEnvironmentWithCrEnabled extends IFeatureEnvironment {
crEnabled?: boolean;
}
export interface IFeatureVariant {
name: string;
stickiness: string;
weight: number;
weightType: 'fix' | 'variable';
overrides?: IOverride[];
payload?: IPayload;
}
export interface IOverride {
contextName: string;
values: string[];
}
export interface IPayload {
type: string;
value: string;
}
export interface IFeatureEnvironmentMetrics {
environment: string;
timestamp: string;
yes: number;
no: number;
}
export interface IFeatureMetrics {
refactor: fix misc TS errors (#729) * refactor: update test deps * refactor: remove unused ts-expect-error annotations * refactor: add missing arg and return types * refactor: the loading prop is optional * refactor: add missing arg and return types * reafactor: fix value arg type * refactor: fix missing array type * refactor: the parameters field is an array * refactor: use undefined instead of null in state * refactor: add missing params type * refactor: add missing children prop * refactor: add missing array type * refactor: add missing React imports * refactor: use correct IProjectEnvironment type * refactor: type errors as unknown * refactor: the index prop is required * refactor: fix date prop type * refactor: fix tooltip placement prop type * refactor: fix environments state type * refactor: add missing arg types * refactor: add guard for undefined field * refactor: fix ChangePassword prop types * refactor: fix MUI import paths * refactor: add missing arg type * refactor: fix showDialog prop type * refactor: remove unused openUpdateDialog prop * refactor: add missing non-null assertion * refactor: remove unused types prop * refactor: stricten API error handler types * refactor: add missing undefined check * refactor: add missing IProject id field * refactor: fix ConditionallyRender condition prop types * refactor: remove unused args * refactor: add AddVariant prop types * refactor: add types to UIContext * refactor: fix event arg type * refactor: add missing default impressionData field * refactor: fix handleDeleteEnvironment prop args * refactor: fix IFeatureMetrics field requirements * refactor: add missing element types to ConditionallyRender * refactor: remove unused ProjectAccess projectId prop * refactor: add missing undefined check * refactor: fix getCreateTogglePath arg type * refactor: add missing IStrategyPayload import * refactor: remove unused user arg * refactor: add missing event arg type * refactor: add missing style object types * refactor: improve userApiErrors prop type * refactor: the Dialogue onClose prop is optional * refactor: fix the AddonEvents setEventValue prop type
2022-02-25 10:55:39 +01:00
version?: number;
maturity?: string;
lastHourUsage: IFeatureEnvironmentMetrics[];
seenApplications: string[];
}
feat: add new feature metrics page (#716) * refactor: ensure that [hidden] overrides other display styles * refactor: use numeric font weights * refactor: remove unnecessary Jest mock * refactor: add a fullWidth prop to GeneralSelect * refactor: remove unnecessary label id prop * refactor: the showActive prop is optional * refactor: add hooks for managing query string state * refactor: add a hour/minute timestamp formatter * refactor: add labels to button icons * feat: add new feature metrics page * refactor: remove prev feature metrics page * refactor: use new metric boxes on overview page * refactor: lazy-load the new metrics page * refactor: fix type error when formatting unknown error * refactor: extract interfaces for props * refactor: destructure all props * refactor: expand arg names * refactor: reorg component dirs and files * refactor: improve chart element label * refactor: hide chart dots until hover * refactor: add section titles to environments/applications * refactor: simplify FeatureMetricsHours types * refactor: sort chart tooltip items * refactor: add more chart labels * refactor: always show a dot in single point charts * refactor: improve chart tooltip styles * refactor: adjut metric page spacing * refactor: decrease legend box size * refactor: move date fmt fn inline * refactor: improve chart legend styles * refactor: increase Cypress timeouts * refactor: sort environment and application chips * refactor: format files * refactor: use stable lists of apps and envs * refactor: fix FeatureMetrics dir name * refactor: avoid ScrollToTop on query string change * refactor: use ConditionallyRender instead of inline condition * refactor: use makeStyles instead of styled API
2022-02-21 13:47:54 +01:00
export interface IFeatureMetricsRaw {
featureName: string;
appName: string;
environment: string;
timestamp: string;
yes: number;
no: number;
variants?: Record<string, number>;
feat: add new feature metrics page (#716) * refactor: ensure that [hidden] overrides other display styles * refactor: use numeric font weights * refactor: remove unnecessary Jest mock * refactor: add a fullWidth prop to GeneralSelect * refactor: remove unnecessary label id prop * refactor: the showActive prop is optional * refactor: add hooks for managing query string state * refactor: add a hour/minute timestamp formatter * refactor: add labels to button icons * feat: add new feature metrics page * refactor: remove prev feature metrics page * refactor: use new metric boxes on overview page * refactor: lazy-load the new metrics page * refactor: fix type error when formatting unknown error * refactor: extract interfaces for props * refactor: destructure all props * refactor: expand arg names * refactor: reorg component dirs and files * refactor: improve chart element label * refactor: hide chart dots until hover * refactor: add section titles to environments/applications * refactor: simplify FeatureMetricsHours types * refactor: sort chart tooltip items * refactor: add more chart labels * refactor: always show a dot in single point charts * refactor: improve chart tooltip styles * refactor: adjut metric page spacing * refactor: decrease legend box size * refactor: move date fmt fn inline * refactor: improve chart legend styles * refactor: increase Cypress timeouts * refactor: sort environment and application chips * refactor: format files * refactor: use stable lists of apps and envs * refactor: fix FeatureMetrics dir name * refactor: avoid ScrollToTop on query string change * refactor: use ConditionallyRender instead of inline condition * refactor: use makeStyles instead of styled API
2022-02-21 13:47:54 +01:00
}