From 2ff29b173b27f3d35546e0824e4fc35e768baaf5 Mon Sep 17 00:00:00 2001 From: Denise Li Date: Tue, 29 Oct 2024 18:55:47 -0400 Subject: [PATCH] feat: hide unexported decls in console by default and provide a toggle to show (#3236) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Part 1 of https://github.com/TBD54566975/ftl/issues/3219 https://github.com/user-attachments/assets/5cb024af-4d59-4a6a-b7ca-678ad1001fed Screenshot 2024-10-29 at 4 37 48 PM --- frontend/console/e2e/helpers.ts | 4 ++ .../src/features/modules/ModulesTree.tsx | 44 ++++++++++++++----- .../src/features/modules/module.utils.ts | 6 +++ 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/frontend/console/e2e/helpers.ts b/frontend/console/e2e/helpers.ts index d4de948707..344ace0e99 100644 --- a/frontend/console/e2e/helpers.ts +++ b/frontend/console/e2e/helpers.ts @@ -15,6 +15,10 @@ export async function navigateToModule(page: Page, moduleName: string) { export async function navigateToDecl(page: Page, moduleName: string, declName: string) { await navigateToModule(page, moduleName) + // Some decls are hidden by default because they are not exported, so click + // the toggle to make them visible. + await page.locator('#hide-exported').click() + // Navigate to the decl page await page.locator(`a#decl-${declName}`).click() await expect(page).toHaveURL(new RegExp(`/modules/${moduleName}/verb/${declName}`)) diff --git a/frontend/console/src/features/modules/ModulesTree.tsx b/frontend/console/src/features/modules/ModulesTree.tsx index 192b50b6e8..8c03caeb56 100644 --- a/frontend/console/src/features/modules/ModulesTree.tsx +++ b/frontend/console/src/features/modules/ModulesTree.tsx @@ -1,4 +1,4 @@ -import { ArrowRight01Icon, ArrowShrink02Icon, CircleArrowRight02Icon, FileExportIcon, PackageIcon } from 'hugeicons-react' +import { ArrowRight01Icon, ArrowShrink02Icon, CircleArrowRight02Icon, PackageIcon, Upload01Icon } from 'hugeicons-react' import { useEffect, useMemo, useRef, useState } from 'react' import { Link, useParams, useSearchParams } from 'react-router-dom' import { Multiselect, sortMultiselectOpts } from '../../components/Multiselect' @@ -12,17 +12,14 @@ import { declIcon, declSumTypeIsExported, declUrlFromInfo, + getHideUnexportedFromLocalStorage, + hasHideUnexportedInLocalStorage, listExpandedModulesFromLocalStorage, + setHideUnexportedFromLocalStorage, toggleModuleExpansionInLocalStorage, } from './module.utils' import { declTypeMultiselectOpts } from './schema/schema.utils' -const ExportedIcon = () => ( - - - -) - const DeclNode = ({ decl, href, isSelected }: { decl: DeclInfo; href: string; isSelected: boolean }) => { const declRef = useRef(null) @@ -45,12 +42,12 @@ const DeclNode = ({ decl, href, isSelected }: { decl: DeclInfo; href: string; is ref={declRef} className={classNames( isSelected ? 'bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 hover:dark:bg-gray-600' : 'hover:bg-gray-200 hover:dark:bg-gray-700', + declSumTypeIsExported(decl.value) ? '' : 'text-gray-400 dark:text-gray-500', 'group flex items-center gap-x-2 pl-4 pr-2 text-sm font-light leading-6 w-full cursor-pointer scroll-mt-10', )} >