Skip to content

Commit c505d81

Browse files
committed
feat: add submit a job
1 parent 8b9e966 commit c505d81

30 files changed

Lines changed: 2451 additions & 503 deletions

client/src/features/dashboardV2/DashboardV2Sessions.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import cx from "classnames";
2222
import { generatePath, Link } from "react-router";
2323
import { Col, ListGroup, Row } from "reactstrap";
2424

25+
import { sessionLauncherKindToCategory } from "~/features/sessionsV2/session.utils.ts";
2526
import RtkOrDataServicesError from "../../components/errors/RtkOrDataServicesError";
2627
import { Loader } from "../../components/Loader";
2728
import { ABSOLUTE_ROUTES } from "../../routing/routes.constants";
@@ -112,10 +113,10 @@ interface DashboardSessionProps {
112113
function DashboardSession({ session }: DashboardSessionProps) {
113114
const { project_id: projectId, launcher_id: launcherId } = session;
114115
const { data: project } = useGetProjectsByProjectIdQuery(
115-
projectId ? { projectId } : skipToken,
116+
projectId ? { projectId } : skipToken
116117
);
117118
const { data: launcher } = useGetProjectSessionLauncherQuery(
118-
launcherId ? { launcherId } : skipToken,
119+
launcherId ? { launcherId } : skipToken
119120
);
120121

121122
const projectUrl = project
@@ -124,10 +125,10 @@ function DashboardSession({ session }: DashboardSessionProps) {
124125
slug: project.slug,
125126
})
126127
: projectId
127-
? generatePath(ABSOLUTE_ROUTES.v2.projects.showById, {
128-
id: projectId,
129-
})
130-
: ABSOLUTE_ROUTES.v2.index;
128+
? generatePath(ABSOLUTE_ROUTES.v2.projects.showById, {
129+
id: projectId,
130+
})
131+
: ABSOLUTE_ROUTES.v2.index;
131132
const showSessionUrl = project
132133
? generatePath(ABSOLUTE_ROUTES.v2.projects.show.sessions.show, {
133134
namespace: project.namespace,
@@ -136,7 +137,8 @@ function DashboardSession({ session }: DashboardSessionProps) {
136137
})
137138
: ABSOLUTE_ROUTES.v2.index;
138139

139-
const sessionStyles = getSessionStatusStyles(session);
140+
const launcherCategory = sessionLauncherKindToCategory(session.session_type);
141+
const sessionStyles = getSessionStatusStyles(session, launcherCategory);
140142
const state = session.status.state;
141143

142144
return (
@@ -151,7 +153,7 @@ function DashboardSession({ session }: DashboardSessionProps) {
151153
"gap-3",
152154
"link-primary",
153155
"text-body",
154-
"text-decoration-none",
156+
"text-decoration-none"
155157
)}
156158
to={{ pathname: projectUrl }}
157159
>
@@ -165,7 +167,7 @@ function DashboardSession({ session }: DashboardSessionProps) {
165167
"cursor-pointer",
166168
"d-inline-block",
167169
"link-primary",
168-
"text-body",
170+
"text-body"
169171
)}
170172
data-cy="list-session-link"
171173
>
@@ -176,7 +178,7 @@ function DashboardSession({ session }: DashboardSessionProps) {
176178
{launcher?.environment?.name}
177179
</>
178180
) : (
179-
(projectId ?? "Unknown")
181+
projectId ?? "Unknown"
180182
)}
181183
</h4>
182184
</Col>
@@ -195,7 +197,7 @@ function DashboardSession({ session }: DashboardSessionProps) {
195197
"mt-2",
196198
"d-block",
197199
"d-sm-flex",
198-
"gap-5",
200+
"gap-5"
199201
)}
200202
xs={12}
201203
>

client/src/features/logsDisplay/LogsModal.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,13 @@ export default function LogsModal({
100100
"fs-4",
101101
"fst-italic",
102102
"mb-0",
103-
getSessionStatusStyles({
104-
status: { state: sessionState },
105-
image: "url",
106-
})["textColorCard"],
103+
getSessionStatusStyles(
104+
{
105+
status: { state: sessionState },
106+
image: "url",
107+
},
108+
"session"
109+
)["textColorCard"]
107110
)}
108111
>
109112
Session status: {sessionState}
@@ -217,7 +220,7 @@ function TabbedLogs({ data, defaultTab }: TabbedLogsProps) {
217220
}, [data, defaultTab]);
218221

219222
const [activeTab, setActiveTab] = useState<string>(
220-
sortedLogs.at(0)?.tab ?? "",
223+
sortedLogs.at(0)?.tab ?? ""
221224
);
222225

223226
const preRef = useRef<HTMLPreElement>(null);
@@ -301,7 +304,7 @@ function ModalFooterButtons({
301304
const [isDownloading, triggerDownload] = useDownloadLogs(
302305
name,
303306
refetch,
304-
downloadQueryTrigger,
307+
downloadQueryTrigger
305308
);
306309
const canDownload =
307310
!isFetching &&
@@ -350,7 +353,7 @@ function ModalFooterButtons({
350353
function useDownloadLogs(
351354
name: string,
352355
refetch: LogsQuery["refetch"],
353-
downloadQueryTrigger: DownloadLogsLazyQueryTrigger | undefined | null,
356+
downloadQueryTrigger: DownloadLogsLazyQueryTrigger | undefined | null
354357
): [boolean, () => void] {
355358
const [isDownloading, setIsDownloading] = useState<boolean>(false);
356359

client/src/features/sessionsV2/DataConnectorSecretsModal.tsx

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ const CONTEXT_STRINGS = {
5959
testError:
6060
"The data connector could not be mounted. Please retry with different credentials, or skip the data connector. If you skip, the data connector will not be mounted in the session.",
6161
},
62+
job: {
63+
continueButton: "Continue",
64+
dataCy: "job-data-connector-credentials-modal",
65+
header: "Job Storage Credentials",
66+
testError:
67+
"The data connector could not be mounted. Please retry with different credentials, or skip the data connector. If you skip, the data connector will not be mounted in the job.",
68+
},
6269
storage: {
6370
continueButton: "Test and Save",
6471
dataCy: "data-connector-credentials-modal",
@@ -113,7 +120,7 @@ function DataConnectorSecrets({
113120
dataConnectorConfig.savedCredentialFields.map((secret) => [
114121
storageSecretNameToFieldName({ name: secret }),
115122
secret,
116-
]),
123+
])
117124
)
118125
: {};
119126

@@ -158,7 +165,7 @@ function DataConnectorSecrets({
158165
}
159166

160167
interface DataConnectorSecretsModalProps {
161-
context?: "session" | "storage";
168+
context?: "session" | "job" | "storage";
162169
isOpen: boolean;
163170
onCancel: () => void;
164171
onStart: (dataConnectorConfigs: DataConnectorConfiguration[]) => void;
@@ -176,16 +183,16 @@ export default function DataConnectorSecretsModal({
176183
initialDataConnectorConfigs == null
177184
? []
178185
: initialDataConnectorConfigs.filter(
179-
(config) => config.sensitiveFieldDefinitions.length === 0,
186+
(config) => config.sensitiveFieldDefinitions.length === 0
180187
),
181-
[initialDataConnectorConfigs],
188+
[initialDataConnectorConfigs]
182189
);
183190
const [dataConnectorConfigs, setDataConnectorConfigs] = useState(
184191
initialDataConnectorConfigs == null
185192
? []
186193
: initialDataConnectorConfigs.filter(
187-
(config) => config.sensitiveFieldDefinitions.length > 0,
188-
),
194+
(config) => config.sensitiveFieldDefinitions.length > 0
195+
)
189196
);
190197
const [index, setIndex] = useState(0);
191198
const { control, handleSubmit, reset: resetForm } = useForm();
@@ -204,7 +211,7 @@ export default function DataConnectorSecretsModal({
204211
onStart([...noCredentialsConfigs, ...csConfigs]);
205212
}
206213
},
207-
[index, noCredentialsConfigs, onStart, resetForm, validationResult],
214+
[index, noCredentialsConfigs, onStart, resetForm, validationResult]
208215
);
209216

210217
const onSkip = useCallback(() => {
@@ -256,7 +263,7 @@ export default function DataConnectorSecretsModal({
256263
newCloudStorageConfigs[index] = config;
257264
setDataConnectorConfigs(newCloudStorageConfigs);
258265
},
259-
[dataConnectorConfigs, index, validateCloudStorageConnection],
266+
[dataConnectorConfigs, index, validateCloudStorageConnection]
260267
);
261268

262269
useEffect(() => {
@@ -278,7 +285,7 @@ export default function DataConnectorSecretsModal({
278285
if (dataConnectorConfigs == null) return null;
279286
if (dataConnectorConfigs.length < 1) return null;
280287
const hasSavedCredentials = dataConnectorConfigs.some(
281-
(csc) => csc.savedCredentialFields?.length > 0,
288+
(csc) => csc.savedCredentialFields?.length > 0
282289
);
283290

284291
return (
@@ -327,10 +334,8 @@ export default function DataConnectorSecretsModal({
327334
);
328335
}
329336

330-
interface CredentialsButtonsProps extends Pick<
331-
DataConnectorSecretsModalProps,
332-
"onCancel"
333-
> {
337+
interface CredentialsButtonsProps
338+
extends Pick<DataConnectorSecretsModalProps, "onCancel"> {
334339
context: NonNullable<DataConnectorSecretsModalProps["context"]>;
335340
hasSavedCredentials: boolean;
336341
onSkip: () => void;
@@ -352,7 +357,9 @@ function CredentialsButtons({
352357
<XLg className={cx("bi", "me-1")} />
353358
Cancel
354359
</Button>
355-
{context === "session" && <SkipConnectionTestButton onSkip={onSkip} />}
360+
{(context === "session" || context === "job") && (
361+
<SkipConnectionTestButton context={context} onSkip={onSkip} />
362+
)}
356363
{context === "storage" && (
357364
<ClearCredentialsButton
358365
onSkip={onSkip}
@@ -364,10 +371,10 @@ function CredentialsButtons({
364371
validationResult == null
365372
? "primary"
366373
: validationResult.isSuccess
367-
? "primary"
368-
: validationResult.isError
369-
? "danger"
370-
: "primary"
374+
? "primary"
375+
: validationResult.isError
376+
? "danger"
377+
: "primary"
371378
}
372379
className={cx("ms-2")}
373380
disabled={validationResult.isLoading}
@@ -431,7 +438,7 @@ function ProgressBreadcrumbs({
431438
"btn-link",
432439
"p-0",
433440
idx === index && ["text-decoration-none", "link-rk-text"],
434-
idx > index && "text-decoration-none",
441+
idx > index && "text-decoration-none"
435442
)}
436443
disabled={idx >= index}
437444
onClick={() => {
@@ -485,7 +492,8 @@ function SaveCredentialsInput({
485492
);
486493
}
487494

488-
interface SensitiveFieldWidgetProps extends DataConnectorConfigurationSecretsProps {
495+
interface SensitiveFieldWidgetProps
496+
extends DataConnectorConfigurationSecretsProps {
489497
credentialFieldDict: Record<string, string>;
490498
field: {
491499
name: string;
@@ -573,7 +581,7 @@ function SensitiveFieldInput({
573581
"form-control",
574582
"rounded-0",
575583
"rounded-start",
576-
fieldState.error && "is-invalid",
584+
fieldState.error && "is-invalid"
577585
)}
578586
placeholder={""}
579587
{...field}
@@ -612,9 +620,11 @@ function SensitiveFieldInput({
612620
}
613621

614622
function SkipConnectionTestButton({
623+
context,
615624
onSkip,
616-
}: Pick<CredentialsButtonsProps, "onSkip">) {
625+
}: Pick<CredentialsButtonsProps, "context" | "onSkip">) {
617626
const skipButtonRef = useRef<HTMLAnchorElement>(null);
627+
const targetLabel = context === "job" ? "job" : "session";
618628
return (
619629
<>
620630
<span ref={skipButtonRef}>
@@ -624,7 +634,7 @@ function SkipConnectionTestButton({
624634
</Button>
625635
</span>
626636
<UncontrolledTooltip target={skipButtonRef}>
627-
Skip the data connector. It will not be mounted in the session.
637+
{`Skip the data connector. It will not be mounted in the ${targetLabel}.`}
628638
</UncontrolledTooltip>
629639
</>
630640
);

0 commit comments

Comments
 (0)