diff --git a/frontend/src/components/resources/build/tabs.tsx b/frontend/src/components/resources/build/tabs.tsx index adada7255..d5171ddc6 100644 --- a/frontend/src/components/resources/build/tabs.tsx +++ b/frontend/src/components/resources/build/tabs.tsx @@ -10,8 +10,10 @@ import { ResourceComponents } from ".."; import { DeploymentTable } from "../deployment/table"; import { BuildConfig } from "./config"; +type BuildTabsView = "Config" | "Info" | "Deployments"; + export const BuildTabs = ({ id }: { id: string }) => { - const [view, setView] = useLocalStorage<"Config" | "Info" | "Deployments">( + const [view, setView] = useLocalStorage( "build-tabs-v1", "Config" ); @@ -20,7 +22,7 @@ export const BuildTabs = ({ id }: { id: string }) => { ); const deploymentsDisabled = (deployments?.length || 0) === 0; - const tabsNoContent = useMemo( + const tabsNoContent = useMemo[]>( () => [ { value: "Config", @@ -46,6 +48,8 @@ export const BuildTabs = ({ id }: { id: string }) => { ); switch (view) { + case "Config": + return ; case "Info": return ; case "Deployments": @@ -57,7 +61,5 @@ export const BuildTabs = ({ id }: { id: string }) => { ); - default: - return ; } }; diff --git a/frontend/src/components/resources/deployment/tabs.tsx b/frontend/src/components/resources/deployment/tabs.tsx index fd94c99db..b8b8184d7 100644 --- a/frontend/src/components/resources/deployment/tabs.tsx +++ b/frontend/src/components/resources/deployment/tabs.tsx @@ -18,14 +18,17 @@ export const DeploymentTabs = ({ id }: { id: string }) => { return ; }; +type DeploymentTabsView = "Config" | "Log" | "Inspect" | "Terminal"; + const DeploymentTabsInner = ({ deployment, }: { deployment: Types.DeploymentListItem; }) => { - const [_view, setView] = useLocalStorage< - "Config" | "Log" | "Inspect" | "Terminal" - >("deployment-tabs-v1", "Config"); + const [_view, setView] = useLocalStorage( + "deployment-tabs-v1", + "Config" + ); const { specificLogs, specificInspect, specificTerminal } = usePermissions({ type: "Deployment", id: deployment.id, @@ -55,7 +58,7 @@ const DeploymentTabsInner = ({ ? "Config" : _view; - const tabsNoContent = useMemo( + const tabsNoContent = useMemo[]>( () => [ { value: "Config", @@ -109,13 +112,13 @@ const DeploymentTabsInner = ({ ); switch (view) { + case "Config": + return ; case "Log": return ; case "Inspect": return ; case "Terminal": return ; - default: - return ; } }; diff --git a/frontend/src/components/resources/server/info/index.tsx b/frontend/src/components/resources/server/info/index.tsx index 930e92c67..dfa0dcc45 100644 --- a/frontend/src/components/resources/server/info/index.tsx +++ b/frontend/src/components/resources/server/info/index.tsx @@ -38,7 +38,7 @@ export const ServerInfo = ({ ); } - const tabsNoContent = useMemo( + const tabsNoContent = useMemo[]>( () => [ { value: "Containers", diff --git a/frontend/src/components/resources/server/tabs.tsx b/frontend/src/components/resources/server/tabs.tsx index ed86ce527..3307ee8b5 100644 --- a/frontend/src/components/resources/server/tabs.tsx +++ b/frontend/src/components/resources/server/tabs.tsx @@ -48,7 +48,7 @@ export const ServerTabs = ({ id }: { id: string }) => { const noResources = noDeployments && noRepos && noStacks; - const tabsNoContent = useMemo( + const tabsNoContent = useMemo[]>( () => [ { value: "Config", @@ -88,6 +88,8 @@ export const ServerTabs = ({ id }: { id: string }) => { ); switch (view) { + case "Config": + return ; case "Stats": return ; case "Docker": @@ -96,8 +98,6 @@ export const ServerTabs = ({ id }: { id: string }) => { return ; case "Terminals": return ; - default: - return ; } }; diff --git a/frontend/src/components/resources/stack/tabs.tsx b/frontend/src/components/resources/stack/tabs.tsx index f9d6e09c1..067a22944 100644 --- a/frontend/src/components/resources/stack/tabs.tsx +++ b/frontend/src/components/resources/stack/tabs.tsx @@ -11,10 +11,13 @@ import { StackServices } from "./services"; import { StackLogs } from "./log"; import { StackConfig } from "./config"; +type StackTabsView = "Config" | "Info" | "Services" | "Log"; + export const StackTabs = ({ id }: { id: string }) => { - const [_view, setView] = useLocalStorage< - "Config" | "Info" | "Services" | "Log" - >("stack-tabs-v1", "Config"); + const [_view, setView] = useLocalStorage( + "stack-tabs-v1", + "Config" + ); const info = useStack(id)?.info; const { specific, specificLogs } = usePermissions({ type: "Stack", id }); @@ -34,7 +37,7 @@ export const StackTabs = ({ id }: { id: string }) => { ? "Config" : _view; - const tabsNoContent = useMemo( + const tabsNoContent = useMemo[]>( () => [ { value: "Config", @@ -44,7 +47,7 @@ export const StackTabs = ({ id }: { id: string }) => { hidden: hideInfo, }, { - value: "Service", + value: "Services", disabled: hideServices, }, { @@ -66,13 +69,13 @@ export const StackTabs = ({ id }: { id: string }) => { ); switch (view) { + case "Config": + return ; case "Info": return ; case "Services": return ; case "Log": return ; - default: - return ; } }; diff --git a/frontend/src/components/resources/sync/tabs.tsx b/frontend/src/components/resources/sync/tabs.tsx index 40a2623ec..7a0b935a1 100644 --- a/frontend/src/components/resources/sync/tabs.tsx +++ b/frontend/src/components/resources/sync/tabs.tsx @@ -14,7 +14,7 @@ import { ResourceSyncConfig } from "./config"; type ResourceSyncTabsView = "Config" | "Info" | "Execute" | "Commit"; const syncTabsViewAtom = atomWithStorage( - "sync-tabs-v4", + "sync-tabs-v5", "Config" ); @@ -58,7 +58,7 @@ export const SyncTabs = ({ id }: { id: string }) => { const { view, setView, hideInfo, showPending } = useResourceSyncTabsView(sync); - const tabsNoContent = useMemo( + const tabsNoContent = useMemo[]>( () => [ { value: "Config", @@ -90,13 +90,13 @@ export const SyncTabs = ({ id }: { id: string }) => { ); switch (view) { + case "Config": + return ; case "Info": return ; case "Execute": return ; case "Commit": return ; - default: - return ; } }; diff --git a/frontend/src/pages/server-info/container/index.tsx b/frontend/src/pages/server-info/container/index.tsx index 7d8646c70..29e8a6dc3 100644 --- a/frontend/src/pages/server-info/container/index.tsx +++ b/frontend/src/pages/server-info/container/index.tsx @@ -249,7 +249,7 @@ const ContainerTabs = ({ ? "Log" : _view; - const tabsNoContent = useMemo( + const tabsNoContent = useMemo[]>( () => [ { value: "Log", diff --git a/frontend/src/pages/stack-service/index.tsx b/frontend/src/pages/stack-service/index.tsx index 95b4344c7..e3c20975a 100644 --- a/frontend/src/pages/stack-service/index.tsx +++ b/frontend/src/pages/stack-service/index.tsx @@ -261,7 +261,7 @@ const StackServiceTabs = ({ ? "Log" : _view; - const tabsNoContent = useMemo( + const tabsNoContent = useMemo[]>( () => [ { value: "Log", diff --git a/frontend/src/ui/mobile-friendly-tabs.tsx b/frontend/src/ui/mobile-friendly-tabs.tsx index 3eeacd8c0..276f69c9a 100644 --- a/frontend/src/ui/mobile-friendly-tabs.tsx +++ b/frontend/src/ui/mobile-friendly-tabs.tsx @@ -9,21 +9,24 @@ import { } from "./select"; import { cn } from "@lib/utils"; -export type Tab = { +export type Tab = { label?: string; hidden?: boolean; disabled?: boolean; - value: string; + value: Value; content: ReactNode; }; -export type TabNoContent = Omit; +export type TabNoContent = Omit< + Tab, + "content" +>; -export const MobileFriendlyTabs = (props: { - tabs: Tab[]; +export const MobileFriendlyTabs = (props: { + tabs: Tab[]; actions?: ReactNode; - value: string; - onValueChange: (value: string) => void; + value: Value; + onValueChange: (value: Value) => void; }) => { return ( ({ Selector, tabs, value, className, }: { Selector: ReactNode; - tabs: Tab[]; - value: string; + tabs: Tab[]; + value: Value; className?: string; }) => { return ( @@ -53,24 +56,24 @@ export const MobileFriendlyTabsWrapper = ({ ); }; -export const MobileFriendlyTabsSelector = ({ +export const MobileFriendlyTabsSelector = ({ tabs: _tabs, actions, value, onValueChange, tabsTriggerClassname, }: { - tabs: TabNoContent[]; + tabs: TabNoContent[]; actions?: ReactNode; - value: string; - onValueChange: (value: string) => void; + value: Value; + onValueChange: (value: Value) => void; tabsTriggerClassname?: string; }) => { const tabs = _tabs.filter((t) => !t.hidden); return ( <>
- + {tabs.map((tab) => ( ({ tabs, value, }: { tabs: Tab[]; - value: string; + value: Value; }) => { return tabs.find((tab) => tab.value === value)?.content; };