Skip to content

Commit

Permalink
Edit text for "delete asset" modal
Browse files Browse the repository at this point in the history
  • Loading branch information
somebody1234 committed Dec 13, 2024
1 parent b83c5a1 commit d166e01
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
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.",
"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
25 changes: 16 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,36 @@ 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()

console.log('hello owo', cannotUndo)

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

0 comments on commit d166e01

Please sign in to comment.