forked from baron/baron-sso
userfront e2e 전체 테스트
This commit is contained in:
@@ -90,6 +90,8 @@ const MEMBER_COLUMN_GAP = 8;
|
||||
const HEADER_HEIGHT = 42;
|
||||
const MEMBER_ROW_HEIGHT = 24;
|
||||
const NODE_PADDING_Y = 12;
|
||||
const MEMBER_GRID_TARGET_ASPECT_RATIO = 2;
|
||||
const MAX_MEMBER_COLUMN_COUNT = 8;
|
||||
const ROOT_GAP_X = 120;
|
||||
const CHILD_GAP_Y = 96;
|
||||
const SIBLING_GAP_X = 80;
|
||||
@@ -155,15 +157,52 @@ function getRankWeight(
|
||||
return (isLeader ? -100 : 0) + (order === -1 ? 99 : order);
|
||||
}
|
||||
|
||||
export function getMemberGridMetrics(memberCount: number) {
|
||||
if (memberCount <= 0) return { columnCount: 1, rowCount: 1 };
|
||||
|
||||
const maxColumnCount = Math.min(
|
||||
MAX_MEMBER_COLUMN_COUNT,
|
||||
Math.max(1, memberCount),
|
||||
);
|
||||
let best = { columnCount: 1, rowCount: memberCount };
|
||||
let bestScore = Number.POSITIVE_INFINITY;
|
||||
|
||||
for (let columnCount = 1; columnCount <= maxColumnCount; columnCount += 1) {
|
||||
const rowCount = Math.ceil(memberCount / columnCount);
|
||||
const width =
|
||||
columnCount <= 1
|
||||
? NODE_WIDTH
|
||||
: Math.max(
|
||||
NODE_WIDTH,
|
||||
NODE_PADDING_Y * 2 +
|
||||
columnCount * MEMBER_COLUMN_WIDTH +
|
||||
(columnCount - 1) * MEMBER_COLUMN_GAP,
|
||||
);
|
||||
const height =
|
||||
HEADER_HEIGHT + NODE_PADDING_Y * 2 + rowCount * MEMBER_ROW_HEIGHT;
|
||||
const aspectRatio = width / height;
|
||||
const score = Math.abs(
|
||||
Math.log(aspectRatio / MEMBER_GRID_TARGET_ASPECT_RATIO),
|
||||
);
|
||||
|
||||
if (
|
||||
score < bestScore ||
|
||||
(score === bestScore && rowCount < best.rowCount)
|
||||
) {
|
||||
best = { columnCount, rowCount };
|
||||
bestScore = score;
|
||||
}
|
||||
}
|
||||
|
||||
return best;
|
||||
}
|
||||
|
||||
function getMemberColumnCount(memberCount: number) {
|
||||
return memberCount > 5 ? Math.floor(memberCount / 5) + 1 : 1;
|
||||
return getMemberGridMetrics(memberCount).columnCount;
|
||||
}
|
||||
|
||||
function getMemberRowCount(memberCount: number) {
|
||||
return Math.max(
|
||||
1,
|
||||
Math.ceil(memberCount / getMemberColumnCount(memberCount)),
|
||||
);
|
||||
return getMemberGridMetrics(memberCount).rowCount;
|
||||
}
|
||||
|
||||
function getNodeWidth(members: UserSummary[]) {
|
||||
@@ -1048,9 +1087,9 @@ function getOrgSelectionLabel(
|
||||
?.name;
|
||||
}
|
||||
|
||||
function filterSystemGlobalTenants(
|
||||
export function filterSystemGlobalTenants(
|
||||
tenants: TenantSummary[],
|
||||
visibilityMode: "internal" | "public" = "internal",
|
||||
_visibilityMode: "internal" | "public" = "public",
|
||||
) {
|
||||
const excludedIds = new Set(
|
||||
tenants.filter(isSystemGlobalTenant).map((tenant) => tenant.id),
|
||||
@@ -1074,7 +1113,7 @@ function filterSystemGlobalTenants(
|
||||
const filtered = tenants.filter(
|
||||
(tenant) => !excludedIds.has(tenant.id) && isOrgFrontTenantType(tenant),
|
||||
);
|
||||
return filterTenantsByVisibility(filtered, visibilityMode);
|
||||
return filterTenantsByVisibility(filtered, "public");
|
||||
}
|
||||
|
||||
type TenantIndexes = {
|
||||
|
||||
Reference in New Issue
Block a user