diff --git a/frontend/packages/app/public/icons/Catalog.svg b/frontend/packages/app/public/icons/Catalog.svg new file mode 100644 index 0000000000..0641df52c6 --- /dev/null +++ b/frontend/packages/app/public/icons/Catalog.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/frontend/packages/core/src/flags.tsx b/frontend/packages/core/src/flags.tsx index 540134761d..ffc271eb84 100644 --- a/frontend/packages/core/src/flags.tsx +++ b/frontend/packages/core/src/flags.tsx @@ -72,10 +72,27 @@ interface SimpleFeatureFlagStateProps { children: React.ReactNode; } +interface SimpleFeatureEnabledProps { + /** The name of the feature flag to lookup */ + feature: string; +} + const FeatureOn = ({ children }: SimpleFeatureFlagStateProps) => <>{children}; const FeatureOff = ({ children }: SimpleFeatureFlagStateProps) => <>{children}; +const checkFeatureEnabled = ({ feature }: SimpleFeatureEnabledProps) => { + const cachedFlags = JSON.parse(sessionStorage.getItem("featureFlags")); + let featureEnabled = false; + + const flag = cachedFlags?.flags?.[feature]; + if (flag !== undefined) { + featureEnabled = flag.booleanValue; + } + + return featureEnabled; +}; + /** * A feature flag wrapper that evaluates a binary value of a specified flag to determine * if it's children should be shown. @@ -114,4 +131,11 @@ const SimpleFeatureFlag = ({ feature, children }: SimpleFeatureFlagProps) => { return <>{statefulChildren}; }; -export { FEATURE_FLAG_POLL_RATE, featureFlags, FeatureOff, FeatureOn, SimpleFeatureFlag }; +export { + FEATURE_FLAG_POLL_RATE, + featureFlags, + checkFeatureEnabled, + FeatureOff, + FeatureOn, + SimpleFeatureFlag, +}; diff --git a/frontend/packages/core/src/index.tsx b/frontend/packages/core/src/index.tsx index d221ca72a1..921c11e27d 100644 --- a/frontend/packages/core/src/index.tsx +++ b/frontend/packages/core/src/index.tsx @@ -22,7 +22,7 @@ export { } from "./Contexts"; export { Dialog, DialogActions, DialogContent } from "./dialog"; export * from "./Feedback"; -export { FeatureOff, FeatureOn, SimpleFeatureFlag } from "./flags"; +export { checkFeatureEnabled, FeatureOff, FeatureOn, SimpleFeatureFlag } from "./flags"; export { default as Grid } from "./grid"; export { AvatarIcon, StatusIcon } from "./icon"; export * from "./Input"; diff --git a/frontend/workflows/projectSelector/src/project-group.tsx b/frontend/workflows/projectSelector/src/project-group.tsx index 4c3e016751..0fca315a8e 100644 --- a/frontend/workflows/projectSelector/src/project-group.tsx +++ b/frontend/workflows/projectSelector/src/project-group.tsx @@ -1,5 +1,5 @@ import * as React from "react"; -import { Checkbox, Switch } from "@clutch-sh/core"; +import { Checkbox, checkFeatureEnabled, Switch } from "@clutch-sh/core"; import styled from "@emotion/styled"; import ChevronRightIcon from "@mui/icons-material/ChevronRight"; import ClearIcon from "@mui/icons-material/Clear"; @@ -139,6 +139,26 @@ const ProjectGroup: React.FC = ({ title, group, displayToggle const numProjects = groupKeys.length; const checkedProjects = groupKeys.filter(k => state?.[group][k].checked); + const additionalQuickLinks = (key: string) => { + const links: any[] = []; + + if (checkFeatureEnabled({ feature: "projectCatalog" })) { + links.push({ + name: "Project Catalog", + links: [ + { + name: "Project Catalog", + trackingId: "dash-project-catalog", + url: `/catalog/${key}`, + }, + ], + imagePath: "/icons/Catalog.svg", + }); + } + + return links; + }; + // We need to keep track of which project has its quick links open so that we know // to hide the other projects' buttons const [quickLinksWindowKey, setQuickLinksWindowKey] = React.useState(""); @@ -235,7 +255,10 @@ const ProjectGroup: React.FC = ({ title, group, displayToggle {!state?.loading && state?.projectData?.[key]?.linkGroups && ( onOpenQuickLinks(key)} onClose={onCloseQuickLinks} showOpenButton={quickLinksWindowKey !== key}