Skip to content

Commit

Permalink
Add Create button and Edit and run buttons for CustomRuns
Browse files Browse the repository at this point in the history
  • Loading branch information
jisoolee committed Sep 5, 2023
1 parent 2c2a2ca commit d209732
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/containers/CustomRun/CustomRun.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
Expand All @@ -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',
Expand Down
42 changes: 42 additions & 0 deletions src/containers/CustomRuns/CustomRuns.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
Table
} from '@tektoncd/dashboard-components';
import {
Add16 as Add,
Calendar16 as CalendarIcon,
TrashCan32 as DeleteIcon,
Time16 as TimeIcon,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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
? []
: [
Expand Down Expand Up @@ -482,6 +523,7 @@ function CustomRuns() {
return (
<>
<Table
toolbarButtons={toolbarButtons}
batchActionButtons={batchActionButtons}
emptyTextAllNamespaces={intl.formatMessage(
{
Expand Down

0 comments on commit d209732

Please sign in to comment.