Skip to content

Commit 35e75ef

Browse files
authored
Merge pull request #239 from import-ai/feat/del2ndconfirm
fix: Fix title too long causing pop-up window to not display properly
2 parents 7d67fd0 + 7be070e commit 35e75ef

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

src/components/confirm-delete-dialog/index.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface IProps {
1919
open: boolean;
2020
titleKey?: string;
2121
descriptionKey?: string;
22-
targetName: string;
22+
targetName?: string;
2323
itemTitle: string;
2424
deleteUrl: string;
2525
restoreUrl?: string;
@@ -35,7 +35,6 @@ export default function ConfirmDeleteDialog(props: IProps) {
3535
const {
3636
open,
3737
titleKey,
38-
targetName,
3938
descriptionKey,
4039
itemTitle,
4140
deleteUrl,
@@ -47,6 +46,7 @@ export default function ConfirmDeleteDialog(props: IProps) {
4746
onRestoreSuccess,
4847
onError,
4948
} = props;
49+
5050
const { t } = useTranslation();
5151
const [loading, setLoading] = useState(false);
5252

@@ -96,20 +96,24 @@ export default function ConfirmDeleteDialog(props: IProps) {
9696
});
9797
};
9898

99+
const targetTitle = (itemTitle: string) => {
100+
if (itemTitle.length > 50) {
101+
return itemTitle.slice(0, 10) + '...' + itemTitle.slice(-10);
102+
}
103+
return itemTitle;
104+
};
105+
99106
return (
100107
<AlertDialog open={open} onOpenChange={onOpenChange}>
101108
<AlertDialogContent>
102109
<AlertDialogHeader>
103110
<AlertDialogTitle>
104-
<Trans
105-
i18nKey={titleKey || 'common.dialog.delete.title'}
106-
values={{ target_name: targetName }}
107-
/>
111+
<Trans i18nKey={titleKey || 'common.dialog.delete.title'} />
108112
</AlertDialogTitle>
109113
<AlertDialogDescription>
110114
<Trans
111115
i18nKey={descriptionKey || 'common.dialog.delete.description'}
112-
values={{ title: itemTitle }}
116+
values={{ title: targetTitle(itemTitle) }}
113117
components={{
114118
strong: <strong className="font-bold" />,
115119
}}

src/i18n/locales/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@
537537
"next": "Next",
538538
"dialog": {
539539
"delete": {
540-
"title": "Delete {{target_name}}?",
540+
"title": "Delete?",
541541
"description": "You are going to delete <strong>{{title}}</strong>"
542542
}
543543
}

src/i18n/locales/zh.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@
537537
"next": "下一页",
538538
"dialog": {
539539
"delete": {
540-
"title": "删除{{target_name}}",
540+
"title": "确认删除",
541541
"description": "您将要删除 <strong>{{title}}</strong>"
542542
}
543543
}

0 commit comments

Comments
 (0)