mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Mark strings in folder manager nav for translation * Mark strings in folder actions for translation * Mark strings in new folder modal for translation * Mark strings in delete modal for translation * Mark strings in move modal for translation * Fix interpunction in translations * Run i18n:extract * Fix Manage Permissions drawer test * Redundnt useMemo * Updated extracted translations after resolving conflicts --------- Co-authored-by: Roxana Turc <anamaria-roxana.turc@grafana.com>
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
import React, { useState } from 'react';
|
|
|
|
import { Space } from '@grafana/experimental';
|
|
import { ConfirmModal } from '@grafana/ui';
|
|
import { P } from '@grafana/ui/src/unstable';
|
|
import { Trans, t } from 'app/core/internationalization';
|
|
|
|
import { DashboardTreeSelection } from '../../types';
|
|
|
|
import { DescendantCount } from './DescendantCount';
|
|
|
|
export interface Props {
|
|
isOpen: boolean;
|
|
onConfirm: () => Promise<void>;
|
|
onDismiss: () => void;
|
|
selectedItems: DashboardTreeSelection;
|
|
}
|
|
|
|
export const DeleteModal = ({ onConfirm, onDismiss, selectedItems, ...props }: Props) => {
|
|
const [isDeleting, setIsDeleting] = useState(false);
|
|
const onDelete = async () => {
|
|
setIsDeleting(true);
|
|
try {
|
|
await onConfirm();
|
|
setIsDeleting(false);
|
|
onDismiss();
|
|
} catch {
|
|
setIsDeleting(false);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<ConfirmModal
|
|
body={
|
|
<>
|
|
<P>
|
|
<Trans i18nKey="browse-dashboards.action.delete-modal-text">
|
|
This action will delete the following content:
|
|
</Trans>
|
|
</P>
|
|
<DescendantCount selectedItems={selectedItems} />
|
|
<Space v={2} />
|
|
</>
|
|
}
|
|
confirmationText="Delete"
|
|
confirmText={
|
|
isDeleting
|
|
? t('browse-dashboards.action.deleting', 'Deleting...')
|
|
: t('browse-dashboards.action.delete-button', 'Delete')
|
|
}
|
|
onDismiss={onDismiss}
|
|
onConfirm={onDelete}
|
|
title={t('browse-dashboards.action.delete-modal-title', 'Delete')}
|
|
{...props}
|
|
/>
|
|
);
|
|
};
|