@@ -19,7 +19,6 @@ import {
1919} from "@lib/color" ;
2020import {
2121 usePermissions ,
22- useLocalStorage ,
2322 useRead ,
2423 useSetTitle ,
2524 useContainerPortsMap ,
@@ -28,20 +27,12 @@ import { cn } from "@lib/utils";
2827import { Types } from "komodo_client" ;
2928import { ChevronLeft , Clapperboard , Layers2 } from "lucide-react" ;
3029import { Link , useParams } from "react-router-dom" ;
31- import { StackServiceLogs } from "./log" ;
3230import { Button } from "@ui/button" ;
3331import { ExportButton } from "@components/export" ;
3432import { ContainerPortLink , DockerResourceLink } from "@components/util" ;
3533import { ResourceNotifications } from "@pages/resource-notifications" ;
3634import { Fragment } from "react/jsx-runtime" ;
37- import { ContainerTerminals } from "@components/terminal/container" ;
38- import { useServer } from "@components/resources/server" ;
39- import { StackServiceInspect } from "./inspect" ;
40- import { useMemo } from "react" ;
41- import {
42- MobileFriendlyTabsSelector ,
43- TabNoContent ,
44- } from "@ui/mobile-friendly-tabs" ;
35+ import { StackServiceTabs } from "./tabs" ;
4536
4637type IdServiceComponent = React . FC < { id : string ; service ?: string } > ;
4738
@@ -224,110 +215,3 @@ const StackServicePageInner = ({
224215 </ div >
225216 ) ;
226217} ;
227-
228- type StackServiceTabsView = "Log" | "Inspect" | "Terminals" ;
229-
230- const StackServiceTabs = ( {
231- stack,
232- service,
233- container_state,
234- } : {
235- stack : Types . StackListItem ;
236- service : string ;
237- container_state : Types . ContainerStateStatusEnum ;
238- } ) => {
239- const [ _view , setView ] = useLocalStorage < StackServiceTabsView > (
240- `stack-${ stack . id } -${ service } -tabs-v2` ,
241- "Log"
242- ) ;
243- const { specificLogs, specificInspect, specificTerminal } = usePermissions ( {
244- type : "Stack" ,
245- id : stack . id ,
246- } ) ;
247- const container_terminals_disabled =
248- useServer ( stack . info . server_id ) ?. info . container_terminals_disabled ?? true ;
249- const logDisabled =
250- ! specificLogs || container_state === Types . ContainerStateStatusEnum . Empty ;
251- const inspectDisabled =
252- ! specificInspect ||
253- container_state === Types . ContainerStateStatusEnum . Empty ;
254- const terminalDisabled =
255- ! specificTerminal ||
256- container_terminals_disabled ||
257- container_state !== Types . ContainerStateStatusEnum . Running ;
258- const view =
259- ( inspectDisabled && _view === "Inspect" ) ||
260- ( terminalDisabled && _view === "Terminals" )
261- ? "Log"
262- : _view ;
263-
264- const tabsNoContent = useMemo < TabNoContent < StackServiceTabsView > [ ] > (
265- ( ) => [
266- {
267- value : "Log" ,
268- hidden : ! specificLogs ,
269- disabled : logDisabled ,
270- } ,
271- {
272- value : "Inspect" ,
273- hidden : ! specificInspect ,
274- disabled : inspectDisabled ,
275- } ,
276- {
277- value : "Terminals" ,
278- hidden : ! specificTerminal ,
279- disabled : terminalDisabled ,
280- } ,
281- ] ,
282- [
283- specificLogs ,
284- logDisabled ,
285- specificInspect ,
286- inspectDisabled ,
287- specificTerminal ,
288- terminalDisabled ,
289- ]
290- ) ;
291-
292- const Selector = (
293- < MobileFriendlyTabsSelector
294- tabs = { tabsNoContent }
295- value = { view }
296- onValueChange = { setView as any }
297- tabsTriggerClassname = "w-[110px]"
298- />
299- ) ;
300-
301- const target : Types . TerminalTarget = useMemo (
302- ( ) => ( {
303- type : "Stack" ,
304- params : {
305- stack : stack . id ,
306- service,
307- } ,
308- } ) ,
309- [ stack . id , service ]
310- ) ;
311-
312- switch ( view ) {
313- case "Log" :
314- return (
315- < StackServiceLogs
316- id = { stack . id }
317- service = { service }
318- titleOther = { Selector }
319- disabled = { logDisabled }
320- />
321- ) ;
322- case "Inspect" :
323- return (
324- < StackServiceInspect
325- id = { stack . id }
326- service = { service }
327- titleOther = { Selector }
328- />
329- ) ;
330- case "Terminals" :
331- return < ContainerTerminals target = { target } titleOther = { Selector } /> ;
332- }
333- } ;
0 commit comments