Skip to content

Commit

Permalink
Don't show 'Trigger:' header in Trigger component for Trigger CRD
Browse files Browse the repository at this point in the history
The details page for a `Trigger` resource already has a heading showing
the resource name so there's no need to duplicate it in the block
rendered by the Trigger component.

We still display this heading when the component is used on the
`EventListener` page.
  • Loading branch information
AlanGreene authored and tekton-robot committed Apr 23, 2021
1 parent d46a169 commit 5b68115
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion packages/components/src/components/Trigger/Trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ const Trigger = ({ intl, namespace, trigger }) => {

const { bindings, interceptors, template } = trigger.spec || trigger;
const triggerTemplateName = template.ref || template.name;
const triggerName = trigger.metadata?.name || trigger.name;
// we deliberately don't get the name from a Trigger resource here
// as it will already have a heading on the page so we only want to display
// a header in this component when it's for a trigger in an EventListener
const triggerName = trigger.name;

return (
<div>
Expand Down
6 changes: 4 additions & 2 deletions src/containers/Trigger/Trigger.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ describe('TriggerContainer', () => {

it('renders the trigger resource', async () => {
const triggerName = 'fake_triggerName';
const templateName = 'fake_templateName';
const fetchTriggerSpy = jest
.fn()
.mockImplementation(() => Promise.resolve());
Expand All @@ -144,10 +145,11 @@ describe('TriggerContainer', () => {
match={match}
trigger={{
metadata: { name: triggerName },
spec: { template: { ref: 'foo' } }
spec: { template: { ref: templateName } }
}}
/>
);
expect(queryByText(`Trigger: ${triggerName}`)).toBeTruthy();
expect(queryByText(triggerName)).toBeTruthy();
expect(queryByText(templateName)).toBeTruthy();
});
});

0 comments on commit 5b68115

Please sign in to comment.