Skip to content

Commit

Permalink
chore(unl-204): remove uses of toast text and confetti (#8941)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
thomasheartman authored Dec 10, 2024
1 parent 2f7bece commit b2c5810
Show file tree
Hide file tree
Showing 135 changed files with 192 additions and 293 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const ApiTokenDocs = () => {
copy(url);
setToastData({
type: 'success',
title: 'Copied to clipboard',
text: 'Copied to clipboard',
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const GoogleAuth = () => {
try {
await updateSettings(removeEmptyStringFields(data));
setToastData({
title: 'Settings stored',
text: 'Settings stored',
type: 'success',
});
} catch (error: unknown) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/component/admin/auth/OidcAuth/OidcAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const OidcAuth = () => {
try {
await updateSettings(removeEmptyStringFields(data));
setToastData({
title: 'Settings stored',
text: 'Settings stored',
type: 'success',
});
} catch (error: unknown) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/component/admin/auth/SamlAuth/SamlAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const SamlAuth = () => {
try {
await updateSettings(removeEmptyStringFields(data));
setToastData({
title: 'Settings stored',
text: 'Settings stored',
type: 'success',
});
} catch (error: unknown) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const ScimSettings = () => {
}

setToastData({
title: 'Settings stored',
text: 'Settings stored',
type: 'success',
});
await refetch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/component/admin/cors/CorsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/component/admin/license/License.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const License = () => {
try {
await updateLicenseKey(token);
setToastData({
title: 'License key updated',
text: 'License key updated',
type: 'success',
});
refetchLicense();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}`,
});
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/component/admin/roles/RoleModal/RoleModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export const ServiceAccountModal = ({
}
}
setToastData({
title: `Service account ${
text: `Service account ${
editing ? 'updated' : 'added'
} successfully`,
type: 'success',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -146,7 +146,7 @@ export const ServiceAccountTokens = ({
refetchTokens();
setDeleteOpen(false);
setToastData({
title: 'Token deleted successfully',
text: 'Token deleted successfully',
type: 'success',
});
} catch (error: unknown) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/component/admin/users/EditUser/EditUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const EditUser = () => {
refetch();
navigate('/admin/users');
setToastData({
title: 'User information updated',
text: 'User information updated',
type: 'success',
});
} catch (error: unknown) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/component/admin/users/LinkField/LinkField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const LinkField: FC<ILinkFieldProps> = ({
const setError = () =>
setToastData({
type: 'error',
title: errorTitle,
text: errorTitle,
});

const handleCopy = () => {
Expand All @@ -61,7 +61,7 @@ export const LinkField: FC<ILinkFieldProps> = ({
.then(() => {
setToastData({
type: 'success',
title: successTitle,
text: successTitle,
});
onCopy?.();
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/component/admin/users/UsersList/UsersList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/component/application/Application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?.();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const EditChange = ({
});
onSubmit();
setToastData({
title: 'Change updated',
text: 'Change updated',
type: 'success',
});
} catch (error: unknown) {
Expand Down
Loading

0 comments on commit b2c5810

Please sign in to comment.