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

Use react router's route handle functionality to remove duplicate containers #3481

Merged
merged 1 commit into from
Jul 1, 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 @@ -165,8 +165,8 @@ const PipelineRuns = ({
const { reason, status } = getStatus(pipelineRun);
const statusIcon = getPipelineRunStatusIcon(pipelineRun);
const pipelineRunURL = getPipelineRunURL({
name: pipelineRunName,
namespace,
pipelineRunName,
annotations
});
const pipelineRunsByPipelineURL =
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/components/TaskRuns/TaskRuns.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ const TaskRuns = ({
} = getStatus(taskRun);
const statusIcon = getTaskRunStatusIcon(taskRun);
const taskRunURL = getTaskRunURL({
namespace,
taskRunName
name: taskRunName,
namespace
});

const taskRunsURL =
Expand Down
12 changes: 6 additions & 6 deletions packages/components/src/components/Trigger/Trigger.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ const Trigger = ({ namespace, trigger }) => {
to={
binding.kind === 'ClusterTriggerBinding'
? urls.clusterTriggerBindings.byName({
clusterTriggerBindingName: binding.ref
name: binding.ref
})
: urls.triggerBindings.byName({
namespace,
triggerBindingName: binding.ref
name: binding.ref,
namespace
})
}
>
Expand Down Expand Up @@ -105,8 +105,8 @@ const Trigger = ({ namespace, trigger }) => {
<Link
className="tkn--trigger-resourcelink"
to={urls.triggerTemplates.byName({
namespace,
triggerTemplateName
name: triggerTemplateName,
namespace
})}
>
<span title={triggerTemplateName}>{triggerTemplateName}</span>
Expand Down Expand Up @@ -324,7 +324,7 @@ const Trigger = ({ namespace, trigger }) => {
content = (
<Link
to={urls.clusterInterceptors.byName({
clusterInterceptorName
name: clusterInterceptorName
})}
title={clusterInterceptorName}
>
Expand Down
44 changes: 21 additions & 23 deletions packages/utils/src/utils/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,33 @@ export const paths = {
clusterTasks: {
all() {
return '/clustertasks';
},
byName() {
return '/clustertasks/:name';
}
},
clusterInterceptors: {
all() {
return '/clusterinterceptors';
},
byName: function byName() {
return '/clusterinterceptors/:clusterInterceptorName';
byName() {
return '/clusterinterceptors/:name';
}
},
clusterTriggerBindings: {
all() {
return '/clustertriggerbindings';
},
byName: function byName() {
return '/clustertriggerbindings/:clusterTriggerBindingName';
byName() {
return '/clustertriggerbindings/:name';
}
},
customRuns: {
all() {
return '/customruns';
},
byName() {
return byNamespace({ path: '/customruns/:runName' });
return byNamespace({ path: '/customruns/:name' });
},
byNamespace() {
return byNamespace({ path: '/customruns' });
Expand All @@ -62,7 +65,7 @@ export const paths = {
return '/eventlisteners';
},
byName() {
return byNamespace({ path: '/eventlisteners/:eventListenerName' });
return byNamespace({ path: '/eventlisteners/:name' });
},
byNamespace() {
return byNamespace({ path: '/eventlisteners' });
Expand All @@ -76,7 +79,7 @@ export const paths = {
return '/interceptors';
},
byName() {
return byNamespace({ path: '/interceptors/:interceptorName' });
return byNamespace({ path: '/interceptors/:name' });
},
byNamespace() {
return byNamespace({ path: '/interceptors' });
Expand All @@ -102,7 +105,7 @@ export const paths = {
},
byName() {
return byNamespace({
path: '/pipelineruns/:pipelineRunName'
path: '/pipelineruns/:name'
});
},
byNamespace() {
Expand All @@ -116,19 +119,11 @@ export const paths = {
all() {
return '/pipelines';
},
byNamespace() {
return byNamespace({ path: '/pipelines' });
}
},
rawCRD: {
all() {
return '/:kind';
byName() {
return byNamespace({ path: '/pipelines/:name' });
},
byNamespace() {
return byNamespace({ path: '/:kind/:name' });
},
cluster() {
return '/:kind/:name';
return byNamespace({ path: '/pipelines' });
}
},
settings() {
Expand All @@ -139,7 +134,7 @@ export const paths = {
return '/taskruns';
},
byName() {
return byNamespace({ path: '/taskruns/:taskRunName' });
return byNamespace({ path: '/taskruns/:name' });
},
byNamespace() {
return byNamespace({ path: '/taskruns' });
Expand All @@ -152,6 +147,9 @@ export const paths = {
all() {
return '/tasks';
},
byName() {
return byNamespace({ path: '/tasks/:name' });
},
byNamespace() {
return byNamespace({ path: '/tasks' });
}
Expand All @@ -161,7 +159,7 @@ export const paths = {
return '/triggerbindings';
},
byName() {
return byNamespace({ path: '/triggerbindings/:triggerBindingName' });
return byNamespace({ path: '/triggerbindings/:name' });
},
byNamespace() {
return byNamespace({ path: '/triggerbindings' });
Expand All @@ -172,7 +170,7 @@ export const paths = {
return '/triggers';
},
byName() {
return byNamespace({ path: '/triggers/:triggerName' });
return byNamespace({ path: '/triggers/:name' });
},
byNamespace() {
return byNamespace({ path: '/triggers' });
Expand All @@ -183,7 +181,7 @@ export const paths = {
return '/triggertemplates';
},
byName() {
return byNamespace({ path: '/triggertemplates/:triggerTemplateName' });
return byNamespace({ path: '/triggertemplates/:name' });
},
byNamespace() {
return byNamespace({ path: '/triggertemplates' });
Expand Down
77 changes: 28 additions & 49 deletions packages/utils/src/utils/router.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ describe('clusterInterceptors', () => {
);
});
it('byName', () => {
expect(urls.clusterInterceptors.byName({ clusterInterceptorName })).toEqual(
expect(
urls.clusterInterceptors.byName({ name: clusterInterceptorName })
).toEqual(
generatePath(paths.clusterInterceptors.byName(), {
clusterInterceptorName
name: clusterInterceptorName
})
);
});
Expand All @@ -77,10 +79,10 @@ describe('clusterTriggerBindings', () => {
});
it('byName', () => {
expect(
urls.clusterTriggerBindings.byName({ clusterTriggerBindingName })
urls.clusterTriggerBindings.byName({ name: clusterTriggerBindingName })
).toEqual(
generatePath(paths.clusterTriggerBindings.byName(), {
clusterTriggerBindingName
name: clusterTriggerBindingName
})
);
});
Expand All @@ -95,11 +97,11 @@ describe('eventListeners', () => {

it('byName', () => {
expect(
urls.eventListeners.byName({ namespace, eventListenerName })
urls.eventListeners.byName({ name: eventListenerName, namespace })
).toEqual(
generatePath(paths.eventListeners.byName(), {
namespace,
eventListenerName
name: eventListenerName,
namespace
})
);
});
Expand Down Expand Up @@ -176,10 +178,12 @@ describe('pipelineRuns', () => {
});

it('byName', () => {
expect(urls.pipelineRuns.byName({ namespace, pipelineRunName })).toEqual(
expect(
urls.pipelineRuns.byName({ name: pipelineRunName, namespace })
).toEqual(
generatePath(paths.pipelineRuns.byName(), {
namespace,
pipelineRunName
name: pipelineRunName,
namespace
})
);
});
Expand Down Expand Up @@ -223,41 +227,16 @@ describe('pipelines', () => {
});
});

describe('rawCRD', () => {
it('all', () => {
const kind = 'tasks';
expect(urls.rawCRD.all({ kind })).toEqual(
generatePath(paths.rawCRD.all(), { kind })
);
});

it('byNamespace', () => {
const kind = 'tasks';
const name = taskName;
expect(urls.rawCRD.byNamespace({ namespace, kind, name })).toEqual(
generatePath(paths.rawCRD.byNamespace(), { kind, name, namespace })
);
});

it('cluster', () => {
const kind = 'tasks';
const name = taskName;
expect(urls.rawCRD.cluster({ kind, name })).toEqual(
generatePath(paths.rawCRD.cluster(), { kind, name })
);
});
});

describe('customRuns', () => {
it('all', () => {
expect(urls.customRuns.all()).toEqual(generatePath(paths.customRuns.all()));
});

it('byName', () => {
expect(urls.customRuns.byName({ namespace, runName })).toEqual(
expect(urls.customRuns.byName({ name: runName, namespace })).toEqual(
generatePath(paths.customRuns.byName(), {
namespace,
runName
name: runName,
namespace
})
);
});
Expand Down Expand Up @@ -290,8 +269,8 @@ describe('taskRuns', () => {
});

it('byName', () => {
expect(urls.taskRuns.byName({ namespace, taskRunName })).toEqual(
generatePath(paths.taskRuns.byName(), { namespace, taskRunName })
expect(urls.taskRuns.byName({ name: taskRunName, namespace })).toEqual(
generatePath(paths.taskRuns.byName(), { name: taskRunName, namespace })
);
});

Expand Down Expand Up @@ -340,11 +319,11 @@ describe('triggerBindings', () => {

it('byName', () => {
expect(
urls.triggerBindings.byName({ namespace, triggerBindingName })
urls.triggerBindings.byName({ name: triggerBindingName, namespace })
).toEqual(
generatePath(paths.triggerBindings.byName(), {
namespace,
triggerBindingName
name: triggerBindingName,
namespace
})
);
});
Expand All @@ -362,10 +341,10 @@ describe('triggers', () => {
});

it('byName', () => {
expect(urls.triggers.byName({ namespace, triggerName })).toEqual(
expect(urls.triggers.byName({ name: triggerName, namespace })).toEqual(
generatePath(paths.triggers.byName(), {
namespace,
triggerName
name: triggerName,
namespace
})
);
});
Expand All @@ -386,11 +365,11 @@ describe('triggerTemplates', () => {

it('byName', () => {
expect(
urls.triggerTemplates.byName({ namespace, triggerTemplateName })
urls.triggerTemplates.byName({ name: triggerTemplateName, namespace })
).toEqual(
generatePath(paths.triggerTemplates.byName(), {
namespace,
triggerTemplateName
name: triggerTemplateName,
namespace
})
);
});
Expand Down
32 changes: 0 additions & 32 deletions src/api/clusterInterceptors.js

This file was deleted.

Loading
Loading