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 pipeline trigger resource pages and related links in details pages #5005
Add pipeline trigger resource pages and related links in details pages #5005
Conversation
/kind feature |
/assign @andrewballantyne |
5b3844f
to
88a3b46
Compare
@@ -31,6 +37,22 @@ export const PipelineRunDetails: React.FC<PipelineRunDetailsProps> = ({ obj: pip | |||
</dd> | |||
</dl> | |||
<br /> | |||
<dl> | |||
<dt>Triggered by</dt> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, you overstepped your story. Please undo changes here. They'll not be adequate to cover the need. See my PR if you're curious how rough it was lol. There is a need to get the username and apply it to the PipelineRun (can't just use the current user at time of read).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, this is the story that covers the Pipeline Run / Trigged By content: https://issues.redhat.com/browse/ODC-3323
@@ -57,4 +75,28 @@ describe('PipelineRun details page', () => { | |||
.filter({ kind: referenceForModel(PipelineResourceModel) }); | |||
expect(resources).toHaveLength(0); | |||
}); | |||
|
|||
it('should return username when labels are not present in the pipeline run object', () => { | |||
expect(wrapper.find('[data-test-id="triggered-by"]').text()).toBe('kube:admin'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naturally undo all of these as well.
const { template, bindings } = | ||
eventListener?.spec?.triggers?.reduce( | ||
(res, trigger) => { | ||
res.template.push(trigger.template.name); | ||
trigger.bindings.map((b) => res.bindings.push(b.name)); | ||
return res; | ||
}, | ||
{ ...resources }, | ||
) || resources; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { template, bindings } = | |
eventListener?.spec?.triggers?.reduce( | |
(res, trigger) => { | |
res.template.push(trigger.template.name); | |
trigger.bindings.map((b) => res.bindings.push(b.name)); | |
return res; | |
}, | |
{ ...resources }, | |
) || resources; | |
const { template, bindings } = | |
(eventListener.spec.triggers || []).reduce( | |
(acc, trigger) => ({ | |
bindings: [...acc.bindings, trigger.bindings], | |
template: [...acc.template, trigger.template], | |
}), | |
{ template: [], bindings: [] }, | |
); |
Rule of thumb is not to mutate outside resources during a .map
or .reduce
as they are intended to be as pure as possible. It's just easier for others to rationalize them out if you keep to these guidelines.
Also, EventListenerKind
has spec.triggers
as being a required path. So we either have an invalid type or unnecessary null-checks.
One last thing is that .reduce
will return the default if the array is empty so this structure allows you not to need to do an extra ||
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated it.
import ResourceLinkList from '../resource-overview/ResourceLinkList'; | ||
|
||
export interface EventListenerDetailsProps { | ||
obj: K8sResourceKind; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
obj: K8sResourceKind; | |
obj: EventListenerKind; |
import { ResourceLink } from '@console/internal/components/utils'; | ||
import './ResourceLinkList.scss'; | ||
|
||
type ResourceLinkListProps = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we change the API of this to make it easier to call.
Model, "links" & namespace is all we really need.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In ResourceLink component kind
determines which badge to use, so it is also required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand what the concern is... you can compute the values with the ModelKind:
// calling file
<ResourceLinkList model={TriggerBindingModel} ... />
// ResourceLinkList
const title = model.labelPlural;
const kind = referenceForModel(model);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the api to make it easier to call
</div> | ||
)} | ||
{pipeline.spec && pipeline.spec.tasks && ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦 Oh right... Pipeline spec is poorly typed. I appreciate you updating this to match types - but spec
is never not there to have a proper Pipeline and since 0.9 or so of the Operator, you have to have at least 1 task.
Maybe we just update the type of the Pipeline kind and remove this check.
<React.Fragment key={name}> | ||
<dd> | ||
<ResourceLink kind={kind} name={name} namespace={namespace} title={name} inline /> | ||
</dd> | ||
</React.Fragment> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<React.Fragment key={name}> | |
<dd> | |
<ResourceLink kind={kind} name={name} namespace={namespace} title={name} inline /> | |
</dd> | |
</React.Fragment> | |
<dd key={name}> | |
<ResourceLink kind={kind} name={name} namespace={namespace} title={name} inline /> | |
</dd> |
Fragments are there to support multiple "root" children. Recommend you read the Fragments page on the React docs as this is not the first time I have mentioned a fragment issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not sure why added this 🤦 , clearly we dont need this, will remove it.
6c2768c
to
82834f2
Compare
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few questions for you!
- Does this PR cover adding trigger information on the Pipeline Run details page? I don't see a screenshot of that.
- When Trigger Templates are shown, I think they should have the associated URL below them, at least that was the design. I know that piece of information is optional, but just checking
- On the Pipeline details page, can we move the Trigger Templates above the Tasks : https://docs.google.com/document/d/11vShZz7TX7b8YUyTG5zBMZXFnQmPEJ8nqUapCL70yyk/edit#heading=h.woem8ztgbvh5
@serenamarie125 I have moved the trigger template above the Tasks section. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the rework & explanations @karthikjeeyar LGTM! Approved by UX
@@ -8,7 +8,6 @@ import { PipelineModel, PipelineResourceModel } from '../../../models'; | |||
export interface PipelineRunDetailsProps { | |||
obj: PipelineRun; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Net zero changes please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
@@ -10,7 +10,6 @@ import PipelineRunVisualization from '../PipelineRunVisualization'; | |||
|
|||
const mockPipelineRun = | |||
pipelineTestData[PipelineExampleNames.SIMPLE_PIPELINE].pipelineRuns[DataState.SUCCESS]; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Net zero changes please.
import { ResourceLink } from '@console/internal/components/utils'; | ||
import './ResourceLinkList.scss'; | ||
|
||
type ResourceLinkListProps = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand what the concern is... you can compute the values with the ModelKind:
// calling file
<ResourceLinkList model={TriggerBindingModel} ... />
// ResourceLinkList
const title = model.labelPlural;
const kind = referenceForModel(model);
const EventListenerDetails: React.FC<EventListenerDetailsProps> = ({ obj: eventListener }) => { | ||
const { template, bindings } = (eventListener?.spec?.triggers || []).reduce( | ||
(acc, trigger) => ({ | ||
bindings: [...acc.bindings, ...trigger.bindings.map((binding) => binding.name)], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh right, my example neglected that it was an array. Hmmm... the array of objects is there because bindings can have two types ClusterTriggerBinding and TriggerBinding... can you add this to the tech debt ticket? I think we need to swing back once we get an operator update as ClusterTriggerBinding doesn't exist on 0.10.8 😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Task to update binding logic for 10.0.8 https://issues.redhat.com/browse/ODC-3557
...s/dev-console/src/components/pipelines/detail-page-tabs/pipeline-details/PipelineDetails.tsx
Outdated
Show resolved
Hide resolved
Oh crud! I forgot about this on my first review pass. Please add this @karthikjeeyar - the URL is awkward to get so we'll have to write another hook for this. I'll see what I can write for this while you're asleep :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please focus on the spec and if it makes it optional. We need to start aligning our Kind definitions and our Code. It becomes unruly having to guess every time you write new code seeing optionals literally everywhere.
frontend/packages/dev-console/src/components/pipelines/utils/triggers.ts
Outdated
Show resolved
Hide resolved
frontend/packages/dev-console/src/components/pipelines/utils/triggers.ts
Outdated
Show resolved
Hide resolved
frontend/packages/dev-console/src/components/pipelines/utils/triggers.ts
Outdated
Show resolved
Hide resolved
frontend/packages/dev-console/src/components/pipelines/utils/triggers.ts
Outdated
Show resolved
Hide resolved
frontend/packages/dev-console/src/components/pipelines/utils/triggers.ts
Outdated
Show resolved
Hide resolved
frontend/packages/dev-console/src/components/pipelines/utils/triggers.ts
Outdated
Show resolved
Hide resolved
.odc-trigger-template-list { | ||
margin-bottom: var(--pf-global--spacer--lg); | ||
&__url { | ||
margin-left: calc(10 * var(--pf-global--BorderWidth--lg)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol, what? I know we request for pf variables... but this is a bit of malicious compliance lol. I'll have to look at what you're trying to do lol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah indeed... we'll need to iterate on this solution heh... I'd prefer a px number over "10 border widths" lol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This var(--pf-global--BorderWidth--lg)
is in px, so calc(10* 3px) is resulting in 30px.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to a pixel value. Using a variable incorrectly is not a good idea.
...ckages/dev-console/src/components/pipelines/resource-overview/TriggerTemplateResouceLink.tsx
Outdated
Show resolved
Hide resolved
...ckages/dev-console/src/components/pipelines/resource-overview/TriggerTemplateResouceLink.tsx
Outdated
Show resolved
Hide resolved
frontend/packages/dev-console/src/components/pipelines/resource-overview/ResourceLinkList.tsx
Outdated
Show resolved
Hide resolved
03031f8
to
8e3cbf8
Compare
...end/packages/dev-console/src/components/pipelineruns/detail-page-tabs/PipelineRunDetails.tsx
Outdated
Show resolved
Hide resolved
...kages/dev-console/src/components/pipelines/resource-overview/TriggerTemplateResourceLink.tsx
Outdated
Show resolved
Hide resolved
.odc-trigger-template-list { | ||
margin-bottom: var(--pf-global--spacer--lg); | ||
&__url { | ||
margin-left: calc(10 * var(--pf-global--BorderWidth--lg)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to a pixel value. Using a variable incorrectly is not a good idea.
8e3cbf8
to
e4a999b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andrewballantyne, karthikjeeyar, serenamarie125 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Fixes:- https://issues.redhat.com/browse/ODC-3427
Analysis / Root cause:
User should be able to traverse between the trigger resources quickly from the details page.
Solution Description:
Added custom pages for the trigger resources and added the links of the related resources.
screenshot:
Pipeline Details
Trigger Template Details
Eventlistener-details
Unit test:
Browser conformance:
cc: @serenamarie125 @andrewballantyne