1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-26 13:48:33 +02:00

chore(unl-204): remove uses of toast text and confetti (#8941)

As of PR #8935, we no longer support both text and title, and confetti
has been removed.

This PR:
- removes `confetti` from the toast interface
- merges `text` and `title` into `text` and updates its uses across the
codebase.
- readjusts the text where necessary.
This commit is contained in:
Thomas Heartman 2024-12-10 14:38:04 +01:00 committed by GitHub
parent 2f7beceb21
commit b2c58102dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
135 changed files with 192 additions and 293 deletions

View File

@ -22,7 +22,7 @@ export const ApiTokenDocs = () => {
copy(url);
setToastData({
type: 'success',
title: 'Copied to clipboard',
text: 'Copied to clipboard',
});
};

View File

@ -14,12 +14,12 @@ export const UserToken = ({ token }: IUserTokenProps) => {
if (copy(token)) {
setToastData({
type: 'success',
title: 'Token copied to clipboard',
text: 'Token copied to clipboard',
});
} else
setToastData({
type: 'error',
title: 'Could not copy token',
text: 'Could not copy token',
});
};

View File

@ -59,7 +59,7 @@ export const GoogleAuth = () => {
try {
await updateSettings(removeEmptyStringFields(data));
setToastData({
title: 'Settings stored',
text: 'Settings stored',
type: 'success',
});
} catch (error: unknown) {

View File

@ -97,7 +97,7 @@ export const OidcAuth = () => {
try {
await updateSettings(removeEmptyStringFields(data));
setToastData({
title: 'Settings stored',
text: 'Settings stored',
type: 'success',
});
} catch (error: unknown) {

View File

@ -50,8 +50,7 @@ export const PasswordAuth = () => {
await updateSettings(settings);
refetch();
setToastData({
title: 'Successfully saved',
text: 'Password authentication settings stored.',
text: 'Password authentication settings stored',
autoHideDuration: 4000,
type: 'success',
show: true,

View File

@ -88,7 +88,7 @@ export const SamlAuth = () => {
try {
await updateSettings(removeEmptyStringFields(data));
setToastData({
title: 'Settings stored',
text: 'Settings stored',
type: 'success',
});
} catch (error: unknown) {

View File

@ -58,7 +58,7 @@ export const ScimSettings = () => {
}
setToastData({
title: 'Settings stored',
text: 'Settings stored',
type: 'success',
});
await refetch();

View File

@ -101,7 +101,7 @@ export const BannerModal = ({ banner, open, setOpen }: IBannerModalProps) => {
await addBanner(payload);
}
setToastData({
title: `Banner ${editing ? 'updated' : 'added'} successfully`,
text: `Banner ${editing ? 'updated' : 'added'} successfully`,
type: 'success',
});
refetch();

View File

@ -42,7 +42,7 @@ export const BannersTable = () => {
try {
await toggleBanner(banner.id, enabled);
setToastData({
title: `"${banner.message}" has been ${
text: `"${banner.message}" has been ${
enabled ? 'enabled' : 'disabled'
}`,
type: 'success',
@ -57,7 +57,7 @@ export const BannersTable = () => {
try {
await removeBanner(banner.id);
setToastData({
title: `"${banner.message}" has been deleted`,
text: `"${banner.message}" has been deleted`,
type: 'success',
});
refetch();

View File

@ -25,7 +25,7 @@ export const CorsForm = ({ frontendApiOrigins }: ICorsFormProps) => {
event.preventDefault();
await setFrontendSettings(split);
setValue(formatInputValue(split));
setToastData({ title: 'Settings saved', type: 'success' });
setToastData({ text: 'Settings saved', type: 'success' });
} catch (error) {
setToastApiError(formatUnknownError(error));
}

View File

@ -48,9 +48,7 @@ export const CreateGroup = () => {
const group = await createGroup(payload);
navigate(`/admin/groups/${group.id}`);
setToastData({
title: 'Group created successfully',
text: 'Now you can start using your group.',
confetti: true,
text: 'Group created successfully',
type: 'success',
});
} catch (error: unknown) {

View File

@ -90,7 +90,7 @@ export const EditGroup = ({
refetchGroups();
navigate(GO_BACK);
setToastData({
title: 'Group updated successfully',
text: 'Group updated successfully',
type: 'success',
});
} catch (error: unknown) {

View File

@ -77,7 +77,7 @@ export const EditGroupUsers: FC<IEditGroupUsersProps> = ({
refetchGroups();
setOpen(false);
setToastData({
title: 'Group users saved successfully',
text: 'Group users saved successfully',
type: 'success',
});
} catch (error: unknown) {

View File

@ -38,7 +38,7 @@ export const RemoveGroupUser: FC<IRemoveGroupUserProps> = ({
refetchGroup();
setOpen(false);
setToastData({
title: 'User removed from group successfully',
text: 'User removed from group successfully',
type: 'success',
});
} catch (error: unknown) {

View File

@ -31,7 +31,7 @@ export const RemoveGroup: FC<IRemoveGroupProps> = ({
setOpen(false);
navigate('/admin/groups');
setToastData({
title: 'Group removed successfully',
text: 'Group removed successfully',
type: 'success',
});
} catch (error: unknown) {

View File

@ -58,7 +58,7 @@ export const License = () => {
try {
await updateLicenseKey(token);
setToastData({
title: 'License key updated',
text: 'License key updated',
type: 'success',
});
refetchLicense();

View File

@ -45,7 +45,7 @@ export const MaintenanceToggle = () => {
const updateEnabled = async () => {
setToastData({
type: 'success',
title: `Maintenance mode has been successfully ${
text: `Maintenance mode has been successfully ${
enabled ? 'disabled' : 'enabled'
}`,
});

View File

@ -96,7 +96,7 @@ export const RoleModal = ({
await addRole(payload);
}
setToastData({
title: `Role ${editing ? 'updated' : 'added'} successfully`,
text: `Role ${editing ? 'updated' : 'added'} successfully`,
type: 'success',
});
refetch();

View File

@ -52,7 +52,7 @@ export const RolesTable = ({
try {
await removeRole(role.id);
setToastData({
title: `${role.name} has been deleted`,
text: `${role.name} has been deleted`,
type: 'success',
});
refetch();

View File

@ -196,7 +196,7 @@ export const ServiceAccountModal = ({
}
}
setToastData({
title: `Service account ${
text: `Service account ${
editing ? 'updated' : 'added'
} successfully`,
type: 'success',

View File

@ -127,7 +127,7 @@ export const ServiceAccountTokens = ({
setNewToken(token);
setTokenOpen(true);
setToastData({
title: 'Token created successfully',
text: 'Token created successfully',
type: 'success',
});
} catch (error: unknown) {
@ -146,7 +146,7 @@ export const ServiceAccountTokens = ({
refetchTokens();
setDeleteOpen(false);
setToastData({
title: 'Token deleted successfully',
text: 'Token deleted successfully',
type: 'success',
});
} catch (error: unknown) {

View File

@ -48,7 +48,7 @@ export const ServiceAccountsTable = () => {
try {
await removeServiceAccount(serviceAccount.id);
setToastData({
title: `${serviceAccount.name} has been deleted`,
text: `${serviceAccount.name} has been deleted`,
type: 'success',
});
refetch();

View File

@ -60,7 +60,7 @@ const EditUser = () => {
refetch();
navigate('/admin/users');
setToastData({
title: 'User information updated',
text: 'User information updated',
type: 'success',
});
} catch (error: unknown) {

View File

@ -71,7 +71,7 @@ export const InactiveUsersList = () => {
try {
await deleteInactiveUsers(inactiveUsers.map((i) => i.id));
setToastData({
title: `Inactive users has been deleted`,
text: `Inactive users has been deleted`,
type: 'success',
});
setShowDelInactiveDialog(false);
@ -84,7 +84,7 @@ export const InactiveUsersList = () => {
try {
await removeUser(userId);
setToastData({
title: `User has been deleted`,
text: `User has been deleted`,
type: 'success',
});
refetchInactiveUsers();

View File

@ -51,7 +51,7 @@ export const LinkField: FC<ILinkFieldProps> = ({
const setError = () =>
setToastData({
type: 'error',
title: errorTitle,
text: errorTitle,
});
const handleCopy = () => {
@ -61,7 +61,7 @@ export const LinkField: FC<ILinkFieldProps> = ({
.then(() => {
setToastData({
type: 'success',
title: successTitle,
text: successTitle,
});
onCopy?.();
})

View File

@ -62,8 +62,7 @@ const ChangePassword = ({
setData({});
closeDialog();
setToastData({
title: 'Password changed successfully',
text: 'The user can now sign in using the new password.',
text: 'Password changed successfully',
type: 'success',
});
} catch (error: unknown) {

View File

@ -112,7 +112,7 @@ const UsersList = () => {
try {
await removeUser(user.id);
setToastData({
title: `${user.name} has been deleted`,
text: `${user.name} has been deleted`,
type: 'success',
});
refetch();

View File

@ -93,8 +93,7 @@ export const Application = () => {
try {
await deleteApplication(appName);
setToastData({
title: 'Deleted Successfully',
text: 'Application deleted successfully',
text: 'Deleted Successfully',
type: 'success',
});
navigate('/applications');

View File

@ -40,8 +40,7 @@ export const ApplicationUpdate = ({ application }: IApplicationUpdateProps) => {
refetchApplication();
setToastData({
type: 'success',
title: 'Updated Successfully',
text: `${field} successfully updated`,
text: 'Updated Successfully',
});
} catch (error: unknown) {
setToastApiError(formatUnknownError(error));

View File

@ -103,7 +103,7 @@ test('should show confirm dialog when reviving flag', async () => {
});
fireEvent.click(reviveFlagsButton);
await screen.findByText("And we're back!");
await screen.findByText('Feature flags revived');
});
test('should show confirm dialog when batch reviving flag', async () => {
@ -134,7 +134,7 @@ test('should show confirm dialog when batch reviving flag', async () => {
});
fireEvent.click(reviveTogglesButton);
await screen.findByText("And we're back!");
await screen.findByText('Feature flags revived');
});
test('should show info box when disableAllEnvsOnRevive flag is on', async () => {

View File

@ -49,10 +49,7 @@ export const ArchivedFeatureDeleteConfirm = ({
await refetch();
setToastData({
type: 'success',
title: `Feature ${singularOrPluralFlags} deleted`,
text: `You have successfully deleted the following feature ${singularOrPluralFlags}: ${deletedFeatures.join(
', ',
)}.`,
text: `Feature ${singularOrPluralFlags} deleted`,
});
} catch (error: unknown) {
setToastApiError(formatUnknownError(error));

View File

@ -39,8 +39,7 @@ export const ArchivedFeatureReviveConfirm = ({
await refetch();
setToastData({
type: 'success',
title: "And we're back!",
text: 'The feature flags have been revived.',
text: 'Feature flags revived',
});
} catch (error: unknown) {
setToastApiError(formatUnknownError(error));

View File

@ -98,7 +98,7 @@ export const ChangeActions: FC<{
change.id,
);
setToastData({
title: 'Change discarded from change request draft.',
text: 'Change discarded from change request draft.',
type: 'success',
});
onRefetch?.();

View File

@ -125,7 +125,7 @@ export const EditChange = ({
});
onSubmit();
setToastData({
title: 'Change updated',
text: 'Change updated',
type: 'success',
});
} catch (error: unknown) {

View File

@ -136,7 +136,6 @@ export const ChangeRequestOverview: FC = () => {
refetchActionableChangeRequests();
setToastData({
type: 'success',
title: 'Success',
text: 'Changes applied',
});
} catch (error: unknown) {
@ -159,7 +158,6 @@ export const ChangeRequestOverview: FC = () => {
refetchActionableChangeRequests();
setToastData({
type: 'success',
title: 'Success',
text: 'Changes scheduled',
});
} catch (error: unknown) {
@ -177,7 +175,6 @@ export const ChangeRequestOverview: FC = () => {
await refetchChangeRequest();
setToastData({
type: 'success',
title: 'Success',
text: 'Comment added',
});
} catch (error: unknown) {
@ -199,7 +196,6 @@ export const ChangeRequestOverview: FC = () => {
refetchActionableChangeRequests();
setToastData({
type: 'success',
title: 'Success',
text: 'Changes cancelled',
});
} catch (error: unknown) {
@ -221,7 +217,6 @@ export const ChangeRequestOverview: FC = () => {
setToastData({
type: 'success',
title: 'Success',
text: 'Changes rejected',
});
refetchChangeRequestOpen();
@ -244,7 +239,6 @@ export const ChangeRequestOverview: FC = () => {
refetchChangeRequestOpen();
setToastData({
type: 'success',
title: 'Success',
text: 'Changes approved',
});
} catch (error: unknown) {

View File

@ -49,7 +49,7 @@ export const ChangeRequestTitle: FC<{
);
setToastData({
type: 'success',
title: 'Change request title updated!',
text: 'Change request title updated!',
});
} catch (error: unknown) {
setToastApiError(formatUnknownError(error));

View File

@ -44,7 +44,7 @@ export const CommandBarFeedback = ({ onSubmit }: ICommandBarFeedbackProps) => {
});
onSubmit();
setToastData({
title: 'Feedback sent',
text: 'Feedback sent',
type: 'success',
});
};

View File

@ -23,7 +23,7 @@ export const CopyApiTokenButton = ({
if (copy(value)) {
setToastData({
type: 'success',
title: `Token copied to clipboard`,
text: 'Token copied to clipboard',
});
if (track && typeof track === 'function') {

View File

@ -34,7 +34,7 @@ export const RemoveApiTokenButton = ({
setToastData({
type: 'success',
title: 'API token removed',
text: 'API token removed',
});
} catch (error: unknown) {
setToastApiError(formatUnknownError(error));

View File

@ -238,11 +238,8 @@ const useArchiveAction = ({
);
refetchChangeRequests();
setToastData({
text: isBulkArchive
? 'Your archive feature flags changes have been added to change request'
: 'Your archive feature flag change has been added to change request',
type: 'success',
title: isBulkArchive
text: isBulkArchive
? 'Changes added to a draft'
: 'Change added to a draft',
});
@ -251,18 +248,16 @@ const useArchiveAction = ({
const archiveToggle = async () => {
await archiveFeatureToggle(projectId, featureIds[0]);
setToastData({
text: 'Your feature flag has been archived',
type: 'success',
title: 'Feature archived',
text: 'Feature flag archived',
});
};
const archiveToggles = async () => {
await archiveFeatures(projectId, featureIds);
setToastData({
text: 'Selected feature flags have been archived',
type: 'success',
title: 'Features archived',
text: 'Feature flags archived',
});
};

View File

@ -50,14 +50,12 @@ export const FeatureStaleDialog = ({
if (isStale) {
setToastData({
type: 'success',
title: "And we're back!",
text: 'The flag is no longer marked as stale.',
text: 'The flag is no longer marked as stale',
});
} else {
setToastData({
type: 'success',
title: 'A job well done.',
text: 'The flag has been marked as stale.',
text: 'The flag has been marked as stale',
});
}
};

View File

@ -259,16 +259,14 @@ const FormTemplate: React.FC<ICreateProps> = ({
if (formatApiCode !== undefined) {
if (copy(formatApiCode())) {
setToastData({
title: 'Successfully copied the command',
text: 'The command should now be automatically copied to your clipboard',
text: 'Command copied',
autoHideDuration: 6000,
type: 'success',
show: true,
});
} else {
setToastData({
title: 'Could not copy the command',
text: 'Sorry, but we could not copy the command.',
text: 'Could not copy the command',
autoHideDuration: 6000,
type: 'error',
show: true,

View File

@ -7,7 +7,7 @@ import UIContext from 'contexts/UIContext';
import Close from '@mui/icons-material/Close';
import type { IToast } from 'interfaces/toast';
const Toast = ({ title, type }: IToast) => {
const Toast = ({ text, type }: IToast) => {
const { setToast } = useContext(UIContext);
const { classes: styles } = useStyles();
@ -20,7 +20,7 @@ const Toast = ({ title, type }: IToast) => {
<div className={classnames(styles.container, 'dropdown-outline')}>
<CheckMarkBadge type={type} className={styles.checkMark} />
<h3 className={styles.headerStyles}>{title}</h3>
<h3 className={styles.headerStyles}>{text}</h3>
<Tooltip title='Close' arrow>
<IconButton

View File

@ -142,8 +142,7 @@ const ContextList: VFC = () => {
refetchUnleashContext();
setToastData({
type: 'success',
title: 'Successfully deleted context',
text: 'Your context is now deleted',
text: 'Context field deleted',
});
} catch (error) {
setToastApiError(formatUnknownError(error));

View File

@ -51,8 +51,7 @@ export const CreateUnleashContext = ({
await createContext(payload);
refetchUnleashContext();
setToastData({
title: 'Context created',
confetti: true,
text: 'Context field created',
type: 'success',
});
onSubmit();

View File

@ -63,7 +63,7 @@ export const EditContext = () => {
refetch();
navigate('/context');
setToastData({
title: 'Context information updated',
text: 'Context information updated',
type: 'success',
});
} catch (e: unknown) {

View File

@ -43,9 +43,8 @@ const CreateEnvironment = () => {
await createEnvironment(payload);
refetch();
setToastData({
title: 'Environment created',
text: 'Environment created',
type: 'success',
confetti: true,
});
navigate('/environments');
} catch (error: unknown) {

View File

@ -49,7 +49,7 @@ const EditEnvironment = () => {
navigate('/environments');
setToastData({
type: 'success',
title: 'Successfully updated environment.',
text: 'Successfully updated environment.',
});
} catch (error: unknown) {
setToastApiError(formatUnknownError(error));

View File

@ -43,8 +43,7 @@ export const EnvironmentActionCell = ({
refetchPermissions();
setToastData({
type: 'success',
title: 'Environment deleted',
text: `You have successfully deleted the ${environment.name} environment.`,
text: `Environment deleted`,
});
} catch (error: unknown) {
setToastApiError(formatUnknownError(error));
@ -60,13 +59,13 @@ export const EnvironmentActionCell = ({
await toggleEnvironmentOff(environment.name);
setToastData({
type: 'success',
title: 'Environment deprecated successfully',
text: 'Environment deprecated',
});
} else {
await toggleEnvironmentOn(environment.name);
setToastData({
type: 'success',
title: 'Environment undeprecated successfully',
text: 'Environment undeprecated',
});
}
} catch (error: unknown) {
@ -89,8 +88,7 @@ export const EnvironmentActionCell = ({
} else {
setToastData({
type: 'error',
title: 'Environment limit reached',
text: `You have reached the maximum number of environments (${environmentLimit}). Please reach out if you need more.`,
text: `Environment limit (${environmentLimit}) reached`,
});
}
}}

View File

@ -184,7 +184,7 @@ export const EnvironmentCloneModal = ({
newToken(token);
}
setToastData({
title: 'Environment successfully cloned!',
text: 'Environment cloned',
type: 'success',
});
refetchEnvironments();

View File

@ -63,12 +63,8 @@ export const useManageDependency = (
}
void refetchChangeRequests();
setToastData({
text:
actionType === 'addDependency'
? `${featureId} will depend on ${parent}`
: `${featureId} dependency will be removed`,
type: 'success',
title: 'Change added to a draft',
text: 'Change added to draft',
});
};
@ -95,7 +91,7 @@ export const useManageDependency = (
eventType: 'dependency removed',
},
});
setToastData({ title: 'Dependency removed', type: 'success' });
setToastData({ text: 'Dependency removed', type: 'success' });
} else {
await addDependency(featureId, {
feature: parent,
@ -110,7 +106,7 @@ export const useManageDependency = (
eventType: 'dependency added',
},
});
setToastData({ title: 'Dependency added', type: 'success' });
setToastData({ text: 'Dependency added', type: 'success' });
}
} catch (error) {
setToastApiError(formatUnknownError(error));

View File

@ -54,7 +54,7 @@ const EditFeature = () => {
await patchFeatureFlag(project, featureId, patch);
navigate(`/projects/${project}/features/${name}`);
setToastData({
title: 'Flag updated successfully',
text: 'Flag updated',
type: 'success',
});
} catch (error: unknown) {

View File

@ -150,9 +150,8 @@ export const FeatureStrategyCreate = () => {
);
setToastData({
title: 'Strategy created',
text: 'Strategy created',
type: 'success',
confetti: true,
});
};
@ -164,9 +163,8 @@ export const FeatureStrategyCreate = () => {
});
// FIXME: segments in change requests
setToastData({
title: 'Strategy added to draft',
text: 'Strategy added to draft',
type: 'success',
confetti: true,
});
refetchChangeRequests();
};

View File

@ -209,9 +209,8 @@ export const FeatureStrategyEdit = () => {
await refetchSavedStrategySegments();
setToastData({
title: 'Strategy updated',
text: 'Strategy updated',
type: 'success',
confetti: true,
});
};
@ -223,9 +222,8 @@ export const FeatureStrategyEdit = () => {
});
// FIXME: segments in change requests
setToastData({
title: 'Change added to draft',
text: 'Change added to draft',
type: 'success',
confetti: true,
});
refetchChangeRequests();
};

View File

@ -78,10 +78,7 @@ export const FeatureStrategyEmpty = ({
refetchFeatureImmutable();
setToastData({
title: multiple ? 'Strategies created' : 'Strategy created',
text: multiple
? 'Successfully copied from another environment'
: 'Successfully created strategy',
text: multiple ? 'Strategies created' : 'Strategy created',
type: 'success',
});
};

View File

@ -75,7 +75,7 @@ export const FeatureReleasePlanCard = ({
);
setToastData({
type: 'success',
title: 'Release plan added',
text: 'Release plan added',
});
refetch();
} catch (error: unknown) {

View File

@ -73,9 +73,8 @@ export const BulkDisableDialog = ({
);
refetchChangeRequests();
setToastData({
text: 'Your disabled feature flags changes have been added to change request',
type: 'success',
title: 'Changes added to a draft',
text: 'Changes added to draft',
});
} else {
await bulkToggleFeaturesEnvironmentOff(
@ -84,9 +83,8 @@ export const BulkDisableDialog = ({
selected,
);
setToastData({
text: 'Your feature flags have been disabled',
type: 'success',
title: 'Features disabled',
text: 'Feature flags disabled',
});
}
onClose();

View File

@ -73,9 +73,8 @@ export const BulkEnableDialog = ({
);
refetchChangeRequests();
setToastData({
text: 'Your enable feature flags changes have been added to change request',
type: 'success',
title: 'Changes added to a draft',
text: 'Changes added to draft',
});
} else {
await bulkToggleFeaturesEnvironmentOn(
@ -84,9 +83,8 @@ export const BulkEnableDialog = ({
selected,
);
setToastData({
text: 'Your feature flags have been enabled',
type: 'success',
title: 'Features enabled',
text: 'Feature flags enabled',
});
}

View File

@ -111,7 +111,7 @@ const EnvironmentAccordionBody = ({
);
refetchFeature();
setToastData({
title: 'Order of strategies updated',
text: 'Order of strategies updated',
type: 'success',
});
} catch (error: unknown) {
@ -129,9 +129,8 @@ const EnvironmentAccordionBody = ({
});
setToastData({
title: 'Strategy execution order added to draft',
text: 'Strategy execution order added to draft',
type: 'success',
confetti: true,
});
refetchChangeRequests();
};

View File

@ -86,8 +86,7 @@ export const CopyStrategyIconMenu: VFC<ICopyStrategyIconMenuProps> = ({
refetchFeature();
refetchFeatureImmutable();
setToastData({
title: `Strategy created`,
text: `Successfully copied a strategy to ${targetEnvironment}`,
text: `Strategy copied to ${targetEnvironment}`,
type: 'success',
});
} catch (error) {

View File

@ -194,7 +194,7 @@ const useOnRemove = ({
strategyId,
);
setToastData({
title: 'Strategy deleted',
text: 'Strategy deleted',
type: 'success',
});
refetchFeature();
@ -227,7 +227,7 @@ const useOnSuggestRemove = ({
},
});
setToastData({
title: 'Changes added to the draft!',
text: 'Changes added to draft',
type: 'success',
});
await refetchChangeRequests();

View File

@ -24,7 +24,7 @@ export const useEnableDisable = ({
!enabled,
);
setToastData({
title: `Strategy ${enabled ? 'enabled' : 'disabled'}`,
text: `Strategy ${enabled ? 'enabled' : 'disabled'}`,
type: 'success',
});

View File

@ -25,7 +25,7 @@ export const useSuggestEnableDisable = ({
},
});
setToastData({
title: 'Changes added to the draft!',
text: 'Changes added to draft',
type: 'success',
});
await refetchChangeRequests();

View File

@ -69,9 +69,8 @@ const useDeleteDependency = (project: string, featureId: string) => {
},
});
setToastData({
text: `${featureId} dependency will be removed`,
type: 'success',
title: 'Change added to a draft',
text: 'Change added to draft',
});
await refetchChangeRequests();
} else {
@ -81,7 +80,7 @@ const useDeleteDependency = (project: string, featureId: string) => {
eventType: 'dependency removed',
},
});
setToastData({ title: 'Dependency removed', type: 'success' });
setToastData({ text: 'Dependency removed', type: 'success' });
await refetchFeature();
}
} catch (error) {

View File

@ -255,7 +255,7 @@ test('delete dependency with change request', async () => {
const deleteButton = await screen.findByText('Delete');
fireEvent.click(deleteButton);
await screen.findByText('Change added to a draft');
await screen.findByText('Change added to draft');
});
test('edit dependency', async () => {

View File

@ -60,9 +60,8 @@ const useDeleteDependency = (project: string, featureId: string) => {
},
});
setToastData({
text: `${featureId} dependency will be removed`,
type: 'success',
title: 'Change added to a draft',
text: 'Change added to draft',
});
await refetchChangeRequests();
} else {
@ -72,7 +71,7 @@ const useDeleteDependency = (project: string, featureId: string) => {
eventType: 'dependency removed',
},
});
setToastData({ title: 'Dependency removed', type: 'success' });
setToastData({ text: 'Dependency removed', type: 'success' });
await refetchFeature();
}
} catch (error) {

View File

@ -92,8 +92,7 @@ export const TagRow = ({ feature }: IFeatureOverviewSidePanelTagsProps) => {
refetch();
setToastData({
type: 'success',
title: 'Tag removed',
text: 'Successfully removed tag',
text: 'Tag removed',
});
} catch (error: unknown) {
setToastApiError(formatUnknownError(error));

View File

@ -71,8 +71,7 @@ export const FeatureOverviewSidePanelTags = ({
refetch();
setToastData({
type: 'success',
title: 'Tag deleted',
text: 'Successfully deleted tag',
text: 'Tag deleted',
});
} catch (error: unknown) {
setToastApiError(formatUnknownError(error));

View File

@ -10,7 +10,6 @@ import { Dialogue } from 'component/common/Dialogue/Dialogue';
import useFeatureApi from 'hooks/api/actions/useFeatureApi/useFeatureApi';
import useFeatureTags from 'hooks/api/getters/useFeatureTags/useFeatureTags';
import useToast from 'hooks/useToast';
import { formatUnknownError } from 'utils/formatUnknownError';
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
import type { ITag, ITagType } from 'interfaces/tags';
import { type TagOption, TagsInput } from './TagsInput';
@ -134,12 +133,9 @@ export const ManageTagsDialog = ({ open, setOpen }: IManageTagsProps) => {
});
await refetch();
} catch (error: unknown) {
const message = formatUnknownError(error);
setToastData({
type: 'error',
title: `Failed to add tag`,
text: message,
confetti: false,
text: 'Failed to add tag',
});
}
};
@ -179,9 +175,7 @@ export const ManageTagsDialog = ({ open, setOpen }: IManageTagsProps) => {
differenceCount > 0 &&
setToastData({
type: 'success',
title: `Updated tag${added.length > 1 ? 's' : ''} to flag`,
text: getToastText(added.length, removed.length),
confetti: true,
text: `Updated tag${added.length > 1 ? 's' : ''} to flag`,
});
}
setDifferenceCount(0);

View File

@ -120,7 +120,7 @@ export const FeatureOverviewEnvironmentBody = ({
);
refetchFeature();
setToastData({
title: 'Order of strategies updated',
text: 'Order of strategies updated',
type: 'success',
});
} catch (error: unknown) {
@ -138,9 +138,8 @@ export const FeatureOverviewEnvironmentBody = ({
});
setToastData({
title: 'Strategy execution order added to draft',
text: 'Strategy execution order added to draft',
type: 'success',
confetti: true,
});
refetchChangeRequests();
};

View File

@ -101,7 +101,7 @@ export const ReleasePlan = ({
id,
);
setToastData({
title: `Release plan "${name}" has been removed from ${featureName} in ${environment}`,
text: `Release plan "${name}" has been removed from ${featureName} in ${environment}`,
type: 'success',
});
refetch();
@ -121,7 +121,7 @@ export const ReleasePlan = ({
milestone.id,
);
setToastData({
title: `Milestone "${milestone.name}" has started`,
text: `Milestone "${milestone.name}" has started`,
type: 'success',
});
refetch();

View File

@ -34,7 +34,7 @@ const FeatureSettingsProject = () => {
if (project) {
await changeFeatureProject(projectId, featureId, project);
refetchFeature();
setToastData({ title: 'Project changed', type: 'success' });
setToastData({ text: 'Project changed', type: 'success' });
setShowConfirmDialog(false);
navigate(
`/projects/${project}/features/${featureId}/settings`,

View File

@ -117,7 +117,7 @@ export const FeatureEnvironmentVariants = () => {
if (error) {
setToastData({
type: 'error',
title: error,
text: error,
});
return;
}
@ -183,7 +183,7 @@ export const FeatureEnvironmentVariants = () => {
pushTitle && draftTitle ? '. ' : ''
}${draftTitle}`;
setToastData({
title,
text: title,
type: 'success',
});
} catch (error: unknown) {
@ -202,7 +202,7 @@ export const FeatureEnvironmentVariants = () => {
await updateVariants(selectedEnvironment, updatedVariants);
setModalOpen(false);
setToastData({
title: selectedEnvironment.crEnabled
text: selectedEnvironment.crEnabled
? `Variant changes added to draft`
: 'Variants updated successfully',
type: 'success',
@ -221,7 +221,7 @@ export const FeatureEnvironmentVariants = () => {
const variants = fromEnvironment.variants ?? [];
await updateVariants(toEnvironment, variants);
setToastData({
title: toEnvironment.crEnabled
text: toEnvironment.crEnabled
? 'Variants copy added to draft'
: 'Variants copied successfully',
type: 'success',

View File

@ -224,7 +224,7 @@ export const FeatureView = () => {
} catch (error: unknown) {
setToastData({
type: 'error',
title: 'Could not copy feature name',
text: 'Could not copy feature name',
});
}
};

View File

@ -82,7 +82,7 @@ export const FeatureTypeForm: VFC<FeatureTypeFormProps> = ({
await updateFeatureTypeLifetime(featureType.id, value);
refetch();
setToastData({
title: 'Feature type updated',
text: 'Feature type updated',
type: 'success',
});
navigate('/feature-toggle-type');

View File

@ -77,8 +77,7 @@ export const FeedbackCESForm = ({ state, onClose }: IFeedbackCESFormProps) => {
await sendFeedbackInput(form);
setToastData({
type: 'success',
title: 'Feedback sent. Thank you!',
confetti: true,
text: 'Feedback sent. Thank you!',
});
onClose();
} finally {

View File

@ -260,7 +260,7 @@ export const FeedbackComponent = ({
}
setToastData({
title: toastTitle,
text: toastTitle,
type: toastType,
});
closeFeedback();

View File

@ -33,8 +33,7 @@ export const IntegrationDelete: VFC<IIntegrationDeleteProps> = ({ id }) => {
refetchAddons();
setToastData({
type: 'success',
title: 'Success',
text: 'Deleted addon successfully',
text: 'Integration deleted',
});
} catch (error: unknown) {
setToastApiError(formatUnknownError(error));

View File

@ -251,15 +251,14 @@ export const IntegrationForm: FC<IntegrationFormProps> = ({
navigate('/integrations');
setToastData({
type: 'success',
title: 'Integration updated successfully',
text: 'Integration updated',
});
} else {
await createAddon(formValues as Omit<AddonSchema, 'id'>);
navigate('/integrations');
setToastData({
type: 'success',
confetti: true,
title: 'Integration created successfully',
text: 'Integration created',
});
}
} catch (error) {

View File

@ -76,10 +76,9 @@ export const IntegrationCardMenu: VFC<IIntegrationCardMenuProps> = ({
refetchAddons();
setToastData({
type: 'success',
title: 'Success',
text: !addon.enabled
? 'Integration is now enabled'
: 'Integration is now disabled',
? 'Integration enabled'
: 'Integration disabled',
});
} catch (error: unknown) {
setToastApiError(formatUnknownError(error));
@ -92,8 +91,7 @@ export const IntegrationCardMenu: VFC<IIntegrationCardMenuProps> = ({
refetchAddons();
setToastData({
type: 'success',
title: 'Success',
text: 'Integration has been deleted',
text: 'Integration deleted',
});
} catch (error: unknown) {
setToastApiError(formatUnknownError(error));

View File

@ -62,7 +62,7 @@ const CopyBlock: FC<{ title: string; code: string }> = ({ title, code }) => {
copy(data);
setToastData({
type: 'success',
title: 'Copied to clipboard',
text: 'Copied to clipboard',
});
};
const { setToastData } = useToast();

View File

@ -150,7 +150,7 @@ export const AdvancedPlayground: FC<{
} catch (error) {
setToastData({
type: 'error',
title: `Failed to parse URL parameters: ${formatUnknownError(
text: `Failed to parse URL parameters: ${formatUnknownError(
error,
)}`,
});
@ -233,14 +233,12 @@ export const AdvancedPlayground: FC<{
} else if (error instanceof SyntaxError) {
setToastData({
type: 'error',
title: `Error parsing context: ${formatUnknownError(
error,
)}`,
text: `Error parsing context: ${formatUnknownError(error)}`,
});
} else {
setToastData({
type: 'error',
title: formatUnknownError(error),
text: formatUnknownError(error),
});
}
}

View File

@ -112,7 +112,7 @@ export const PlaygroundCodeFieldset: VFC<IPlaygroundCodeFieldsetProps> = ({
} catch (error) {
setToastData({
type: 'error',
title: `Error parsing context: ${formatUnknownError(error)}`,
text: `Error parsing context: ${formatUnknownError(error)}`,
});
}
};

View File

@ -29,9 +29,8 @@ export const ArchiveProjectDialogue = ({
await archiveProject(project);
refetchProjectOverview();
setToastData({
title: 'Archived project',
text: 'Project archived',
type: 'success',
text: 'Successfully archived project',
});
onSuccess?.();
} catch (ex: unknown) {

View File

@ -178,9 +178,7 @@ export const CreateProjectDialog = ({
refetchUser();
navigate(`/projects/${createdProject.id}`);
setToastData({
title: 'Project created',
text: 'Now you can add flags to this project',
confetti: true,
text: 'Project created',
type: 'success',
});

View File

@ -43,9 +43,8 @@ export const DeleteProjectDialogue = ({
refetchProjects();
refetchProjectArchive();
setToastData({
title: 'Deleted project',
text: 'Project deleted',
type: 'success',
text: 'Successfully deleted project',
});
onSuccess?.();
} catch (ex: unknown) {

View File

@ -89,14 +89,14 @@ export const ImportArea: FC<{
setActiveTab('code');
setToastData({
type: 'success',
title: 'File uploaded',
text: 'File uploaded',
});
}}
onError={(error) => {
setImportPayload('');
setToastData({
type: 'error',
title: error,
text: error,
});
}}
onDragStatusChange={setDragActive}

View File

@ -80,7 +80,7 @@ export const ImportStage: FC<{
.catch((error) => {
setToastData({
type: 'error',
title: formatUnknownError(error),
text: formatUnknownError(error),
});
});
}, []);

View File

@ -124,7 +124,7 @@ export const ValidationStage: FC<{
setValidJSON(false);
setToastData({
type: 'error',
title: formatUnknownError(error),
text: formatUnknownError(error),
});
});
}, []);

View File

@ -164,9 +164,7 @@ const CreateFeatureDialogContent = ({
navigate(`/projects/${project}/features/${name}`);
}
setToastData({
title: 'Flag created successfully',
text: 'Now you can start using your flag.',
confetti: true,
text: 'Flag created successfully',
type: 'success',
});
onClose();

View File

@ -235,7 +235,7 @@ export const Project = () => {
const text = created ? 'Project created' : 'Project updated';
setToastData({
type: 'success',
title: text,
text,
});
}
/* eslint-disable-next-line */

View File

@ -81,7 +81,7 @@ export const ActionsCell: VFC<IActionsCellProps> = ({
} catch (error: unknown) {
setToastData({
type: 'error',
title: 'Could not copy feature name',
text: 'Could not copy feature name',
});
}
};

View File

@ -170,8 +170,7 @@ export const useFeatureToggleSwitch: UseFeatureToggleSwitchType = (
setToastData({
type: 'success',
title: `Enabled in ${config.environmentName}`,
text: `${config.featureId} is now available in ${config.environmentName} based on its defined strategies.`,
text: `Enabled in ${config.environmentName}`,
});
config.onSuccess?.();
} catch (error: unknown) {
@ -193,8 +192,7 @@ export const useFeatureToggleSwitch: UseFeatureToggleSwitchType = (
);
setToastData({
type: 'success',
title: `Disabled in ${config.environmentName}`,
text: `${config.featureId} is unavailable in ${config.environmentName} and its strategies will no longer have any effect.`,
text: `Disabled in ${config.environmentName}`,
});
config.onSuccess?.();
} catch (error: unknown) {

View File

@ -62,21 +62,19 @@ export const ManageTags: VFC<IManageTagsProps> = ({
const features = data.map(({ name }) => name);
const payload = { features, tags: { addedTags, removedTags } };
try {
await bulkUpdateTags(payload, projectId);
const added = addedTags.length
? `Added tags: ${addedTags
.map(({ type, value }) => `${type}:${value}`)
.join(', ')}.`
: '';
const removed = removedTags.length
? `Removed tags: ${removedTags
.map(({ type, value }) => `${type}:${value}`)
.join(', ')}.`
: '';
console.log(addedTags, removedTags, features);
const toastText = [
addedTags.length > 0 &&
`added ${addedTags.length} tag${addedTags.length > 1 ? 's' : ''}`,
removedTags.length > 0 &&
`removed ${removedTags.length} tag${removedTags.length > 1 ? 's' : ''}`,
]
.filter(Boolean)
.join(' and ');
await bulkUpdateTags(payload, projectId);
setToastData({
title: 'Tags updated',
text: `${features.length} feature flags updated. ${added} ${removed}`,
text: toastText,
type: 'success',
autoHideDuration: 12000,
});

View File

@ -58,7 +58,6 @@ export const MoreActions: VFC<IMoreActionsProps> = ({
await staleFeatures(projectId, selectedIds);
onChange?.();
setToastData({
title: 'State updated',
text: 'Feature flags marked as stale',
type: 'success',
});
@ -78,7 +77,6 @@ export const MoreActions: VFC<IMoreActionsProps> = ({
await staleFeatures(projectId, selectedIds, false);
onChange?.();
setToastData({
title: 'State updated',
text: 'Feature flags unmarked as stale',
type: 'success',
});

View File

@ -96,8 +96,7 @@ export const ChangeRequestTable: VFC = () => {
);
setToastData({
type: 'success',
title: 'Updated change request status',
text: 'Successfully updated change request status.',
text: 'Change request status updated',
});
await refetchChangeRequestConfig();
} catch (error) {

View File

@ -159,7 +159,7 @@ export const ProjectActionsModal = ({
await addActionSet(payload);
}
setToastData({
title: `action ${editing ? 'updated' : 'added'} successfully`,
text: `action ${editing ? 'updated' : 'added'} successfully`,
type: 'success',
});
refetch();

View File

@ -57,7 +57,7 @@ export const ProjectActionsTable = ({
try {
await toggleActionSet(action.id, enabled);
setToastData({
title: `"${action.name}" has been ${
text: `"${action.name}" has been ${
enabled ? 'enabled' : 'disabled'
}`,
type: 'success',
@ -72,7 +72,7 @@ export const ProjectActionsTable = ({
try {
await removeActionSet(action.id);
setToastData({
title: `"${action.name}" has been deleted`,
text: `"${action.name}" has been deleted`,
type: 'success',
});
refetch();

View File

@ -107,9 +107,8 @@ const EditDefaultStrategy = () => {
refetchSavedStrategySegments();
refetchProjectOverview();
setToastData({
title: 'Default Strategy updated',
text: 'Default Strategy updated',
type: 'success',
confetti: true,
});
};

View File

@ -125,7 +125,7 @@ export const UpdateEnterpriseSettings = ({
await editProjectSettings(id, payload);
refetch();
setToastData({
title: 'Project information updated',
text: 'Project information updated',
type: 'success',
});
trackPattern(featureNamingPattern);

Some files were not shown because too many files have changed in this diff Show More