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
Bug 1873143: fix pipeline details page breadcrumbs in admin perspective #6212
Conversation
/kind bug |
/assign @andrewballantyne |
you would need to fix the same for the Task details page as well |
Thanks @debsmita1, I fix the same for tasks and triggers pages as well. |
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'm seeing a lot of repeat code here... is there not a utility you can create? "DRY" is a principle we should strive to uphold whenever possible.
Recommend 4 hook methods
- usePipelinesBreadcrumbsFor
- useTasksBreadcrumbsFor
- useTriggersBreadcrumbsFor
- useTabbedTableBreadcrumbsFor
That way the generic logic of routing to a new location can be handled in one spot and then you can apply the various differences at a shallow wrapper and each Details page can avoid the repeat logic.
This may not work out 1:1, so please work around any issues with the above idea, with the goal of keeping it simple + avoiding repeating yourself.
@andrewballantyne I added a hook to avoid code repeat. PTAL again. |
/retitle Bug 1873143: fix pipeline details page breadcrumbs in admin perspective |
@vikram-raj: This pull request references Bugzilla bug 1873143, which is invalid:
Comment In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/bugzilla refresh |
@vikram-raj: This pull request references Bugzilla bug 1873143, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker. 3 validation(s) were run on this bug
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
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.
@vikram-raj What was wrong with my suggested path? I feel it's a lot less weight for the caller to do the same thing, making it a simpler interface. Plus moving all namespace calls internal to the breadcrumbsFor method, you align on the one implementation and don't need to wiggle for another one with the use of the selector in the cluster resources cases.
i.e, something like this:
type Match = RMatch<{ url: string }>;
const useTabbedTableBreadcrumbsFor = (kindObj: K8sKind, match: Match, navOption: string) => {
const currentNamespace = useSelector((state: RootState) => getActiveNamespace(state));
const isAdminPerspective =
useSelector((state: RootState) => getActivePerspective(state)) === 'admin';
const namespace = ALL_NAMESPACES_KEY === currentNamespace ? 'all-namespaces' : currentNamespace;
const subTab = pipelinesTab(kindObj);
if (subTab == null) {
return [];
}
return [
{
name: kindObj.labelPlural,
path: isAdminPerspective
? `/${navOption}/ns/${namespace}/${subTab}`
: getBreadcrumbPath(match),
},
{ name: `${kindObj.label} Details`, path: match.url },
];
};
export const usePipelinesBreadcrumbsFor = (kindObj: K8sKind, match: Match) =>
useTabbedTableBreadcrumbsFor(kindObj, match, 'pipelines');
export const useTasksBreadcrumbsFor = (kindObj: K8sKind, match: Match) =>
useTabbedTableBreadcrumbsFor(kindObj, match, 'tasks');
export const useTriggersBreadcrumbsFor = (kindObj: K8sKind, match: Match) =>
useTabbedTableBreadcrumbsFor(kindObj, match, 'triggers');
|
||
const ClusterTaskDetailsPage: React.FC<DetailsPageProps> = (props) => { | ||
const { kindObj, match, kind } = props; | ||
const activeNamespace = useSelector((state: RootState) => getActiveNamespace(state)); |
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 think you can avoid doing this out here if you just bake this functionality into the hook.
This is a bit of annoying usage due to the 3 imports + ts-ignore override.
name: kindObj.labelPlural, | ||
path: | ||
activePerspective === 'admin' | ||
? `/${navOption}/ns/${namespace}${ |
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.
You have a bug here if you're in "all-namespaces" when you go into the details page - leaving via the breadcrumb causes a not found issue with #ALL_NS#
.
@@ -105,7 +105,7 @@ export const ConditionModel: K8sKind = { | |||
id: 'condition', | |||
labelPlural: 'Conditions', | |||
crd: true, | |||
badge: BadgeType.DEV, | |||
badge: BadgeType.TECH, |
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 aligning this.
@@ -403,3 +414,26 @@ export const getSecretAnnotations = (annotation: KeyValuePair) => { | |||
} | |||
return annotations; | |||
}; | |||
|
|||
export const pipelinesTab = (kindObj: K8sKind) => { | |||
switch (kindObj.kind) { |
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 think for this to be an accurate usage, we need to cover the situation where they pass valid models that don't have unique values (the "root" pages).
case PipelineModel.kind:
case TaskModel.kind:
case EventListenerModel.kind:
return '';
That way there is a distinction between null
(not a pipeline tab) and ''
a "root" pipeline tab. This would be my expectation when using a function called pipelinesTab
to get a tab extension for the pipelines pages.
@andrewballantyne Nothing wrong with your suggestion. I was just trying to do it using one hook. Thanks. |
It's important to remember in the functional world, functions are not bad. If you can get a readable and easily understandable set of functions, which avoid magic exposed strings, you have less errors in usage and more understandable use-cases. Wrapping functions should not be frowned upon in the functional world. This is one of the main wins over the OO world. |
Oops, I created a bug with my implementation. Was testing around and I noticed There is another bug here but I think it's unrelated, and that's viewing this tab view in the Dev perspective, it breaks the "single project" methodology... as it has no "dev perspective" blocks to show projects. Not sure what the best solution is for that right now. I will raise it in the tmp-odc-pipelines channel. |
Fixed this issue. |
cc @divyanshiGupta FYI on this solution as we had discussed this several weeks back. Vikram needs another reviewer, if @debsmita1 wants to finish her review or if you want to do it @divyanshiGupta |
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.
Code looks good to me, also verified it locally as well and it works fine for me.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andrewballantyne, divyanshiGupta, vikram-raj 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 |
@vikram-raj: All pull requests linked via external trackers have merged: Bugzilla bug 1873143 has been moved to the MODIFIED state. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Fixes:
https://issues.redhat.com/browse/ODC-4220
Analysis / Root cause:
Pipeline details pages on Admin to have breadcrumbs that take the user to default list page of Pipelines instead of to the tabbed list page from where the user came from
Solution Description:
Pipeline details pages on Admin to have breadcrumbs that take the user back to the tabbed list page from where the user came from.
Screen shots / Gifs for design review:
Unit test coverage report: