Skip to content

Commit 26812f3

Browse files
committed
fix create compute server option to account for tabs
1 parent abcd0d5 commit 26812f3

File tree

5 files changed

+33
-14
lines changed

5 files changed

+33
-14
lines changed

src/packages/frontend/compute/select-server.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,9 @@ export default function SelectServer({
241241
label: (
242242
<div
243243
onClick={() => {
244-
const actions = redux.getProjectActions(project_id);
245-
if (actions != null) {
246-
actions.setState({ create_compute_server: true });
247-
actions.set_active_tab("servers", {
248-
change_history: true,
249-
});
250-
}
244+
redux
245+
.getProjectActions(project_id)
246+
?.createComputeServerDialog();
251247
}}
252248
>
253249
<Icon name="plus-circle" /> New Compute Server...

src/packages/frontend/compute/tab.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import {
33
set_local_storage,
44
} from "@cocalc/frontend/misc/local-storage";
55

6-
export function getServerTab(project_id): string | undefined {
6+
export type TabName = "compute-servers" | "cloud-filesystems" | "notebooks";
7+
8+
export function getServerTab(project_id): TabName | undefined {
79
return (get_local_storage(`${project_id}-server-tab`) ?? undefined) as
8-
| string
10+
| TabName
911
| undefined;
1012
}
1113

12-
export function setServerTab(project_id, tab) {
14+
export function setServerTab(project_id, tab: TabName) {
1315
return set_local_storage(`${project_id}-server-tab`, tab);
1416
}

src/packages/frontend/project/page/flyouts/servers.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ import { FIX_BORDER } from "@cocalc/frontend/project/page/common";
1717
import { SagewsControl } from "@cocalc/frontend/project/settings/sagews-control";
1818
import { NAMED_SERVER_NAMES } from "@cocalc/util/types/servers";
1919
import { FLYOUT_PADDING } from "./consts";
20-
import { getServerTab, setServerTab } from "@cocalc/frontend/compute/tab";
20+
import {
21+
getServerTab,
22+
setServerTab,
23+
TabName,
24+
} from "@cocalc/frontend/compute/tab";
2125

2226
export function ServersFlyout({ project_id, wrap }) {
2327
const servers = NAMED_SERVER_NAMES.map((name) => (
@@ -122,7 +126,7 @@ export function ServersFlyout({ project_id, wrap }) {
122126
<Tabs
123127
items={items}
124128
defaultActiveKey={getServerTab(project_id)}
125-
onChange={(tab) => setServerTab(project_id, tab)}
129+
onChange={(tab) => setServerTab(project_id, tab as TabName)}
126130
/>,
127131
);
128132
}

src/packages/frontend/project/servers/project-servers.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ import { SagewsControl } from "../settings/sagews-control";
2222
import { useAvailableFeatures } from "../use-available-features";
2323
import { ICON_NAME, ROOT_STYLE, TITLE } from "./consts";
2424
import CloudFilesystems from "@cocalc/frontend/compute/cloud-filesystem/cloud-filesystems";
25-
import { getServerTab, setServerTab } from "@cocalc/frontend/compute/tab";
25+
import {
26+
getServerTab,
27+
setServerTab,
28+
TabName,
29+
} from "@cocalc/frontend/compute/tab";
2630

2731
// Antd's 24 grid system
2832
const md = 6;
@@ -226,7 +230,7 @@ export function ProjectServers(props: Props) {
226230
<Tabs
227231
items={items}
228232
defaultActiveKey={getServerTab(project_id)}
229-
onChange={(tab) => setServerTab(project_id, tab)}
233+
onChange={(tab) => setServerTab(project_id, tab as TabName)}
230234
/>
231235
</div>
232236
);

src/packages/frontend/project_actions.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ import {
8181
FlyoutLogFilter,
8282
} from "./project/page/flyouts/utils";
8383
import { modalParams } from "@cocalc/frontend/compute/select-server-for-file";
84+
import { setServerTab } from "@cocalc/frontend/compute/tab";
8485

8586
const { defaults, required } = misc;
8687

@@ -3457,4 +3458,16 @@ export class ProjectActions extends Actions<ProjectStoreState> {
34573458
const store = this.get_store();
34583459
return id ?? store?.get("compute_server_id") ?? 0;
34593460
};
3461+
3462+
showComputeServers = () => {
3463+
setServerTab(this.project_id, "compute-servers");
3464+
this.set_active_tab("servers", {
3465+
change_history: true,
3466+
});
3467+
};
3468+
3469+
createComputeServerDialog = () => {
3470+
this.setState({ create_compute_server: true });
3471+
this.showComputeServers();
3472+
};
34603473
}

0 commit comments

Comments
 (0)