Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit text for "delete asset" modal #11857

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
4 changes: 3 additions & 1 deletion app/common/src/text/english.json
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@
"thisFolderFailedToFetch": "This folder failed to fetch.",
"yourTrashIsEmpty": "Your trash is empty.",
"deleteTheAssetTypeTitle": "delete the $0 '$1'",
"deleteTheAssetTypeTitleForever": "permanently delete the $0 '$1'",
"trashTheAssetTypeTitle": "move the $0 '$1' to Trash",
"notImplemetedYet": "Not implemented yet.",
"newLabelButtonLabel": "New label",
Expand Down Expand Up @@ -445,7 +446,8 @@
"youHaveNoRecentProjects": "You have no recent projects. Switch to another category to create a project.",
"youHaveNoFiles": "This folder is empty. You can create a project using the buttons above.",
"placeholderChatPrompt": "Login or register to access live chat with our support team.",
"confirmPrompt": "Are you sure you want to $0?",
"confirmPrompt": "Do you really want to $0?",
"confirmPromptCannotUndo": "Do you really want to $0? This operation is final and cannot be undone.",
somebody1234 marked this conversation as resolved.
Show resolved Hide resolved
"couldNotInviteUser": "Could not invite user $0",
"inviteFormSeatsLeft": "You have $0 seats left on your plan. Upgrade to invite more",
"inviteFormSeatsLeftError": "You have exceed the number of seats on your plan by $0",
Expand Down
2 changes: 2 additions & 0 deletions app/common/src/text/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ interface PlaceholderOverrides {
readonly deleteUserGroupActionText: [groupName: string]
readonly removeUserFromUserGroupActionText: [userName: string, groupName: string]
readonly confirmPrompt: [action: string]
readonly confirmPromptCannotUndo: [action: string]
readonly trashTheAssetTypeTitle: [assetType: string, assetName: string]
readonly deleteTheAssetTypeTitle: [assetType: string, assetName: string]
readonly deleteTheAssetTypeTitleForever: [assetType: string, assetName: string]
readonly couldNotInviteUser: [userEmail: string]
readonly filesWithoutConflicts: [fileCount: number]
readonly projectsWithoutConflicts: [projectCount: number]
Expand Down
3 changes: 2 additions & 1 deletion app/gui/src/dashboard/layouts/AssetContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ export default function AssetContextMenu(props: AssetContextMenuProps) {
setModal(
<ConfirmDeleteModal
defaultOpen
actionText={`delete the ${asset.type} '${asset.title}' forever`}
cannotUndo
actionText={getText('deleteTheAssetTypeTitleForever', asset.type, asset.title)}
doDelete={() => {
const ids = new Set([asset.id])
dispatchAssetEvent({ type: AssetEventType.deleteForever, ids })
Expand Down
2 changes: 1 addition & 1 deletion app/gui/src/dashboard/layouts/AssetsTableContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export default function AssetsTableContextMenu(props: AssetsTableContextMenuProp

if (category.type === 'trash') {
return (
selectedKeys.size !== 0 && (
selectedKeys.size > 1 && (
<ContextMenu
aria-label={getText('assetsTableContextMenuLabel')}
hidden={hidden}
Expand Down
23 changes: 14 additions & 9 deletions app/gui/src/dashboard/modals/ConfirmDeleteModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,34 @@ import { useText } from '#/providers/TextProvider'

/** Props for a {@link ConfirmDeleteModal}. */
export interface ConfirmDeleteModalProps {
readonly defaultOpen?: boolean
readonly defaultOpen?: boolean | undefined
readonly cannotUndo?: boolean | undefined
/** Must fit in the sentence "Are you sure you want to <action>?". */
readonly actionText: string
/** The label shown on the colored confirmation button. "Delete" by default. */
readonly actionButtonLabel?: string
readonly actionButtonLabel?: string | undefined
readonly doDelete: () => void
}

/** A modal for confirming the deletion of an asset. */
export default function ConfirmDeleteModal(props: ConfirmDeleteModalProps) {
const { defaultOpen, actionText, actionButtonLabel = 'Delete', doDelete } = props
const {
defaultOpen = false,
cannotUndo = false,
actionText,
actionButtonLabel = 'Delete',
doDelete,
} = props

const { unsetModal } = useSetModal()
const { getText } = useText()

return (
<Dialog
title={getText('areYouSure')}
role="alertdialog"
modalProps={defaultOpen == null ? {} : { defaultOpen }}
>
<Dialog title={getText('areYouSure')} role="alertdialog" modalProps={{ defaultOpen }}>
<Form schema={z.object({})} method="dialog" onSubmit={doDelete} onSubmitSuccess={unsetModal}>
<Text className="relative">{getText('confirmPrompt', actionText)}</Text>
<Text className="relative">
{getText(cannotUndo ? 'confirmPromptCannotUndo' : 'confirmPrompt', actionText)}
</Text>

<ButtonGroup>
<Form.Submit variant="delete" className="relative">
Expand Down
Loading