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

Add pages for StepActions #3360

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion base/200-clusterrole-tenant.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019-2023 The Tekton Authors
# Copyright 2019-2024 The Tekton Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -44,6 +44,7 @@ rules:
- apiGroups:
- tekton.dev
resources:
- stepactions
- tasks
- taskruns
- pipelines
Expand Down
3 changes: 2 additions & 1 deletion overlays/patches/read-write/clusterrole-tenant-patch.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020-2023 The Tekton Authors
# Copyright 2020-2024 The Tekton Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -19,6 +19,7 @@
apiGroups:
- tekton.dev
resources:
- stepactions
- tasks
- taskruns
- pipelines
Expand Down
1 change: 1 addition & 0 deletions packages/e2e/cypress/fixtures/kinds.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{ "label": "ClusterTasks", "path": "/clustertasks" },
{ "label": "TaskRuns", "path": "/taskruns" },
{ "label": "CustomRuns", "path": "/customruns" },
{ "label": "StepActions", "path": "/stepactions" },
{ "label": "EventListeners", "path": "/eventlisteners" },
{ "label": "Triggers", "path": "/triggers" },
{ "label": "TriggerBindings", "path": "/triggerbindings" },
Expand Down
10 changes: 9 additions & 1 deletion packages/utils/src/utils/router.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down Expand Up @@ -146,6 +146,14 @@ export const paths = {
settings() {
return '/settings';
},
stepActions: {
all() {
return '/stepactions';
},
byNamespace() {
return byNamespace({ path: '/stepactions' });
}
},
taskRuns: {
all() {
return '/taskruns';
Expand Down
1 change: 1 addition & 0 deletions src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export * from './interceptors';
export * from './pipelineRuns';
export * from './pipelines';
export * from './serviceAccounts';
export * from './stepActions';
export * from './taskRuns';
export * from './tasks';
export * from './triggerBindings';
Expand Down
72 changes: 72 additions & 0 deletions src/api/stepActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
Copyright 2024 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import { deleteRequest, get } from './comms';
import {
getQueryParams,
getTektonAPI,
useCollection,
useResource
} from './utils';

function getStepActionsAPI({ filters, isWebSocket, name, namespace }) {
return getTektonAPI(
'stepactions',
{ isWebSocket, namespace, version: 'v1alpha1' },
getQueryParams({ filters, name })
);
}

export function getStepActions({ filters = [], namespace } = {}) {
const uri = getStepActionsAPI({ filters, namespace });
return get(uri);
}

export function getStepAction({ name, namespace }) {
const uri = getTektonAPI('stepactions', {
name,
namespace,
version: 'v1alpha1'
});
return get(uri);
}

export function deleteStepAction({ name, namespace }) {
const uri = getTektonAPI('stepactions', {
name,
namespace,
version: 'v1alpha1'
});
return deleteRequest(uri);
}

export function useStepActions(params) {
const webSocketURL = getStepActionsAPI({ ...params, isWebSocket: true });
return useCollection({
api: getStepActions,
kind: 'StepAction',
params,
webSocketURL
});
}

export function useStepAction(params, queryConfig) {
const webSocketURL = getStepActionsAPI({ ...params, isWebSocket: true });
return useResource({
api: getStepAction,
kind: 'StepAction',
params,
queryConfig,
webSocketURL
});
}
87 changes: 87 additions & 0 deletions src/api/stepActions.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
Copyright 2024 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import { http, HttpResponse } from 'msw';

import * as API from './stepActions';
import * as utils from './utils';
import { server } from '../../config_frontend/msw';

it('getStepActions', () => {
const data = {
items: 'stepactions'
};
server.use(http.get(/\/stepactions\//, () => HttpResponse.json(data)));
return API.getStepActions().then(stepActions => {
expect(stepActions).toEqual(data);
});
});

it('getStepAction', () => {
const name = 'foo';
const data = { fake: 'stepAction' };
server.use(http.get(new RegExp(`/${name}$`), () => HttpResponse.json(data)));
return API.getStepAction({ name }).then(stepAction => {
expect(stepAction).toEqual(data);
});
});

it('deleteStepAction', () => {
const name = 'foo';
const data = { fake: 'stepAction' };
server.use(
http.delete(new RegExp(`/${name}$`), () => HttpResponse.json(data))
);
return API.deleteStepAction({ name }).then(stepAction => {
expect(stepAction).toEqual(data);
});
});

it('useStepActions', () => {
const query = { fake: 'query' };
const params = { fake: 'params' };
vi.spyOn(utils, 'useCollection').mockImplementation(() => query);
expect(API.useStepActions(params)).toEqual(query);
expect(utils.useCollection).toHaveBeenCalledWith(
expect.objectContaining({
api: API.getStepActions,
kind: 'StepAction',
params
})
);
});

it('useStepAction', () => {
const query = { fake: 'query' };
const params = { fake: 'params' };
vi.spyOn(utils, 'useResource').mockImplementation(() => query);
expect(API.useStepAction(params)).toEqual(query);
expect(utils.useResource).toHaveBeenCalledWith(
expect.objectContaining({
api: API.getStepAction,
kind: 'StepAction',
params
})
);

const queryConfig = { fake: 'queryConfig' };
API.useStepAction(params, queryConfig);
expect(utils.useResource).toHaveBeenCalledWith(
expect.objectContaining({
api: API.getStepAction,
kind: 'StepAction',
params,
queryConfig
})
);
});
11 changes: 11 additions & 0 deletions src/containers/App/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import {
ResourceList,
Settings,
SideNav,
StepActions,
TaskRun,
TaskRuns,
Tasks,
Expand Down Expand Up @@ -293,6 +294,16 @@ export function App({ lang }) {
<PipelineRun />
</NamespacedRoute>
</CompatRoute>
<CompatRoute path={paths.stepActions.all()} exact>
<NamespacedRoute>
<StepActions />
</NamespacedRoute>
</CompatRoute>
<CompatRoute path={paths.stepActions.byNamespace()} exact>
<NamespacedRoute>
<StepActions />
</NamespacedRoute>
</CompatRoute>
<CompatRoute path={paths.tasks.all()} exact>
<NamespacedRoute>
<Tasks />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down Expand Up @@ -28,6 +28,7 @@ import {
useCustomResource,
useInterceptor,
usePipeline,
useStepAction,
useTask
} from '../../api';

Expand All @@ -41,6 +42,8 @@ function useResource({ group, name, namespace, type, version }) {
return useInterceptor({ name, namespace });
case 'pipelines':
return usePipeline({ name, namespace });
case 'stepactions':
return useStepAction({ name, namespace });
case 'tasks':
return useTask({ name, namespace });
default:
Expand Down
7 changes: 6 additions & 1 deletion src/containers/SideNav/SideNav.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2023 The Tekton Authors
Copyright 2019-2024 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down Expand Up @@ -124,6 +124,11 @@ function SideNav({ expanded, showKubernetesResources = false }) {
>
CustomRuns
</SideNavMenuItem>
<SideNavMenuItem
{...getMenuItemProps(getPath(urls.stepActions.all()))}
>
StepActions
</SideNavMenuItem>
{isTriggersInstalled && (
<SideNavMenuItem
{...getMenuItemProps(getPath(urls.eventListeners.all()))}
Expand Down