Skip to content

Commit

Permalink
use jobName as fallback if only launching 1 job
Browse files Browse the repository at this point in the history
  • Loading branch information
dliu27 committed Dec 19, 2024
1 parent a1e8f85 commit 4a5be44
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,29 @@ export function useLaunchMultipleRunsWithTelemetry() {
const history = useHistory();

return useCallback(
async (variables: LaunchMultipleRunsMutationVariables, behavior: LaunchBehavior) => {
async (
variables: LaunchMultipleRunsMutationVariables,
behavior: LaunchBehavior,
jobName: string,
) => {
try {
const executionParamsList = Array.isArray(variables.executionParamsList)
? variables.executionParamsList
: [variables.executionParamsList];
const jobNames = executionParamsList.map(

let jobNames = executionParamsList.map(
(params) => params.selector.jobName || params.selector.pipelineName,
);

if (
jobNames.length !== executionParamsList.length ||
jobNames.includes(undefined) ||
(executionParamsList.length === 1 && jobNames.includes(undefined)) ||
jobNames.includes(null)
) {
jobNames = [jobName];
}

if (
(jobNames.length !== executionParamsList.length && jobNames.includes(undefined)) ||
jobNames.includes(null)
) {
throw new Error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,22 @@ const EvaluateSchedule = ({repoAddress, name, onClose, jobName}: Props) => {

try {
if (executionParamsList) {
await launchMultipleRunsWithTelemetry({executionParamsList}, 'toast');
await launchMultipleRunsWithTelemetry({executionParamsList}, 'toast', jobName);
}
} catch (e) {
console.error(e);
}

setLaunching(false);
onClose();
}, [canLaunchAll, executionParamsList, launchMultipleRunsWithTelemetry, onClose, trackEvent]);
}, [
canLaunchAll,
executionParamsList,
jobName,
launchMultipleRunsWithTelemetry,
onClose,
trackEvent,
]);

const content = useMemo(() => {
// launching all runs state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ const SensorDryRun = ({repoAddress, name, currentCursor, onClose, jobName}: Prop

try {
if (executionParamsList) {
await launchMultipleRunsWithTelemetry({executionParamsList}, 'toast');
await launchMultipleRunsWithTelemetry({executionParamsList}, 'toast', jobName);
onCommitTickResult(); // persist tick
}
} catch (e) {
Expand All @@ -208,6 +208,7 @@ const SensorDryRun = ({repoAddress, name, currentCursor, onClose, jobName}: Prop
}, [
canLaunchAll,
executionParamsList,
jobName,
launchMultipleRunsWithTelemetry,
onClose,
onCommitTickResult,
Expand Down

0 comments on commit 4a5be44

Please sign in to comment.