diff --git a/web/dashboard-ui/src/views/pages/WorkspacePage.tsx b/web/dashboard-ui/src/views/pages/WorkspacePage.tsx index 71fe22a7..c2cd37db 100644 --- a/web/dashboard-ui/src/views/pages/WorkspacePage.tsx +++ b/web/dashboard-ui/src/views/pages/WorkspacePage.tsx @@ -22,6 +22,8 @@ import { SearchTwoTone, StopCircleOutlined, StopCircleTwoTone, + UnfoldLessOutlined, + UnfoldMoreOutlined, WebTwoTone, } from "@mui/icons-material"; import { @@ -360,7 +362,10 @@ const NetworkRuleList: React.FC<{ workspace: Workspace }> = ({ workspace }) => { upsertDialogDispatch(true, { workspace: workspace, networkRule: networkRule, - defaultOpenHttpOptions: true, + defaultOpenHttpOptions: + (networkRule.customHostPrefix !== "" && + networkRule.customHostPrefix !== "main") || + networkRule.httpPath !== "/", index: index, isMain: networkRule.url == workspace.status?.mainUrl, @@ -396,10 +401,32 @@ const NetworkRuleList: React.FC<{ workspace: Workspace }> = ({ workspace }) => { const WorkspaceItem: React.VFC<{ workspace: WorkspaceWrapper; events: Event[]; -}> = ({ workspace: ws, events }) => { + defaultExpandState?: { + networkRule?: boolean; + event?: boolean; + }; + expandState?: { + networkRule?: boolean; + event?: boolean; + }; +}> = ({ workspace: ws, events, defaultExpandState, expandState }) => { console.log("WorkspaceItem", ws.status?.phase, ws.spec?.replicas); - const [networkRuleExpanded, setNetworkRuleExpanded] = useState(false); - const [eventExpanded, setEventExpanded] = useState(false); + const [networkRuleExpanded, setNetworkRuleExpanded] = useState( + defaultExpandState?.networkRule || false + ); + const [eventExpanded, setEventExpanded] = useState( + defaultExpandState?.event || false + ); + if ( + expandState?.networkRule !== undefined && + networkRuleExpanded !== expandState.networkRule + ) { + setNetworkRuleExpanded(expandState.networkRule); + } + if (expandState?.event !== undefined && eventExpanded !== expandState.event) { + setEventExpanded(expandState.event); + } + const { clock } = useLogin(); const theme = useTheme(); @@ -540,6 +567,24 @@ const WorkspaceList: React.VFC = () => { const [isSearchFocused, setIsSearchFocused] = useState(false); const [isLoading, setIsLoading] = useState(false); const [isHoverRefreshIcon, setIsHoverRefreshIcon] = useState(false); + + const [expandState, setExpandState] = useState<{ + currentState: boolean | undefined; + beforeState: boolean | undefined; + }>({ currentState: undefined, beforeState: true }); + const changeExpandState = (state: boolean) => { + setExpandState((prev) => { + return { currentState: state, beforeState: prev.currentState }; + }); + setTimeout( + () => + setExpandState((prev) => { + return { currentState: undefined, beforeState: prev.currentState }; + }), + 500 + ); + }; + const createDialogDisptch = WorkspaceCreateDialogContext.useDispatch(); const theme = useTheme(); @@ -595,6 +640,30 @@ const WorkspaceList: React.VFC = () => { (isUpSM || (!isSearchFocused && urlParam.search === "")) && ( )} + {isUpSM && + (expandState.beforeState === true ? ( + + + changeExpandState(false)} + disabled={expandState.beforeState === undefined} + > + + + + + ) : ( + + + changeExpandState(true)} + disabled={expandState.beforeState === undefined} + > + + + + + ))} { a.ownerName !== b.ownerName ? 1 : a.name < b.name ? -1 : 1 ) .map((ws) => ( - + ))}