Skip to content

Commit 82becf4

Browse files
feat: add job launcher (#4209)
* feat: add job launcher * fix: show the popover position correctly (#4223) --------- Co-authored-by: Lorenzo Cavazzi <43481553+lorenzo-cavazzi@users.noreply.github.com>
1 parent 39e3fc0 commit 82becf4

47 files changed

Lines changed: 2054 additions & 869 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export type EntityTypes =
22
| "code-repository"
33
| "data-connector"
4+
| "job-launcher"
45
| "session-launcher";

client/src/components/offcanvas/OffcanvasHeaderWithType.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import cx from "classnames";
22
import {
33
Database,
44
FileCode,
5+
Gear,
56
PlayCircle,
67
QuestionCircle,
78
} from "react-bootstrap-icons";
@@ -29,6 +30,8 @@ export default function OffcanvasHeaderWithType({
2930
<Database className="me-1" />
3031
) : entityType === "session-launcher" ? (
3132
<PlayCircle className="me-1" />
33+
) : entityType === "job-launcher" ? (
34+
<Gear className="me-1" />
3235
) : entityType === "code-repository" ? (
3336
<FileCode className="me-1" />
3437
) : (
@@ -39,11 +42,13 @@ export default function OffcanvasHeaderWithType({
3942
? _entityName
4043
: entityType === "data-connector"
4144
? "Data connector"
42-
: entityType === "session-launcher"
43-
? "Session launcher"
44-
: entityType === "code-repository"
45-
? "Code repository"
46-
: "Unknown";
45+
: entityType === "job-launcher"
46+
? "Job launcher"
47+
: entityType === "session-launcher"
48+
? "Session launcher"
49+
: entityType === "code-repository"
50+
? "Code repository"
51+
: "Unknown";
4752

4853
return (
4954
<div>

client/src/features/admin/SessionEnvironmentAdvancedFields.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export default function SessionEnvironmentAdvancedFields({
7070
<AdvancedSettingsFields<SessionEnvironmentForm>
7171
control={control}
7272
errors={errors}
73+
launcherCategory="session"
7374
/>
7475
</CollapseBody>
7576
</Collapse>

client/src/features/admin/UpdateSessionEnvironmentButton.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,8 @@ function UpdateSessionEnvironmentModal({
106106
uid: data.uid ?? undefined,
107107
working_directory: data.working_directory?.trim() || undefined,
108108
strip_path_prefix: data.strip_path_prefix,
109-
...(commandParsed.data
110-
? { command: commandParsed.data }
111-
: { command: null }),
112-
...(argsParsed.data ? { args: argsParsed.data } : { args: null }),
109+
command: commandParsed.data ?? undefined,
110+
args: argsParsed.data ?? undefined,
113111
},
114112
});
115113
},

client/src/features/sessionsV2/AddSessionLauncherButton.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { useCallback, useState } from "react";
2121
import { PlusLg } from "react-bootstrap-icons";
2222
import { Button } from "reactstrap";
2323

24-
import NewSessionLauncherModal from "./components/SessionModals/NewSessionLauncherModal";
24+
import NewLauncherModal from "./components/SessionModals/NewLauncherModal";
2525

2626
export default function AddSessionLauncherButton({
2727
"data-cy": dataCy,
@@ -38,9 +38,9 @@ export default function AddSessionLauncherButton({
3838
return (
3939
<>
4040
{styleBtn === "iconTextBtn" ? (
41-
<Button data-cy={dataCy} onClick={() => toggle()}>
41+
<Button data-cy={dataCy} onClick={toggle}>
4242
<PlusLg className={cx("me-2", "bi")} />
43-
Add session
43+
Add launcher
4444
</Button>
4545
) : (
4646
<Button
@@ -52,7 +52,7 @@ export default function AddSessionLauncherButton({
5252
<PlusLg className="bi" />
5353
</Button>
5454
)}
55-
<NewSessionLauncherModal isOpen={isOpen} toggle={toggle} />
55+
<NewLauncherModal isOpen={isOpen} toggle={toggle} />
5656
</>
5757
);
5858
}

client/src/features/sessionsV2/DeleteSessionLauncherModal.tsx

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ import { WarnAlert } from "../../components/Alert";
2525
import RtkOrDataServicesError from "../../components/errors/RtkOrDataServicesError";
2626
import type { SessionLauncher } from "./api/sessionLaunchersV2.api";
2727
import { useDeleteSessionLaunchersByLauncherIdMutation as useDeleteSessionLauncherMutation } from "./api/sessionLaunchersV2.api";
28+
import {
29+
getLauncherCategory,
30+
getLauncherCategoryDefinition,
31+
} from "./session.utils";
2832

2933
interface DeleteSessionLauncherModalProps {
3034
isOpen: boolean;
@@ -40,6 +44,8 @@ export default function DeleteSessionLauncherModal({
4044
sessionsLength,
4145
}: DeleteSessionLauncherModalProps) {
4246
const [deleteSessionLauncher, result] = useDeleteSessionLauncherMutation();
47+
const launcherCategory = getLauncherCategory(launcher);
48+
const launcherDefinition = getLauncherCategoryDefinition(launcherCategory);
4349

4450
const onDelete = useCallback(() => {
4551
deleteSessionLauncher({
@@ -75,32 +81,37 @@ export default function DeleteSessionLauncherModal({
7581
tag="h2"
7682
toggle={toggle}
7783
>
78-
Delete session launcher
84+
Delete {launcherDefinition.text.inline} launcher
7985
</ModalHeader>
8086
<ModalBody>
8187
{result.error && <RtkOrDataServicesError error={result.error} />}
8288
<p className="mb-3">
83-
Are you sure you want to delete the <b>{launcher.name}</b> session
84-
launcher?
89+
Are you sure you want to delete the <b>{launcher.name}</b>{" "}
90+
{launcherDefinition.text.inline} launcher?
8591
</p>
8692
{sessionsLength > 0 && (
8793
<WarnAlert dismissible={false}>
8894
<p>
89-
You have a session running from this launcher. If you delete this
90-
session launcher, that session will continue running, but it
91-
become an orphan session and will not be able to be launched again
92-
once stopped. If other RenkuLab users are running sessions from
93-
this launcher, their sessions will become orphan sessions as well.
95+
You have a {launcherDefinition.text.inline} running from this
96+
launcher. If you delete this launcher, that{" "}
97+
{launcherDefinition.text.inline} will continue running, but it
98+
become an orphan {launcherDefinition.text.inline} and will not be
99+
able to be launched again once stopped. If other RenkuLab users
100+
are running {launcherDefinition.text.inline}s from this launcher,
101+
their {launcherDefinition.text.inline}s will become orphan{" "}
102+
{launcherDefinition.text.inline}s as well.
94103
</p>
95104
</WarnAlert>
96105
)}
97106
{sessionsLength === 0 && (
98107
<WarnAlert dismissible={false}>
99108
<p>
100-
If other RenkuLab users are running sessions from this launcher,
101-
their sessions will become orphan sessions. This means that their
102-
sessions will continue running, but will not be able to be
103-
launched again once stopped.
109+
If other RenkuLab users are running{" "}
110+
{launcherDefinition.text.inline}s from this launcher, their{" "}
111+
{launcherDefinition.text.inline}s will become orphan{" "}
112+
{launcherDefinition.text.inline}s. This means that their{" "}
113+
{launcherDefinition.text.inline}s will continue running, but will
114+
not be able to be launched again once stopped.
104115
</p>
105116
</WarnAlert>
106117
)}
@@ -119,7 +130,7 @@ export default function DeleteSessionLauncherModal({
119130
role="button"
120131
>
121132
<Trash className={cx("bi", "me-1")} />
122-
Delete Session launcher
133+
Delete {launcherDefinition.text.inline} launcher
123134
</Button>
124135
</ModalFooter>
125136
</Modal>

0 commit comments

Comments
 (0)