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

Bug 1873143: fix pipeline details page breadcrumbs in admin perspective #6212

Merged
merged 1 commit into from Aug 31, 2020

Conversation

vikram-raj
Copy link
Member

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:
Kapture 2020-08-05 at 3 26 28

@vikram-raj
Copy link
Member Author

/kind bug

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Aug 4, 2020
@vikram-raj
Copy link
Member Author

/assign @andrewballantyne

@debsmita1
Copy link
Contributor

you would need to fix the same for the Task details page as well

@vikram-raj
Copy link
Member Author

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.

Copy link
Contributor

@andrewballantyne andrewballantyne left a 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.

@vikram-raj
Copy link
Member Author

@andrewballantyne I added a hook to avoid code repeat. PTAL again.

@vikram-raj
Copy link
Member Author

/retitle Bug 1873143: fix pipeline details page breadcrumbs in admin perspective

@openshift-ci-robot openshift-ci-robot changed the title fix pipeline details page breadcrumbs in admin perspective Bug 1873143: fix pipeline details page breadcrumbs in admin perspective Aug 27, 2020
@openshift-ci-robot openshift-ci-robot added the bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. label Aug 27, 2020
@openshift-ci-robot
Copy link
Contributor

@vikram-raj: This pull request references Bugzilla bug 1873143, which is invalid:

  • expected the bug to target the "4.6.0" release, but it targets "---" instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

Bug 1873143: fix pipeline details page breadcrumbs in admin perspective

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.

@openshift-ci-robot openshift-ci-robot added the bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. label Aug 27, 2020
@vikram-raj
Copy link
Member Author

/bugzilla refresh

@openshift-ci-robot openshift-ci-robot added bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. and removed bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. labels Aug 27, 2020
@openshift-ci-robot
Copy link
Contributor

@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
  • bug is open, matching expected state (open)
  • bug target release (4.6.0) matches configured target release for branch (4.6.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

/bugzilla refresh

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.

Copy link
Contributor

@andrewballantyne andrewballantyne left a 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));
Copy link
Contributor

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}${
Copy link
Contributor

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,
Copy link
Contributor

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) {
Copy link
Contributor

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.

@vikram-raj
Copy link
Member Author

@andrewballantyne Nothing wrong with your suggestion. I was just trying to do it using one hook. Thanks.

@andrewballantyne
Copy link
Contributor

@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.

@andrewballantyne
Copy link
Contributor

i.e, something like this:

Oops, I created a bug with my implementation. Was testing around and I noticed all-namespaces is not ns/all-namespaces. Please correct that @vikram-raj

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.

@vikram-raj
Copy link
Member Author

Oops, I created a bug with my implementation. Was testing around and I noticed all-namespaces is not ns/all-namespaces. Please correct that @vikram-raj

Fixed this issue.

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 31, 2020
@andrewballantyne
Copy link
Contributor

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

Copy link
Contributor

@divyanshiGupta divyanshiGupta left a 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

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 31, 2020
@openshift-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit d98477c into openshift:master Aug 31, 2020
@openshift-ci-robot
Copy link
Contributor

@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:

Bug 1873143: fix pipeline details page breadcrumbs in admin perspective

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.

@spadgett spadgett added this to the v4.6 milestone Sep 1, 2020
@vikram-raj vikram-raj deleted the ODC-4220 branch September 2, 2020 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/dev-console Related to dev-console kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants