Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ui] fix job names #26616

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,16 @@ export function useLaunchMultipleRunsWithTelemetry() {
const history = useHistory();

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

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

// if only executing one job, and jobName isn't defined, fallback to jobName from sensor/schedule
if (executionParamsList.length === 1 && !executionParamsList[0]?.selector?.jobName) {
jobNames = [jobName];
executionParamsList[0]!.selector.jobName = jobName;
}

if (
jobNames.length !== executionParamsList.length ||
jobNames.includes(undefined) ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ const EvaluateSchedule = ({repoAddress, name, onClose, jobName}: Props) => {
const executionParamsList = useMemo(
() =>
scheduleExecutionData && scheduleSelector
? buildExecutionParamsListSchedule(scheduleExecutionData, scheduleSelector)
? buildExecutionParamsListSchedule(scheduleExecutionData, scheduleSelector, jobName)
: [],
[scheduleSelector, scheduleExecutionData],
[scheduleSelector, scheduleExecutionData, jobName],
);

const canLaunchAll = useMemo(() => {
Expand All @@ -190,22 +190,15 @@ const EvaluateSchedule = ({repoAddress, name, onClose, jobName}: Props) => {

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

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

const content = useMemo(() => {
// launching all runs state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ const SensorDryRun = ({repoAddress, name, currentCursor, onClose, jobName}: Prop
const executionParamsList = useMemo(
() =>
sensorExecutionData && sensorSelector
? buildExecutionParamsListSensor(sensorExecutionData, sensorSelector)
? buildExecutionParamsListSensor(sensorExecutionData, sensorSelector, jobName)
: [],
[sensorSelector, sensorExecutionData],
[sensorSelector, sensorExecutionData, jobName],
);

const submitTest = useCallback(async () => {
Expand Down Expand Up @@ -196,7 +196,7 @@ const SensorDryRun = ({repoAddress, name, currentCursor, onClose, jobName}: Prop

try {
if (executionParamsList) {
await launchMultipleRunsWithTelemetry({executionParamsList}, 'toast', jobName);
await launchMultipleRunsWithTelemetry({executionParamsList}, 'toast');
onCommitTickResult(); // persist tick
}
} catch (e) {
Expand All @@ -208,7 +208,6 @@ const SensorDryRun = ({repoAddress, name, currentCursor, onClose, jobName}: Prop
}, [
canLaunchAll,
executionParamsList,
jobName,
launchMultipleRunsWithTelemetry,
onClose,
onCommitTickResult,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const onlyKeyAndValue = ({key, value}: {key: string; value: string}) => ({key, v
export const buildExecutionParamsListSensor = (
sensorExecutionData: SensorDryRunInstigationTick,
sensorSelector: SensorSelector,
jobName: string,
) => {
if (!sensorExecutionData) {
return [];
Expand All @@ -36,7 +37,7 @@ export const buildExecutionParamsListSensor = (
const executionParams: ExecutionParams = {
runConfigData: configYamlOrEmpty,
selector: {
jobName: request.jobName, // get jobName from runRequest
jobName: request.jobName ?? jobName, // get jobName from runRequest, fallback to jobName
repositoryLocationName,
repositoryName,
assetSelection: [],
Expand All @@ -57,6 +58,7 @@ export const buildExecutionParamsListSensor = (
export const buildExecutionParamsListSchedule = (
scheduleExecutionData: ScheduleDryRunInstigationTick,
scheduleSelector: ScheduleSelector,
jobName: string,
) => {
if (!scheduleExecutionData) {
return [];
Expand All @@ -78,7 +80,7 @@ export const buildExecutionParamsListSchedule = (
const executionParams: ExecutionParams = {
runConfigData: configYamlOrEmpty,
selector: {
jobName: request.jobName, // get jobName from runRequest
jobName: request.jobName ?? jobName, // get jobName from runRequest, fallback to jobName
repositoryLocationName,
repositoryName,
assetSelection: [],
Expand Down
Loading