diff --git a/packages/console/src/components/RoleScopesTransfer/components/SourceScopesBox/index.tsx b/packages/console/src/components/RoleScopesTransfer/components/SourceScopesBox/index.tsx
index 5a622359a..5f56f0877 100644
--- a/packages/console/src/components/RoleScopesTransfer/components/SourceScopesBox/index.tsx
+++ b/packages/console/src/components/RoleScopesTransfer/components/SourceScopesBox/index.tsx
@@ -1,6 +1,7 @@
import type { ResourceResponse, Scope, ScopeResponse } from '@logto/schemas';
import { managementResourceScopeId } from '@logto/schemas';
import { conditional } from '@silverhand/essentials';
+import classNames from 'classnames';
import type { ChangeEvent } from 'react';
import { useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -119,6 +120,8 @@ const SourceScopesBox = ({ roleId, selectedScopes, onChange }: Props) => {
);
}, [keyword, resources]);
+ const isEmpty = !isLoading && !hasError && dataSource.length === 0;
+
return (
@@ -129,14 +132,15 @@ const SourceScopesBox = ({ roleId, selectedScopes, onChange }: Props) => {
onChange={handleSearchInput}
/>
-
- {!isLoading && !hasError && dataSource.length === 0 && (
+
+ {isEmpty ? (
- )}
- {dataSource.length > 0 &&
+ ) : (
dataSource.map((resource) => (
{
onSelectResource={onSelectResource}
onSelectScope={onSelectScope}
/>
- ))}
+ ))
+ )}
);
diff --git a/packages/console/src/components/RoleUsersTransfer/components/SourceUsersBox/index.tsx b/packages/console/src/components/RoleUsersTransfer/components/SourceUsersBox/index.tsx
index a26fd2132..e6b63832a 100644
--- a/packages/console/src/components/RoleUsersTransfer/components/SourceUsersBox/index.tsx
+++ b/packages/console/src/components/RoleUsersTransfer/components/SourceUsersBox/index.tsx
@@ -1,5 +1,6 @@
import type { User } from '@logto/schemas';
import { conditional } from '@silverhand/essentials';
+import classNames from 'classnames';
import type { ChangeEvent } from 'react';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
@@ -56,6 +57,8 @@ const SourceUsersBox = ({ roleId, selectedUsers, onChange }: Props) => {
const isUserAdded = (user: User) => selectedUsers.findIndex(({ id }) => id === user.id) >= 0;
+ const isEmpty = !isLoading && !error && dataSource.length === 0;
+
return (
@@ -66,11 +69,12 @@ const SourceUsersBox = ({ roleId, selectedUsers, onChange }: Props) => {
onChange={handleSearchInput}
/>
-
- {!isLoading && !error && dataSource.length === 0 && (
+
+ {isEmpty ? (
- )}
- {dataSource.length > 0 &&
+ ) : (
dataSource.map((user) => {
const isSelected = isUserAdded(user);
@@ -88,7 +92,8 @@ const SourceUsersBox = ({ roleId, selectedUsers, onChange }: Props) => {
}}
/>
);
- })}
+ })
+ )}
{
}, searchDelay);
};
+ const isEmpty = !isLoading && !error && dataSource.length === 0;
+
return (
@@ -67,11 +70,12 @@ const SourceRolesBox = ({ userId, selectedRoles, onChange }: Props) => {
onChange={handleSearchInput}
/>
-
- {!isLoading && !error && dataSource.length === 0 && (
+
+ {isEmpty ? (
- )}
- {dataSource.length > 0 &&
+ ) : (
dataSource.map((role) => {
const isSelected = isRoleSelected(role);
@@ -89,7 +93,8 @@ const SourceRolesBox = ({ userId, selectedRoles, onChange }: Props) => {
}}
/>
);
- })}
+ })
+ )}