mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-24 04:51:51 +00:00
refactor(ui): use const type for requirement labels
This commit is contained in:
@@ -13,7 +13,10 @@ import {
|
||||
import { accountDisplayLabel } from "../_lib/cross-account-adapter";
|
||||
import type { AccountStatusMap, CrossAccountAccountRef } from "../_types";
|
||||
|
||||
import { RequirementStatusSummary } from "./requirement-status-summary";
|
||||
import {
|
||||
REQUIREMENT_ENTITY_LABEL,
|
||||
RequirementStatusSummary,
|
||||
} from "./requirement-status-summary";
|
||||
|
||||
interface RequirementAccountChipsProps {
|
||||
accounts: AccountStatusMap;
|
||||
@@ -40,7 +43,7 @@ export const RequirementAccountChips = ({
|
||||
if (entries.length > MAX_INLINE_ACCOUNT_CHIPS) {
|
||||
return (
|
||||
<RequirementStatusSummary
|
||||
entityLabel="accounts"
|
||||
entityLabel={REQUIREMENT_ENTITY_LABEL.ACCOUNTS}
|
||||
entries={entries.map((account) => ({
|
||||
key: account.id,
|
||||
label: accountDisplayLabel(account),
|
||||
|
||||
@@ -30,6 +30,14 @@ const STATUS_ORDER: readonly CrossProviderStatus[] = ["FAIL", "MANUAL", "PASS"];
|
||||
|
||||
const SCROLLABLE_BREAKDOWN_MIN_ROWS = 13;
|
||||
|
||||
export const REQUIREMENT_ENTITY_LABEL = {
|
||||
ACCOUNTS: "accounts",
|
||||
PROVIDERS: "providers",
|
||||
} as const;
|
||||
|
||||
type RequirementEntityLabel =
|
||||
(typeof REQUIREMENT_ENTITY_LABEL)[keyof typeof REQUIREMENT_ENTITY_LABEL];
|
||||
|
||||
/**
|
||||
* Aggregated per-status counts for a requirement row whose column axis has
|
||||
* too many members to chip inline (many accounts of one provider type, or
|
||||
@@ -39,10 +47,10 @@ const SCROLLABLE_BREAKDOWN_MIN_ROWS = 13;
|
||||
*/
|
||||
export const RequirementStatusSummary = ({
|
||||
entries,
|
||||
entityLabel = "providers",
|
||||
entityLabel = REQUIREMENT_ENTITY_LABEL.PROVIDERS,
|
||||
}: {
|
||||
entries: RequirementStatusEntry[];
|
||||
entityLabel?: "accounts" | "providers";
|
||||
entityLabel?: RequirementEntityLabel;
|
||||
}) => {
|
||||
const counts = STATUS_ORDER.map((status) => ({
|
||||
status,
|
||||
|
||||
Reference in New Issue
Block a user