0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

refactor(console): use phrase key for <AssignRoleModal> (#4722)

This commit is contained in:
Gao Sun 2023-10-25 01:13:31 -05:00 committed by GitHub
parent 30047e3c19
commit 233ccff0fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 128 additions and 103 deletions

View file

@ -31,7 +31,7 @@ function AssignRoleModal<T extends Application | User>({
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' });
const [isLoading, setIsLoading] = useState(false);
const [entities, setEntities] = useState<T[]>([]);
const isUser = roleType === RoleType.User;
const phraseKey = roleType === RoleType.User ? 'users' : 'applications';
const api = useApi();
@ -43,20 +43,10 @@ function AssignRoleModal<T extends Application | User>({
setIsLoading(true);
try {
await (isUser
? api.post(`api/roles/${roleId}/users`, {
json: { userIds: entities.map(({ id }) => id) },
})
: api.post(`api/roles/${roleId}/applications`, {
json: { applicationIds: entities.map(({ id }) => id) },
}));
toast.success(
t(
isUser
? 'role_details.users.users_assigned'
: 'role_details.applications.applications_assigned'
)
);
await api.post(`api/roles/${roleId}/${phraseKey}`, {
json: { [phraseKey.slice(0, -1) + 'Ids']: entities.map(({ id }) => id) },
});
toast.success(t(`role_details.${phraseKey}.assigned_toast_text`));
onClose(true);
} finally {
setIsLoading(false);
@ -74,14 +64,8 @@ function AssignRoleModal<T extends Application | User>({
}}
>
<ModalLayout
title={
isUser ? 'role_details.users.assign_title' : 'role_details.applications.assign_title'
}
subtitle={
isUser
? 'role_details.users.assign_subtitle'
: 'role_details.applications.assign_subtitle'
}
title={`role_details.${phraseKey}.assign_title`}
subtitle={`role_details.${phraseKey}.assign_subtitle`}
size="large"
footer={
<>
@ -99,11 +83,7 @@ function AssignRoleModal<T extends Application | User>({
isLoading={isLoading}
disabled={entities.length === 0}
htmlType="submit"
title={
isUser
? 'role_details.users.confirm_assign'
: 'role_details.applications.confirm_assign'
}
title={`role_details.${phraseKey}.confirm_assign`}
size="large"
type="primary"
onClick={handleAssign}
@ -112,27 +92,19 @@ function AssignRoleModal<T extends Application | User>({
}
onClose={onClose}
>
<FormField
title={
isUser
? 'role_details.users.assign_users_field'
: 'role_details.applications.assign_applications_field'
}
>
<FormField title={`role_details.${phraseKey}.assign_field`}>
<EntitiesTransfer
searchProps={{
pathname: isUser ? 'api/users' : 'api/applications',
pathname: `api/${phraseKey}`,
parameters: {
excludeRoleId: roleId,
...(isUser
...(roleType === RoleType.User
? {}
: { 'search.type': ApplicationType.MachineToMachine, 'mode.type': 'exact' }),
},
}}
selectedEntities={entities}
emptyPlaceholder={
isUser ? 'role_details.users.empty' : 'role_details.applications.empty'
}
emptyPlaceholder={`role_details.${phraseKey}.empty`}
renderEntity={(entity) =>
isUserEntity(entity) ? (
<UserItem entity={entity} />

View file

@ -44,9 +44,11 @@ const role_details = {
assign_title: 'Benutzer zuweisen',
assign_subtitle:
'Weisen Sie Benutzer dieser Rolle zu. Finden Sie geeignete Benutzer, indem Sie nach Name, E-Mail, Telefon oder Benutzer-ID suchen.',
assign_users_field: 'Benutzer zuweisen',
/** UNTRANSLATED */
assign_field: 'Assign users',
confirm_assign: 'Benutzer zuweisen',
users_assigned: 'Die ausgewählten Benutzer wurden dieser Rolle erfolgreich zugewiesen',
/** UNTRANSLATED */
assigned_toast_text: 'The selected users were successfully assigned to this role',
empty: 'Kein Benutzer verfügbar',
},
applications: {
@ -60,10 +62,11 @@ const role_details = {
assign_title: 'Apps zuweisen',
assign_subtitle:
'Weisen Sie dieser Rolle Anwendungen zu. Finden Sie geeignete Anwendungen, indem Sie nach Name, Beschreibung oder App-ID suchen.',
assign_applications_field: 'Apps zuweisen',
/** UNTRANSLATED */
assign_field: 'Assign applications',
confirm_assign: 'Apps zuweisen',
applications_assigned:
'Die ausgewählten Anwendungen wurden dieser Rolle erfolgreich zugewiesen',
/** UNTRANSLATED */
assigned_toast_text: 'The selected applications were successfully assigned to this role',
empty: 'Keine Anwendung verfügbar',
},
};

View file

@ -43,9 +43,9 @@ const role_details = {
assign_title: 'Assign users',
assign_subtitle:
'Assign users to this role. Find appropriate users by searching name, email, phone, or user ID.',
assign_users_field: 'Assign users',
assign_field: 'Assign users',
confirm_assign: 'Assign users',
users_assigned: 'The selected users were successfully assigned to this role',
assigned_toast_text: 'The selected users were successfully assigned to this role',
empty: 'No user available',
},
applications: {
@ -59,9 +59,9 @@ const role_details = {
assign_title: 'Assign apps',
assign_subtitle:
'Assign applications to this role. Find appropriate applications by searching name, description or app ID.',
assign_applications_field: 'Assign applications',
assign_field: 'Assign applications',
confirm_assign: 'Assign applications',
applications_assigned: 'The selected applications were successfully assigned to this role',
assigned_toast_text: 'The selected applications were successfully assigned to this role',
empty: 'No application available',
},
};

View file

@ -43,9 +43,11 @@ const role_details = {
assign_title: 'Asignar usuarios',
assign_subtitle:
'Asignar usuarios a este rol. Encuentre usuarios apropiados buscando nombre, correo electrónico, teléfono o ID de usuario.',
assign_users_field: 'Asignar usuarios',
/** UNTRANSLATED */
assign_field: 'Assign users',
confirm_assign: 'Asignar usuarios',
users_assigned: 'Los usuarios seleccionados se asignaron correctamente a este rol',
/** UNTRANSLATED */
assigned_toast_text: 'The selected users were successfully assigned to this role',
empty: 'No hay usuarios disponibles',
},
applications: {
@ -59,9 +61,11 @@ const role_details = {
assign_title: 'Asignar aplicaciones',
assign_subtitle:
'Asignar aplicaciones a este rol. Encuentre las aplicaciones adecuadas buscando el nombre, la descripción o el ID de la aplicación.',
assign_applications_field: 'Asignar aplicaciones',
/** UNTRANSLATED */
assign_field: 'Assign applications',
confirm_assign: 'Asignar aplicaciones',
applications_assigned: 'Las aplicaciones seleccionadas se asignaron correctamente a este rol',
/** UNTRANSLATED */
assigned_toast_text: 'The selected applications were successfully assigned to this role',
empty: 'No hay aplicaciones disponibles',
},
};

View file

@ -43,9 +43,11 @@ const role_details = {
assign_title: 'Attribuer des utilisateurs',
assign_subtitle:
'Attribuez des utilisateurs à ce rôle. Trouvez les utilisateurs appropriés en recherchant leur nom, leur e-mail, leur numéro de téléphone ou leur ID utilisateur.',
assign_users_field: 'Attribuer des utilisateurs',
/** UNTRANSLATED */
assign_field: 'Assign users',
confirm_assign: 'Attribuer des utilisateurs',
users_assigned: 'Les utilisateurs sélectionnés ont été attribués avec succès à ce rôle',
/** UNTRANSLATED */
assigned_toast_text: 'The selected users were successfully assigned to this role',
empty: 'Aucun utilisateur disponible',
},
applications: {
@ -59,10 +61,11 @@ const role_details = {
assign_title: 'Assigner des applications',
assign_subtitle:
"Assignez des applications à ce rôle. Trouvez les applications appropriées en recherchant par nom, description ou ID de l'application.",
assign_applications_field: 'Assigner des applications',
/** UNTRANSLATED */
assign_field: 'Assign applications',
confirm_assign: 'Assigner des applications',
applications_assigned:
'Les applications sélectionnées ont été attribuées avec succès à ce rôle',
/** UNTRANSLATED */
assigned_toast_text: 'The selected applications were successfully assigned to this role',
empty: 'Aucune application disponible',
},
};

View file

@ -44,9 +44,11 @@ const role_details = {
assign_title: 'Assegna utenti',
assign_subtitle:
'Assegna utenti a questo ruolo. Trova utenti appropriati cercando nome, email, telefono o ID utente.',
assign_users_field: 'Assegna utenti',
/** UNTRANSLATED */
assign_field: 'Assign users',
confirm_assign: 'Assegna utenti',
users_assigned: 'Gli utenti selezionati sono stati assegnati con successo a questo ruolo',
/** UNTRANSLATED */
assigned_toast_text: 'The selected users were successfully assigned to this role',
empty: 'Nessun utente disponibile',
},
applications: {
@ -60,10 +62,11 @@ const role_details = {
assign_title: 'Assegna applicazioni',
assign_subtitle:
'Assegna applicazioni a questo ruolo. Trova le applicazioni appropriate cercando nome, descrizione o ID app.',
assign_applications_field: 'Assegna applicazioni',
/** UNTRANSLATED */
assign_field: 'Assign applications',
confirm_assign: 'Assegna applicazioni',
applications_assigned:
'Le applicazioni selezionate sono state assegnate con successo a questo ruolo',
/** UNTRANSLATED */
assigned_toast_text: 'The selected applications were successfully assigned to this role',
empty: 'Nessuna applicazione disponibile',
},
};

View file

@ -42,9 +42,11 @@ const role_details = {
assign_title: 'ユーザーを割り当てる',
assign_subtitle:
'ユーザーをこのロールに割り当てます。名前、電子メール、電話、またはユーザーIDで検索して適切なユーザーを見つけます。',
assign_users_field: 'ユーザーを割り当てる',
/** UNTRANSLATED */
assign_field: 'Assign users',
confirm_assign: 'ユーザーを割り当てる',
users_assigned: '選択したユーザーは、このロールに正常に割り当てられました',
/** UNTRANSLATED */
assigned_toast_text: 'The selected users were successfully assigned to this role',
empty: '使用可能なユーザーはありません',
},
applications: {
@ -57,9 +59,11 @@ const role_details = {
assign_title: 'アプリケーションを割り当てる',
assign_subtitle:
'このロールにアプリケーションを割り当てます。名前、説明、またはアプリIDで検索して適切なアプリケーションを見つけます。',
assign_applications_field: 'アプリケーションを割り当てる',
/** UNTRANSLATED */
assign_field: 'Assign applications',
confirm_assign: 'アプリケーションを割り当てる',
applications_assigned: '選択したアプリケーションは、このロールに正常に割り当てられました',
/** UNTRANSLATED */
assigned_toast_text: 'The selected applications were successfully assigned to this role',
empty: '利用可能なアプリケーションはありません',
},
};

View file

@ -42,9 +42,11 @@ const role_details = {
assign_title: '사용자 할당',
assign_subtitle:
'사용자를 이 역할에 할당해요. 이름, 이메일, 전화번호, 사용자 ID 등을 이용하여 적절한 사용자를 찾아 보세요.',
assign_users_field: '사용자 할당',
/** UNTRANSLATED */
assign_field: 'Assign users',
confirm_assign: '사용자 할당',
users_assigned: '선택된 이용자들이 이 역할에 성공적으로 할당되었어요.',
/** UNTRANSLATED */
assigned_toast_text: 'The selected users were successfully assigned to this role',
empty: '사용자 없음',
},
applications: {
@ -56,9 +58,11 @@ const role_details = {
deleted: '{{name}} 이(가) 이 역할에서 성공적으로 제거되었습니다.',
assign_title: '앱 할당',
assign_subtitle: '이 역할에 앱 할당 적절한 앱을 이름, 설명 또는 앱 ID로 검색하여 찾아보세요.',
assign_applications_field: '앱 할당',
/** UNTRANSLATED */
assign_field: 'Assign applications',
confirm_assign: '앱 할당',
applications_assigned: '선택한 앱이이 역할에 성공적으로 할당되었습니다',
/** UNTRANSLATED */
assigned_toast_text: 'The selected applications were successfully assigned to this role',
empty: '사용 가능한 앱 없음',
},
};

View file

@ -43,9 +43,11 @@ const role_details = {
assign_title: 'Przydziel użytkowników',
assign_subtitle:
'Przydziel użytkowników do tej roli. Znajdź odpowiednich użytkowników, wyszukując po nazwie, adresie e-mail, numerze telefonu lub identyfikatorze użytkownika.',
assign_users_field: 'Przydziel użytkowników',
/** UNTRANSLATED */
assign_field: 'Assign users',
confirm_assign: 'Przydziel użytkowników',
users_assigned: 'Wybrani użytkownicy zostali pomyślnie przypisani do tej roli',
/** UNTRANSLATED */
assigned_toast_text: 'The selected users were successfully assigned to this role',
empty: 'Brak dostępnych użytkowników',
},
applications: {
@ -59,9 +61,11 @@ const role_details = {
assign_title: 'Przypisz aplikacje',
assign_subtitle:
'Przypisz aplikacje do tej roli. Znajdź odpowiednie aplikacje, wyszukując po nazwie, opisie lub identyfikatorze aplikacji.',
assign_applications_field: 'Przypisz aplikacje',
/** UNTRANSLATED */
assign_field: 'Assign applications',
confirm_assign: 'Przypisz aplikacje',
applications_assigned: 'Wybrane aplikacje zostały pomyślnie przypisane do tej roli',
/** UNTRANSLATED */
assigned_toast_text: 'The selected applications were successfully assigned to this role',
empty: 'Brak dostępnych aplikacji',
},
};

View file

@ -43,9 +43,11 @@ const role_details = {
assign_title: 'Atribuir usuários',
assign_subtitle:
'Atribuir usuários a este papel. Encontre usuários adequados pesquisando nome, e-mail, telefone ou ID do usuário.',
assign_users_field: 'Atribuir usuários',
/** UNTRANSLATED */
assign_field: 'Assign users',
confirm_assign: 'Atribuir usuários',
users_assigned: 'Os usuários selecionados foram atribuídos com sucesso a este papel',
/** UNTRANSLATED */
assigned_toast_text: 'The selected users were successfully assigned to this role',
empty: 'Nenhum usuário disponível',
},
applications: {
@ -59,9 +61,11 @@ const role_details = {
assign_title: 'Atribuir aplicativos',
assign_subtitle:
'Atribuir aplicativos a este papel. Encontre os aplicativos adequados pesquisando por nome, descrição ou ID do aplicativo.',
assign_applications_field: 'Atribuir aplicativos',
/** UNTRANSLATED */
assign_field: 'Assign applications',
confirm_assign: 'Atribuir aplicativos',
applications_assigned: 'As aplicações selecionadas foram atribuídas com sucesso a este papel',
/** UNTRANSLATED */
assigned_toast_text: 'The selected applications were successfully assigned to this role',
empty: 'Nenhum aplicativo disponível',
},
};

View file

@ -43,9 +43,11 @@ const role_details = {
assign_title: 'Atribuir utilizadores',
assign_subtitle:
'Atribua utilizadores a esta função. Encontre utilizadores apropriados pesquisando pelo nome, e-mail, telefone ou ID de utilizador.',
assign_users_field: 'Atribuir utilizadores',
/** UNTRANSLATED */
assign_field: 'Assign users',
confirm_assign: 'Atribuir utilizadores',
users_assigned: 'Os utilizadores selecionados foram atribuídos com sucesso a esta função',
/** UNTRANSLATED */
assigned_toast_text: 'The selected users were successfully assigned to this role',
empty: 'Nenhum utilizador disponível',
},
applications: {
@ -59,9 +61,11 @@ const role_details = {
assign_title: 'Atribuir aplicações',
assign_subtitle:
'Atribua aplicações a esta função. Encontre aplicações apropriadas pesquisando pelo nome, descrição ou ID da aplicação.',
assign_applications_field: 'Atribuir aplicações',
/** UNTRANSLATED */
assign_field: 'Assign applications',
confirm_assign: 'Atribuir aplicações',
applications_assigned: 'As aplicações selecionadas foram atribuídas com sucesso a esta função',
/** UNTRANSLATED */
assigned_toast_text: 'The selected applications were successfully assigned to this role',
empty: 'Nenhuma aplicação disponível',
},
};

View file

@ -43,9 +43,11 @@ const role_details = {
assign_title: 'Назначить пользователей',
assign_subtitle:
'Назначить пользователей на эту роль. Найдите подходящих пользователей, используя поиск по имени, электронной почте, номеру телефона или идентификатору пользователя.',
assign_users_field: 'Назначить пользователей',
/** UNTRANSLATED */
assign_field: 'Assign users',
confirm_assign: 'Назначить пользователей',
users_assigned: 'Выбранные пользователи были успешно назначены на эту роль',
/** UNTRANSLATED */
assigned_toast_text: 'The selected users were successfully assigned to this role',
empty: 'Нет доступных пользователей',
},
applications: {
@ -59,9 +61,11 @@ const role_details = {
assign_title: 'Назначить приложения',
assign_subtitle:
'Назначить приложения на эту роль. Найдите подходящие приложения, используя поиск по имени, описанию или идентификатору приложения.',
assign_applications_field: 'Назначить приложения',
/** UNTRANSLATED */
assign_field: 'Assign applications',
confirm_assign: 'Назначить приложения',
applications_assigned: 'Выбранные приложения были успешно назначены на эту роль',
/** UNTRANSLATED */
assigned_toast_text: 'The selected applications were successfully assigned to this role',
empty: 'Нет доступных приложений',
},
};

View file

@ -42,9 +42,11 @@ const role_details = {
assign_title: 'Kullanıcılar Ata',
assign_subtitle:
'Kullanıcıları bu role atayın. İsim, e-posta, telefon veya kullanıcı kimliği arayarak uygun kullanıcıları bulun.',
assign_users_field: 'Kullanıcıları Ata',
/** UNTRANSLATED */
assign_field: 'Assign users',
confirm_assign: 'Kullanıcıları Ata',
users_assigned: 'Seçilen kullanıcılar bu role başarıyla atandı',
/** UNTRANSLATED */
assigned_toast_text: 'The selected users were successfully assigned to this role',
empty: 'Mevcut kullanıcı yok',
},
applications: {
@ -58,9 +60,11 @@ const role_details = {
assign_title: 'Uygulamaları Ata',
assign_subtitle:
'Bu role uygulamaları atayın. İsim, açıklama veya uygulama kimliği arayarak uygun uygulamaları bulun.',
assign_applications_field: 'Uygulamaları Ata',
/** UNTRANSLATED */
assign_field: 'Assign applications',
confirm_assign: 'Uygulamaları Ata',
applications_assigned: 'Seçilen uygulamalar bu role başarıyla atandı',
/** UNTRANSLATED */
assigned_toast_text: 'The selected applications were successfully assigned to this role',
empty: 'Mevcut uygulama yok',
},
};

View file

@ -39,9 +39,11 @@ const role_details = {
deleted: '{{name}} 已成功从此角色中删除',
assign_title: '分配用户',
assign_subtitle: '将用户分配给此角色。通过搜索名称、电子邮件、电话或用户 ID 查找适当的用户。',
assign_users_field: '分配用户',
/** UNTRANSLATED */
assign_field: 'Assign users',
confirm_assign: '分配用户',
users_assigned: '所选的用户已成功分配给此角色',
/** UNTRANSLATED */
assigned_toast_text: 'The selected users were successfully assigned to this role',
empty: '无可用用户',
},
applications: {
@ -53,9 +55,11 @@ const role_details = {
deleted: '{{name}} 已成功从此角色中删除',
assign_title: '分配应用',
assign_subtitle: '将应用分配给此角色。通过搜索名称、描述或应用 ID 查找适当的应用。',
assign_applications_field: '分配应用',
/** UNTRANSLATED */
assign_field: 'Assign applications',
confirm_assign: '分配应用',
applications_assigned: '所选的应用已成功分配给此角色',
/** UNTRANSLATED */
assigned_toast_text: 'The selected applications were successfully assigned to this role',
empty: '无可用应用',
},
};

View file

@ -39,9 +39,11 @@ const role_details = {
deleted: '{{name}} 已成功從此角色中刪除',
assign_title: '分配用戶',
assign_subtitle: '將用戶分配給此角色。通過搜索名稱、電子郵件、電話或用戶 ID 查找適當的用戶。',
assign_users_field: '分配用戶',
/** UNTRANSLATED */
assign_field: 'Assign users',
confirm_assign: '分配用戶',
users_assigned: '所選的用戶已成功分配給此角色',
/** UNTRANSLATED */
assigned_toast_text: 'The selected users were successfully assigned to this role',
empty: '無可用用戶',
},
applications: {
@ -53,9 +55,11 @@ const role_details = {
deleted: '{{name}} 已成功從此角色中刪除',
assign_title: '分配應用',
assign_subtitle: '將應用分配給此角色。通過搜索名稱、描述或應用 ID 查找適當的應用。',
assign_applications_field: '分配應用',
/** UNTRANSLATED */
assign_field: 'Assign applications',
confirm_assign: '分配應用',
applications_assigned: '所選的應用已成功分配給此角色',
/** UNTRANSLATED */
assigned_toast_text: 'The selected applications were successfully assigned to this role',
empty: '無可用應用',
},
};

View file

@ -39,9 +39,11 @@ const role_details = {
deleted: '{{name}} 已成功從此角色中刪除',
assign_title: '分配用戶',
assign_subtitle: '將用戶分配給此角色。通過搜索名稱、電子郵件、電話或用戶 ID 尋找適當的用戶。',
assign_users_field: '分配用戶',
/** UNTRANSLATED */
assign_field: 'Assign users',
confirm_assign: '分配用戶',
users_assigned: '所選的用戶已成功分配給此角色',
/** UNTRANSLATED */
assigned_toast_text: 'The selected users were successfully assigned to this role',
empty: '無可用用戶',
},
applications: {
@ -53,9 +55,11 @@ const role_details = {
deleted: '{{name}} 已從此角色中成功刪除',
assign_title: '分配應用',
assign_subtitle: '將應用程式分配給此角色。通過搜索名稱、描述或應用程式 ID 尋找合適的應用程式。',
assign_applications_field: '分配應用',
/** UNTRANSLATED */
assign_field: 'Assign applications',
confirm_assign: '分配應用',
applications_assigned: '已成功將所選的應用程式分配給此角色',
/** UNTRANSLATED */
assigned_toast_text: 'The selected applications were successfully assigned to this role',
empty: '沒有可用的應用程式',
},
};