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

move object resources to new nav item #895

Merged

Conversation

SanjalKatiyar
Copy link
Collaborator

@SanjalKatiyar SanjalKatiyar commented Jun 9, 2023

Screenshot 2023-06-09 at 8 08 04 PM Screenshot 2023-06-09 at 8 08 13 PM Screenshot 2023-06-09 at 8 08 21 PM Screenshot 2023-06-09 at 8 08 31 PM

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jun 9, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: SanjalKatiyar

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-ci openshift-ci bot added the approved label Jun 9, 2023
@SanjalKatiyar SanjalKatiyar changed the title move object resources to new nav item [WIP] move object resources to new nav item Jun 9, 2023
} from '@openshift-console/dynamic-plugin-sdk';
import { useActiveNamespace } from '@openshift-console/dynamic-plugin-sdk-internal';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bipuladh ended up using this, which is the cleanest way to do things...
we have alternatives like passing NS via URL or using Context, but that will need handling multiple edge conditions (to prevent small small bugs) and IMHO is not the best way. Adding one more component for tech-debt for this is good to have in core sdk.

@SanjalKatiyar SanjalKatiyar changed the title [WIP] move object resources to new nav item move object resources to new nav item Jun 12, 2023
Comment on lines +34 to +40
cy.byTestID('dropdown-text-filter')
.clear()
.then(() => cy.byTestID('dropdown-text-filter').should('be.empty'))
.then(() => cy.byTestID('dropdown-text-filter').type(projectName))
.then(() =>
cy.byTestID('dropdown-text-filter').should('have.value', projectName)
);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OBC tests are flaky on Project creation step... this change should fix that !

@SanjalKatiyar
Copy link
Collaborator Author

/test odf-console-e2e-aws

3 similar comments
@SanjalKatiyar
Copy link
Collaborator Author

/test odf-console-e2e-aws

@SanjalKatiyar
Copy link
Collaborator Author

/test odf-console-e2e-aws

@SanjalKatiyar
Copy link
Collaborator Author

/test odf-console-e2e-aws

isInline
title={t('Address form errors to proceed')}
<>
<NamespaceBar />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using useActiveNamespace why not pass a onNamespaceChange prop to this component?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are 2 reasons for that:

  1. We are already using "useActiveNamespace" at other places, so I used here as well.
  2. Namespace is already stored and passed down by console via context, no need to use local "useState" variable to store that info again.

Comment on lines +451 to +453
const resourcePath = `${referenceForModel(
NooBaaObjectBucketClaimModel
)}/${resource.metadata.name}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we keep on using resourcePathFromModel we could perhaps append /odf/resources in front? Unless there is a specific reason to avoid that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don;t have anything for or against it, just "resourcePathFromModel" will add "k8s" to the path as well which made sense earlier because earlier list page and creation page were using generic Routes which had "k8s" in its path as well.

Now, when OB/OBC are separate tabs, list/creation page don;t have "k8s" in its path and to keep consistent I did same for the details page as well !!

if (!haveAlreadyResolvedOnce.current && haveExtensionsResolved) {
haveAlreadyResolvedOnce.current = true;
}
useSortPages({ extensions, haveExtensionsResolved, pages, setPages });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
useSortPages({ extensions, haveExtensionsResolved, pages, setPages });
const pages = useSortPages({ extensions, haveExtensionsResolved});

The root state of all these pages are the extensions which is stored in a state somewhere. If we are to use a hook then we can potentially avoid keeping an intermeddiate state to store pages. WDYT?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense !

@bipuladh bipuladh self-requested a review June 16, 2023 12:08
@SanjalKatiyar SanjalKatiyar force-pushed the object_nav branch 2 times, most recently from 52629d4 to d8a5967 Compare June 16, 2023 13:03
@@ -3,6 +3,13 @@ import { app } from '../support/pages/app';
import { MINUTE } from '../utils/consts';
import { listPage } from './list-page';

export const obcNavigate = {
navigateToOBC: () => {
cy.clickNavLink(['Storage', 'Object Storage']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cy.clickNavLink(['Storage', 'Object Storage']);
commonFlows.navigateToObjectStore();

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack...

export const obcNavigate = {
navigateToOBC: () => {
cy.clickNavLink(['Storage', 'Object Storage']);
cy.byLegacyTestID('horizontal-link-Object Bucket Claims').first().click();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need first?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think it is needed, at many places we are using cy.byLegacyTestID('horizontal-link-Storage Systems').first().click();, I just copied this line and made it OBC instead of SS.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's remove first if not necessary.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack...

"exact": false,
"path": "/k8s/ns/:ns/objectbucket.io~v1alpha1~ObjectBucketClaim/~new/form",
"exact": true,
"path": "/odf/resource/objectbucket.io~v1alpha1~ObjectBucketClaim/create/~new",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is inconsistency in the URL patterns.
/odf/resource/ns/:namespace/objectbucket.io~v1alpha1~ObjectBucketClaim/:resourceName
Some URLS support NS and some don't.

Copy link
Collaborator Author

@SanjalKatiyar SanjalKatiyar Jun 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually this was intensional on my end, we need to decide what is the best way to go ??

here all tabs are horizaontalNavs and expect OBC others are either clusterwide resource or openshift-storage specific (hence no ns in URL).
now for OBC tab, I did not add ns to the url because:

  1. so that it matches with other horizontal tabs.
  2. currently I have added OBC tab via extension so that console can handle all the filtering based upon "RGW" "OBC" etc flags. If I need to pass ns to the URL of OBC list page then I need to add OBC tab as a static page (similar to how we add "Overview" page to ODF dashboard) and will have to again do all the filtering based on the required/disallow flags.
  3. now since list page did not had URL, I kept it same for create page as well.
  4. Only details page is something which has ns in URL and it is kind of separate from the list/create flow as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we are moving everything under one root then lets keep consistency in the URLs. I am fine with creating another story for looking into URLs but this is an important detail.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack... will create a story/task...

}, [extensions, haveExtensionsResolved, staticPages]);
};

export const convertHorizontalNavTabToNav = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const convertHorizontalNavTabToNav = (
export const convertHorizontalNavTabToNavPage = (

ResolvedCodeRefProperties<HorizontalNavTabExtensionProps>;

const sortPages = (
horizontalNavTabs: ResolvedCodeRefProperties<HorizontalNavTabExtensionProps>[]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
horizontalNavTabs: ResolvedCodeRefProperties<HorizontalNavTabExtensionProps>[]
horizontalNavTabs: HorizontalNavProps[]

import {
HorizontalNavTabExtensionProps,
HorizontalNavTab,
} from 'packages/odf-plugin-sdk/extensions';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks wrong to me.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u mean import packages/odf-plugin-sdk/extensions do not have @ ?? or something else...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Comment on lines 23 to 24
export const ALL_NAMESPACES = 'all-namespaces';
export const DEFAULT_NS = 'default';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is better suited for shared.

{
"type": "console.page/route",
"properties": {
"path": ["/odf/object-storage"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's kind of confusing these URL patterns. This is the root path but for OBC details the route is /odf/resource/ns/:namespace/objectbucket.io~v1alpha1~ObjectBucketClaim/:resourceName

Copy link
Collaborator Author

@SanjalKatiyar SanjalKatiyar Jun 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn;t it same as what is happening right now ??
currently say for BackingStore list page we have /odf/cluster as root, but details page have /odf/resource/noobaa.io~v1alpha1~BackingStore/noobaa-default-backing-store

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only change I did is to make /odf/cluster to /odf/object-storage, rest everything is same as current...

Comment on lines 95 to 101
const isDashboardTab = React.useMemo(
() =>
compose(isHorizontalNavTab, (e: Extension) => {
if (e.properties.contextId === ODF_DASHBOARD_CONTEXT) return e;
}),
[]
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const isDashboardTab = React.useMemo(
() =>
compose(isHorizontalNavTab, (e: Extension) => {
if (e.properties.contextId === ODF_DASHBOARD_CONTEXT) return e;
}),
[]
);
const isDashboardTab = (e) =>
isHorizontalNavTab(e) && (e.properties.contextId === ODF_DASHBOARD_CONTEXT)
);

This can prolly live outside the component safely.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sense... not sure why I used a hook !

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing

Comment on lines 38 to 44
const isObjectServiceTab = React.useMemo(
() =>
compose(isHorizontalNavTab, (e: Extension) => {
if (e.properties.contextId === OBJECT_SERVICE_CONTEXT) return e;
}),
[]
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useMemo should not return a function there is already useCallback for that.

@SanjalKatiyar SanjalKatiyar force-pushed the object_nav branch 2 times, most recently from 7fb21fd to f620306 Compare June 20, 2023 07:27
@SanjalKatiyar
Copy link
Collaborator Author

/test odf-console-e2e-aws

@bipuladh
Copy link
Contributor

/lgtm

@SanjalKatiyar
Copy link
Collaborator Author

/test odf-console-e2e-aws

1 similar comment
@SanjalKatiyar
Copy link
Collaborator Author

/test odf-console-e2e-aws

@SanjalKatiyar
Copy link
Collaborator Author

/test odf-console-e2e-aws

@openshift-merge-robot openshift-merge-robot merged commit f6c11c1 into red-hat-storage:master Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants