diff --git a/src/containers/CustomRun/CustomRun.jsx b/src/containers/CustomRun/CustomRun.jsx index 7cf6a4efe..424e73068 100644 --- a/src/containers/CustomRun/CustomRun.jsx +++ b/src/containers/CustomRun/CustomRun.jsx @@ -202,6 +202,14 @@ function CustomRun() { }); } + function editAndRun(run) { + navigate( + `${urls.customRuns.create()}?mode=yaml&customRunName=${ + run.metadata.name + }&namespace=${run.metadata.namespace}` + ); + } + function runActions() { if (isReadOnly) { return []; @@ -215,6 +223,13 @@ function CustomRun() { }), disable: resource => !!resource.metadata.labels?.['tekton.dev/pipeline'] }, + { + actionText: intl.formatMessage({ + id: 'dashboard.editAndRun.actionText', + defaultMessage: 'Edit and run' + }), + action: editAndRun + }, { actionText: intl.formatMessage({ id: 'dashboard.actions.deleteButton', diff --git a/src/containers/CustomRuns/CustomRuns.jsx b/src/containers/CustomRuns/CustomRuns.jsx index 70385bba5..4165d6746 100644 --- a/src/containers/CustomRuns/CustomRuns.jsx +++ b/src/containers/CustomRuns/CustomRuns.jsx @@ -34,6 +34,7 @@ import { Table } from '@tektoncd/dashboard-components'; import { + Add16 as Add, Calendar16 as CalendarIcon, TrashCan32 as DeleteIcon, Time16 as TimeIcon, @@ -188,6 +189,14 @@ function CustomRuns() { rerunCustomRun(run); } + function editAndRun(run) { + navigate( + `${urls.customRuns.create()}?mode=yaml&customRunName=${ + run.metadata.name + }&namespace=${run.metadata.namespace}` + ); + } + function deleteResource(run) { const { name, namespace: resourceNamespace } = run.metadata; return deleteCustomRun({ name, namespace: resourceNamespace }).catch( @@ -225,6 +234,13 @@ function CustomRuns() { }), disable: resource => !!resource.metadata.labels?.['tekton.dev/pipeline'] }, + { + actionText: intl.formatMessage({ + id: 'dashboard.editAndRun.actionText', + defaultMessage: 'Edit and run' + }), + action: editAndRun + }, { actionText: intl.formatMessage({ id: 'dashboard.cancelTaskRun.actionText', @@ -294,6 +310,31 @@ function CustomRuns() { ]; } + const toolbarButtons = isReadOnly + ? [] + : [ + { + onClick: () => { + let queryString; + if (namespace !== ALL_NAMESPACES || kind !== 'CustomRun') { + queryString = new URLSearchParams({ + ...(namespace !== ALL_NAMESPACES && { namespace }), + ...(kind && { kind }), + ...(customRunName && { customRunName }) + }).toString(); + } + navigate( + urls.customRuns.create() + (queryString ? `?${queryString}` : '') + ); + }, + text: intl.formatMessage({ + id: 'dashboard.actions.createButton', + defaultMessage: 'Create' + }), + icon: Add + } + ]; + const batchActionButtons = isReadOnly ? [] : [ @@ -482,6 +523,7 @@ function CustomRuns() { return ( <>