feat: expand advanced widget experiences
This commit is contained in:
1 parent
55226842f9
commit
65a7e84bea
137 files changed
+3684
-850
No files matched your search
@@ -1,3 +1,5 @@
|
||||
import type { PatchMonStatKey } from "./stat-colors";
|
||||
|
||||
const gridColsByWidth = [
|
||||
{ minWidth: 500, cols: 4 },
|
||||
{ minWidth: 380, cols: 3 },
|
||||
@@ -5,6 +7,26 @@ const gridColsByWidth = [
|
||||
{ minWidth: 0, cols: 1 },
|
||||
] as const;
|
||||
|
||||
const statVisibilityByOption = [
|
||||
["showTotalHosts", "totalHosts"],
|
||||
["showHostsNeedingUpdates", "hostsNeedingUpdates"],
|
||||
["showSecurityUpdates", "securityUpdates"],
|
||||
["showUpToDateHosts", "upToDateHosts"],
|
||||
["showHostsWithSecurityUpdates", "hostsWithSecurityUpdates"],
|
||||
["showRecentUpdates24h", "recentUpdates24h"],
|
||||
["showTotalOutdatedPackages", "totalOutdatedPackages"],
|
||||
["showTotalRepos", "totalRepos"],
|
||||
] as const satisfies readonly (readonly [string, PatchMonStatKey])[];
|
||||
|
||||
type PatchMonStatVisibilityOptions = Partial<Record<(typeof statVisibilityByOption)[number][0], boolean>>;
|
||||
|
||||
export function getVisiblePatchMonStatKeys(
|
||||
options: PatchMonStatVisibilityOptions,
|
||||
isAdvanced: boolean,
|
||||
): PatchMonStatKey[] {
|
||||
return statVisibilityByOption.filter(([optionKey]) => isAdvanced || options[optionKey]).map(([, statKey]) => statKey);
|
||||
}
|
||||
|
||||
export function getGridCols(width: number): number {
|
||||
const match = gridColsByWidth.find(({ minWidth }) => width >= minWidth);
|
||||
return match?.cols ?? 1;
|
||||
|
||||
Reference in new issue
Block a user