0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -05:00

refactor(console): use correct delete confirmation text

This commit is contained in:
Gao Sun 2023-10-20 16:56:08 +08:00
parent 4ee2947b81
commit 14008e198b
No known key found for this signature in database
GPG key ID: 13EBE123E4773688
18 changed files with 96 additions and 7 deletions

View file

@ -1,5 +1,5 @@
import { type AdminConsoleKey } from '@logto/phrases';
import { useCallback, useState, type ReactNode } from 'react';
import { useCallback, useState } from 'react';
import { useTranslation } from 'react-i18next';
import Delete from '@/assets/icons/delete.svg';
@ -7,6 +7,7 @@ import Edit from '@/assets/icons/edit.svg';
import More from '@/assets/icons/more.svg';
import ActionMenu, { ActionMenuItem } from '@/ds-components/ActionMenu';
import ConfirmModal from '@/ds-components/ConfirmModal';
import DynamicT from '@/ds-components/DynamicT';
import useActionTranslation from '@/hooks/use-action-translation';
import * as styles from './index.module.scss';
@ -16,8 +17,8 @@ type Props = {
onDelete: () => void | Promise<void>;
/** A function that will be called when the user clicks the edit button. */
onEdit: () => void | Promise<void>;
/** The text or content to display in the confirmation modal. */
content: ReactNode;
/** The translation key of the content that will be displayed in the confirmation modal. */
deleteConfirmation: AdminConsoleKey;
/** The name of the field that is being operated. */
fieldName: AdminConsoleKey;
};
@ -28,7 +29,7 @@ type Props = {
* - Edit
* - Delete
*/
function ActionsButton({ onDelete, onEdit, content, fieldName }: Props) {
function ActionsButton({ onDelete, onEdit, deleteConfirmation, fieldName }: Props) {
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
const tAction = useActionTranslation();
const [isModalOpen, setIsModalOpen] = useState(false);
@ -72,7 +73,7 @@ function ActionsButton({ onDelete, onEdit, content, fieldName }: Props) {
}}
onConfirm={handleDelete}
>
{content}
<DynamicT forKey={deleteConfirmation} />
</ConfirmModal>
</>
);

View file

@ -75,7 +75,7 @@ function PermissionsField() {
render: (data) => (
<ActionsButton
fieldName="organizations.permission"
content="Delete at your own risk, mate."
deleteConfirmation="organizations.organization_permission_delete_confirm"
onEdit={() => {
setEditData(data);
setIsModalOpen(true);

View file

@ -89,7 +89,7 @@ function RolesField() {
render: (data) => (
<ActionsButton
fieldName="organizations.role"
content="Delete at your own risk, mate."
deleteConfirmation="organizations.organization_role_delete_confirm"
onEdit={() => {
setEditData(data);
setIsModalOpen(true);

View file

@ -14,6 +14,9 @@ const organizations = {
/** UNTRANSLATED */
organization_permission_other: 'Organization permissions',
/** UNTRANSLATED */
organization_permission_delete_confirm:
'If this permission is deleted, all organization roles including this permission will lose this permission, and users who had this permission will lose the access granted by it.',
/** UNTRANSLATED */
create_permission_placeholder: 'Read appointment history.',
/** UNTRANSLATED */
permission: 'Permission',
@ -24,6 +27,9 @@ const organizations = {
/** UNTRANSLATED */
organization_role_other: 'Organization roles',
/** UNTRANSLATED */
organization_role_delete_confirm:
'Doing so will remove the permissions associated with this role from the affected users and delete the relations among organization roles, members in the organization, and organization permissions.',
/** UNTRANSLATED */
role: 'Role',
/** UNTRANSLATED */
create_role_placeholder: 'Users with view-only permissions.',

View file

@ -7,11 +7,15 @@ const organization = {
'Authorization in a multi-tenancy applications is often designed to make sure that tenant isolation is maintained throughout an application and that tenants can access only their own resources.',
organization_permission: 'Organization permission',
organization_permission_other: 'Organization permissions',
organization_permission_delete_confirm:
'If this permission is deleted, all organization roles including this permission will lose this permission, and users who had this permission will lose the access granted by it.',
create_permission_placeholder: 'Read appointment history.',
permission: 'Permission',
permission_other: 'Permissions',
organization_role: 'Organization role',
organization_role_other: 'Organization roles',
organization_role_delete_confirm:
'Doing so will remove the permissions associated with this role from the affected users and delete the relations among organization roles, members in the organization, and organization permissions.',
role: 'Role',
create_role_placeholder: 'Users with view-only permissions.',
search_permission_placeholder: 'Type to search for permissions.',

View file

@ -14,6 +14,9 @@ const organizations = {
/** UNTRANSLATED */
organization_permission_other: 'Organization permissions',
/** UNTRANSLATED */
organization_permission_delete_confirm:
'If this permission is deleted, all organization roles including this permission will lose this permission, and users who had this permission will lose the access granted by it.',
/** UNTRANSLATED */
create_permission_placeholder: 'Read appointment history.',
/** UNTRANSLATED */
permission: 'Permission',
@ -24,6 +27,9 @@ const organizations = {
/** UNTRANSLATED */
organization_role_other: 'Organization roles',
/** UNTRANSLATED */
organization_role_delete_confirm:
'Doing so will remove the permissions associated with this role from the affected users and delete the relations among organization roles, members in the organization, and organization permissions.',
/** UNTRANSLATED */
role: 'Role',
/** UNTRANSLATED */
create_role_placeholder: 'Users with view-only permissions.',

View file

@ -14,6 +14,9 @@ const organizations = {
/** UNTRANSLATED */
organization_permission_other: 'Organization permissions',
/** UNTRANSLATED */
organization_permission_delete_confirm:
'If this permission is deleted, all organization roles including this permission will lose this permission, and users who had this permission will lose the access granted by it.',
/** UNTRANSLATED */
create_permission_placeholder: 'Read appointment history.',
/** UNTRANSLATED */
permission: 'Permission',
@ -24,6 +27,9 @@ const organizations = {
/** UNTRANSLATED */
organization_role_other: 'Organization roles',
/** UNTRANSLATED */
organization_role_delete_confirm:
'Doing so will remove the permissions associated with this role from the affected users and delete the relations among organization roles, members in the organization, and organization permissions.',
/** UNTRANSLATED */
role: 'Role',
/** UNTRANSLATED */
create_role_placeholder: 'Users with view-only permissions.',

View file

@ -14,6 +14,9 @@ const organizations = {
/** UNTRANSLATED */
organization_permission_other: 'Organization permissions',
/** UNTRANSLATED */
organization_permission_delete_confirm:
'If this permission is deleted, all organization roles including this permission will lose this permission, and users who had this permission will lose the access granted by it.',
/** UNTRANSLATED */
create_permission_placeholder: 'Read appointment history.',
/** UNTRANSLATED */
permission: 'Permission',
@ -24,6 +27,9 @@ const organizations = {
/** UNTRANSLATED */
organization_role_other: 'Organization roles',
/** UNTRANSLATED */
organization_role_delete_confirm:
'Doing so will remove the permissions associated with this role from the affected users and delete the relations among organization roles, members in the organization, and organization permissions.',
/** UNTRANSLATED */
role: 'Role',
/** UNTRANSLATED */
create_role_placeholder: 'Users with view-only permissions.',

View file

@ -14,6 +14,9 @@ const organizations = {
/** UNTRANSLATED */
organization_permission_other: 'Organization permissions',
/** UNTRANSLATED */
organization_permission_delete_confirm:
'If this permission is deleted, all organization roles including this permission will lose this permission, and users who had this permission will lose the access granted by it.',
/** UNTRANSLATED */
create_permission_placeholder: 'Read appointment history.',
/** UNTRANSLATED */
permission: 'Permission',
@ -24,6 +27,9 @@ const organizations = {
/** UNTRANSLATED */
organization_role_other: 'Organization roles',
/** UNTRANSLATED */
organization_role_delete_confirm:
'Doing so will remove the permissions associated with this role from the affected users and delete the relations among organization roles, members in the organization, and organization permissions.',
/** UNTRANSLATED */
role: 'Role',
/** UNTRANSLATED */
create_role_placeholder: 'Users with view-only permissions.',

View file

@ -14,6 +14,9 @@ const organizations = {
/** UNTRANSLATED */
organization_permission_other: 'Organization permissions',
/** UNTRANSLATED */
organization_permission_delete_confirm:
'If this permission is deleted, all organization roles including this permission will lose this permission, and users who had this permission will lose the access granted by it.',
/** UNTRANSLATED */
create_permission_placeholder: 'Read appointment history.',
/** UNTRANSLATED */
permission: 'Permission',
@ -24,6 +27,9 @@ const organizations = {
/** UNTRANSLATED */
organization_role_other: 'Organization roles',
/** UNTRANSLATED */
organization_role_delete_confirm:
'Doing so will remove the permissions associated with this role from the affected users and delete the relations among organization roles, members in the organization, and organization permissions.',
/** UNTRANSLATED */
role: 'Role',
/** UNTRANSLATED */
create_role_placeholder: 'Users with view-only permissions.',

View file

@ -14,6 +14,9 @@ const organizations = {
/** UNTRANSLATED */
organization_permission_other: 'Organization permissions',
/** UNTRANSLATED */
organization_permission_delete_confirm:
'If this permission is deleted, all organization roles including this permission will lose this permission, and users who had this permission will lose the access granted by it.',
/** UNTRANSLATED */
create_permission_placeholder: 'Read appointment history.',
/** UNTRANSLATED */
permission: 'Permission',
@ -24,6 +27,9 @@ const organizations = {
/** UNTRANSLATED */
organization_role_other: 'Organization roles',
/** UNTRANSLATED */
organization_role_delete_confirm:
'Doing so will remove the permissions associated with this role from the affected users and delete the relations among organization roles, members in the organization, and organization permissions.',
/** UNTRANSLATED */
role: 'Role',
/** UNTRANSLATED */
create_role_placeholder: 'Users with view-only permissions.',

View file

@ -14,6 +14,9 @@ const organizations = {
/** UNTRANSLATED */
organization_permission_other: 'Organization permissions',
/** UNTRANSLATED */
organization_permission_delete_confirm:
'If this permission is deleted, all organization roles including this permission will lose this permission, and users who had this permission will lose the access granted by it.',
/** UNTRANSLATED */
create_permission_placeholder: 'Read appointment history.',
/** UNTRANSLATED */
permission: 'Permission',
@ -24,6 +27,9 @@ const organizations = {
/** UNTRANSLATED */
organization_role_other: 'Organization roles',
/** UNTRANSLATED */
organization_role_delete_confirm:
'Doing so will remove the permissions associated with this role from the affected users and delete the relations among organization roles, members in the organization, and organization permissions.',
/** UNTRANSLATED */
role: 'Role',
/** UNTRANSLATED */
create_role_placeholder: 'Users with view-only permissions.',

View file

@ -14,6 +14,9 @@ const organizations = {
/** UNTRANSLATED */
organization_permission_other: 'Organization permissions',
/** UNTRANSLATED */
organization_permission_delete_confirm:
'If this permission is deleted, all organization roles including this permission will lose this permission, and users who had this permission will lose the access granted by it.',
/** UNTRANSLATED */
create_permission_placeholder: 'Read appointment history.',
/** UNTRANSLATED */
permission: 'Permission',
@ -24,6 +27,9 @@ const organizations = {
/** UNTRANSLATED */
organization_role_other: 'Organization roles',
/** UNTRANSLATED */
organization_role_delete_confirm:
'Doing so will remove the permissions associated with this role from the affected users and delete the relations among organization roles, members in the organization, and organization permissions.',
/** UNTRANSLATED */
role: 'Role',
/** UNTRANSLATED */
create_role_placeholder: 'Users with view-only permissions.',

View file

@ -14,6 +14,9 @@ const organizations = {
/** UNTRANSLATED */
organization_permission_other: 'Organization permissions',
/** UNTRANSLATED */
organization_permission_delete_confirm:
'If this permission is deleted, all organization roles including this permission will lose this permission, and users who had this permission will lose the access granted by it.',
/** UNTRANSLATED */
create_permission_placeholder: 'Read appointment history.',
/** UNTRANSLATED */
permission: 'Permission',
@ -24,6 +27,9 @@ const organizations = {
/** UNTRANSLATED */
organization_role_other: 'Organization roles',
/** UNTRANSLATED */
organization_role_delete_confirm:
'Doing so will remove the permissions associated with this role from the affected users and delete the relations among organization roles, members in the organization, and organization permissions.',
/** UNTRANSLATED */
role: 'Role',
/** UNTRANSLATED */
create_role_placeholder: 'Users with view-only permissions.',

View file

@ -14,6 +14,9 @@ const organizations = {
/** UNTRANSLATED */
organization_permission_other: 'Organization permissions',
/** UNTRANSLATED */
organization_permission_delete_confirm:
'If this permission is deleted, all organization roles including this permission will lose this permission, and users who had this permission will lose the access granted by it.',
/** UNTRANSLATED */
create_permission_placeholder: 'Read appointment history.',
/** UNTRANSLATED */
permission: 'Permission',
@ -24,6 +27,9 @@ const organizations = {
/** UNTRANSLATED */
organization_role_other: 'Organization roles',
/** UNTRANSLATED */
organization_role_delete_confirm:
'Doing so will remove the permissions associated with this role from the affected users and delete the relations among organization roles, members in the organization, and organization permissions.',
/** UNTRANSLATED */
role: 'Role',
/** UNTRANSLATED */
create_role_placeholder: 'Users with view-only permissions.',

View file

@ -14,6 +14,9 @@ const organizations = {
/** UNTRANSLATED */
organization_permission_other: 'Organization permissions',
/** UNTRANSLATED */
organization_permission_delete_confirm:
'If this permission is deleted, all organization roles including this permission will lose this permission, and users who had this permission will lose the access granted by it.',
/** UNTRANSLATED */
create_permission_placeholder: 'Read appointment history.',
/** UNTRANSLATED */
permission: 'Permission',
@ -24,6 +27,9 @@ const organizations = {
/** UNTRANSLATED */
organization_role_other: 'Organization roles',
/** UNTRANSLATED */
organization_role_delete_confirm:
'Doing so will remove the permissions associated with this role from the affected users and delete the relations among organization roles, members in the organization, and organization permissions.',
/** UNTRANSLATED */
role: 'Role',
/** UNTRANSLATED */
create_role_placeholder: 'Users with view-only permissions.',

View file

@ -14,6 +14,9 @@ const organizations = {
/** UNTRANSLATED */
organization_permission_other: 'Organization permissions',
/** UNTRANSLATED */
organization_permission_delete_confirm:
'If this permission is deleted, all organization roles including this permission will lose this permission, and users who had this permission will lose the access granted by it.',
/** UNTRANSLATED */
create_permission_placeholder: 'Read appointment history.',
/** UNTRANSLATED */
permission: 'Permission',
@ -24,6 +27,9 @@ const organizations = {
/** UNTRANSLATED */
organization_role_other: 'Organization roles',
/** UNTRANSLATED */
organization_role_delete_confirm:
'Doing so will remove the permissions associated with this role from the affected users and delete the relations among organization roles, members in the organization, and organization permissions.',
/** UNTRANSLATED */
role: 'Role',
/** UNTRANSLATED */
create_role_placeholder: 'Users with view-only permissions.',

View file

@ -14,6 +14,9 @@ const organizations = {
/** UNTRANSLATED */
organization_permission_other: 'Organization permissions',
/** UNTRANSLATED */
organization_permission_delete_confirm:
'If this permission is deleted, all organization roles including this permission will lose this permission, and users who had this permission will lose the access granted by it.',
/** UNTRANSLATED */
create_permission_placeholder: 'Read appointment history.',
/** UNTRANSLATED */
permission: 'Permission',
@ -24,6 +27,9 @@ const organizations = {
/** UNTRANSLATED */
organization_role_other: 'Organization roles',
/** UNTRANSLATED */
organization_role_delete_confirm:
'Doing so will remove the permissions associated with this role from the affected users and delete the relations among organization roles, members in the organization, and organization permissions.',
/** UNTRANSLATED */
role: 'Role',
/** UNTRANSLATED */
create_role_placeholder: 'Users with view-only permissions.',