forked from baron/baron-sso
chore: snapshot local state before dev merge
This commit is contained in:
@@ -97,7 +97,7 @@ import {
|
||||
updateUser,
|
||||
} from "../../lib/adminApi";
|
||||
import { t } from "../../lib/i18n";
|
||||
import { isSuperAdminRole, normalizeAdminRole } from "../../lib/roles";
|
||||
import { normalizeAdminRole } from "../../lib/roles";
|
||||
import {
|
||||
downloadUserTemplate,
|
||||
UserBulkUploadModal,
|
||||
@@ -121,7 +121,7 @@ type UserSortKey = string;
|
||||
const USER_ROW_ESTIMATED_HEIGHT = 64;
|
||||
const USER_ROW_OVERSCAN = 2;
|
||||
const USER_TABLE_VIEWPORT_ESTIMATED_HEIGHT = 640;
|
||||
const userFixedColumnWidths = [48, 160, 220, 160, 260, 170, 160, 220] as const;
|
||||
const userFixedColumnWidths = [48, 160, 220, 160, 260, 170, 220] as const;
|
||||
const userMetadataColumnWidth = 160;
|
||||
const userCreatedColumnWidth = 150;
|
||||
type UserRowVirtualizer = Virtualizer<HTMLDivElement, HTMLTableRowElement>;
|
||||
@@ -135,23 +135,6 @@ const userSortableTableHeadContentClassName = "h-full items-center";
|
||||
const userTableStateCellClassName =
|
||||
"flex h-24 items-center justify-center p-0 text-center text-sm text-muted-foreground";
|
||||
|
||||
const bulkPermissionOptions = [
|
||||
{
|
||||
value: "super_admin",
|
||||
labelKey: "ui.admin.role.super_admin",
|
||||
fallback: "시스템 관리자",
|
||||
},
|
||||
{
|
||||
value: "user",
|
||||
labelKey: "ui.admin.role.user",
|
||||
fallback: "일반 사용자",
|
||||
},
|
||||
] as const;
|
||||
|
||||
function assignableSystemRoleValue(role?: string | null) {
|
||||
return isSuperAdminRole(role) ? "super_admin" : "user";
|
||||
}
|
||||
|
||||
type RepresentativeTenantCandidate = {
|
||||
id?: string;
|
||||
slug?: string;
|
||||
@@ -370,8 +353,6 @@ function UserListPage() {
|
||||
const [selectedBulkStatus, setSelectedBulkStatus] = React.useState<
|
||||
UserStatusValue | ""
|
||||
>("");
|
||||
const [selectedBulkPermission, setSelectedBulkPermission] =
|
||||
React.useState("");
|
||||
const [sortConfig, setSortConfig] =
|
||||
React.useState<SortConfig<UserSortKey> | null>(null);
|
||||
const [bulkUploadOpen, setBulkUploadOpen] = React.useState(false);
|
||||
@@ -604,7 +585,7 @@ function UserListPage() {
|
||||
]);
|
||||
|
||||
const shouldVirtualizeRows = !query.isLoading && items.length > 0;
|
||||
const tableColumnCount = 9 + visibleUserSchemaFields.length;
|
||||
const tableColumnCount = 8 + visibleUserSchemaFields.length;
|
||||
|
||||
const requestSort = (key: UserSortKey) => {
|
||||
setSortConfig((current) => toggleSort(current, key));
|
||||
@@ -622,8 +603,6 @@ function UserListPage() {
|
||||
};
|
||||
|
||||
const total = query.data?.pages[0]?.total ?? 0;
|
||||
const canPromoteSuperAdmin = isSuperAdminRole(profile?.role);
|
||||
|
||||
const toggleSelectAll = () => {
|
||||
if (selectedUserIds.length === items.length) {
|
||||
setSelectedUserIds([]);
|
||||
@@ -673,7 +652,6 @@ function UserListPage() {
|
||||
query.refetch();
|
||||
setSelectedUserIds([]);
|
||||
setSelectedBulkStatus("");
|
||||
setSelectedBulkPermission("");
|
||||
toast.success(
|
||||
t(
|
||||
"msg.admin.users.bulk.update_success",
|
||||
@@ -691,14 +669,6 @@ function UserListPage() {
|
||||
});
|
||||
};
|
||||
|
||||
const _handleApplyBulkPermission = () => {
|
||||
if (selectedUserIds.length === 0 || !selectedBulkPermission) return;
|
||||
bulkUpdateMutation.mutate({
|
||||
userIds: selectedUserIds,
|
||||
role: selectedBulkPermission,
|
||||
});
|
||||
};
|
||||
|
||||
const handleBulkDelete = () => {
|
||||
if (selectedUserIds.length === 0) return;
|
||||
if (
|
||||
@@ -1005,15 +975,6 @@ function UserListPage() {
|
||||
{getSortIcon("status")}
|
||||
</div>
|
||||
</TableHead>
|
||||
<TableHead
|
||||
className={userTableHeadInteractiveClassName}
|
||||
onClick={() => requestSort("role")}
|
||||
>
|
||||
<div className={userTableHeadContentClassName}>
|
||||
{t("ui.admin.users.list.table.role", "ROLE")}
|
||||
{getSortIcon("role")}
|
||||
</div>
|
||||
</TableHead>
|
||||
<TableHead
|
||||
className={userTableHeadInteractiveClassName}
|
||||
onClick={() => requestSort("tenant_dept")}
|
||||
@@ -1206,36 +1167,6 @@ function UserListPage() {
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<Select
|
||||
value={assignableSystemRoleValue(user.role)}
|
||||
onValueChange={(value) =>
|
||||
bulkUpdateMutation.mutate({
|
||||
userIds: [user.id],
|
||||
role: value,
|
||||
})
|
||||
}
|
||||
disabled={
|
||||
bulkUpdateMutation.isPending ||
|
||||
!isSuperAdminRole(profile?.role) ||
|
||||
user.id === profile?.id
|
||||
}
|
||||
>
|
||||
<SelectTrigger className="h-8 w-[140px] border-none bg-transparent hover:bg-muted/50 transition-colors px-0 font-medium">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{bulkPermissionOptions.map((option) => (
|
||||
<SelectItem
|
||||
key={option.value}
|
||||
value={option.value}
|
||||
>
|
||||
{t(option.labelKey, option.fallback)}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-sm font-medium">
|
||||
@@ -1302,31 +1233,6 @@ function UserListPage() {
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
{canPromoteSuperAdmin && (
|
||||
<Select
|
||||
value={selectedBulkPermission}
|
||||
onValueChange={setSelectedBulkPermission}
|
||||
>
|
||||
<SelectTrigger
|
||||
className="h-8 w-[120px] bg-transparent border-background/20 text-background text-xs"
|
||||
data-testid="bulk-permission-select"
|
||||
>
|
||||
<SelectValue
|
||||
placeholder={t(
|
||||
"ui.admin.users.bulk.permission_placeholder",
|
||||
"권한 선택",
|
||||
)}
|
||||
/>
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{bulkPermissionOptions.map((option) => (
|
||||
<SelectItem key={option.value} value={option.value}>
|
||||
{t(option.labelKey, option.fallback)}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
)}
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
@@ -1335,25 +1241,18 @@ function UserListPage() {
|
||||
const payload: {
|
||||
userIds: string[];
|
||||
status?: UserStatusValue;
|
||||
role?: string;
|
||||
} = { userIds: selectedUserIds };
|
||||
let hasChanges = false;
|
||||
if (selectedBulkStatus) {
|
||||
payload.status = selectedBulkStatus;
|
||||
hasChanges = true;
|
||||
}
|
||||
if (selectedBulkPermission && canPromoteSuperAdmin) {
|
||||
payload.role = selectedBulkPermission;
|
||||
hasChanges = true;
|
||||
}
|
||||
if (hasChanges) {
|
||||
bulkUpdateMutation.mutate(payload);
|
||||
}
|
||||
}}
|
||||
disabled={
|
||||
(!selectedBulkStatus && !selectedBulkPermission) ||
|
||||
bulkUpdateMutation.isPending ||
|
||||
!isWritable
|
||||
!selectedBulkStatus || bulkUpdateMutation.isPending || !isWritable
|
||||
}
|
||||
data-testid="bulk-apply-btn"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user