-
Notifications
You must be signed in to change notification settings - Fork 30
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
move object resources to new nav item #895
Conversation
SanjalKatiyar
commented
Jun 9, 2023
•
edited
Loading
edited
[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 |
} from '@openshift-console/dynamic-plugin-sdk'; | ||
import { useActiveNamespace } from '@openshift-console/dynamic-plugin-sdk-internal'; |
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.
@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.
32a1f3b
to
9e1d7e9
Compare
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) | ||
); |
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.
OBC tests are flaky on Project creation step... this change should fix that !
/test odf-console-e2e-aws |
3 similar comments
/test odf-console-e2e-aws |
/test odf-console-e2e-aws |
/test odf-console-e2e-aws |
isInline | ||
title={t('Address form errors to proceed')} | ||
<> | ||
<NamespaceBar /> |
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.
Instead of using useActiveNamespace
why not pass a onNamespaceChange
prop to this component?
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 are 2 reasons for that:
- We are already using "useActiveNamespace" at other places, so I used here as well.
- Namespace is already stored and passed down by console via context, no need to use local "useState" variable to store that info again.
const resourcePath = `${referenceForModel( | ||
NooBaaObjectBucketClaimModel | ||
)}/${resource.metadata.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.
Could we keep on using resourcePathFromModel
we could perhaps append /odf/resources
in front? Unless there is a specific reason to avoid that.
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 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 }); |
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.
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?
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.
make sense !
52629d4
to
d8a5967
Compare
cypress/views/obcPage.ts
Outdated
@@ -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']); |
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.
cy.clickNavLink(['Storage', 'Object Storage']); | |
commonFlows.navigateToObjectStore(); |
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.
ack...
cypress/views/obcPage.ts
Outdated
export const obcNavigate = { | ||
navigateToOBC: () => { | ||
cy.clickNavLink(['Storage', 'Object Storage']); | ||
cy.byLegacyTestID('horizontal-link-Object Bucket Claims').first().click(); |
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.
Why do we need first
?
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 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.
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.
let's remove first
if not necessary.
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.
ack...
"exact": false, | ||
"path": "/k8s/ns/:ns/objectbucket.io~v1alpha1~ObjectBucketClaim/~new/form", | ||
"exact": true, | ||
"path": "/odf/resource/objectbucket.io~v1alpha1~ObjectBucketClaim/create/~new", |
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 is inconsistency in the URL patterns.
/odf/resource/ns/:namespace/objectbucket.io~v1alpha1~ObjectBucketClaim/:resourceName
Some URLS support NS and some don't.
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.
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:
- so that it matches with other horizontal tabs.
- 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.
- now since list page did not had URL, I kept it same for create page as well.
- Only details page is something which has ns in URL and it is kind of separate from the list/create flow 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.
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.
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.
ack... will create a story/task...
}, [extensions, haveExtensionsResolved, staticPages]); | ||
}; | ||
|
||
export const convertHorizontalNavTabToNav = ( |
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.
export const convertHorizontalNavTabToNav = ( | |
export const convertHorizontalNavTabToNavPage = ( |
ResolvedCodeRefProperties<HorizontalNavTabExtensionProps>; | ||
|
||
const sortPages = ( | ||
horizontalNavTabs: ResolvedCodeRefProperties<HorizontalNavTabExtensionProps>[] |
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.
horizontalNavTabs: ResolvedCodeRefProperties<HorizontalNavTabExtensionProps>[] | |
horizontalNavTabs: HorizontalNavProps[] |
import { | ||
HorizontalNavTabExtensionProps, | ||
HorizontalNavTab, | ||
} from 'packages/odf-plugin-sdk/extensions'; |
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 looks wrong to me.
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.
u mean import packages/odf-plugin-sdk/extensions
do not have @
?? or something else...
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.
yes
packages/odf/constants/common.ts
Outdated
export const ALL_NAMESPACES = 'all-namespaces'; | ||
export const DEFAULT_NS = 'default'; |
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 is better suited for shared.
{ | ||
"type": "console.page/route", | ||
"properties": { | ||
"path": ["/odf/object-storage"], |
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.
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
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.
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
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.
only change I did is to make /odf/cluster
to /odf/object-storage
, rest everything is same as current...
const isDashboardTab = React.useMemo( | ||
() => | ||
compose(isHorizontalNavTab, (e: Extension) => { | ||
if (e.properties.contextId === ODF_DASHBOARD_CONTEXT) return e; | ||
}), | ||
[] | ||
); |
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 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.
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.
make sense... not sure why I used a hook !
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.
missing
const isObjectServiceTab = React.useMemo( | ||
() => | ||
compose(isHorizontalNavTab, (e: Extension) => { | ||
if (e.properties.contextId === OBJECT_SERVICE_CONTEXT) return e; | ||
}), | ||
[] | ||
); |
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.
useMemo
should not return a function there is already useCallback
for that.
7fb21fd
to
f620306
Compare
/test odf-console-e2e-aws |
f620306
to
87849dd
Compare
/lgtm |
/test odf-console-e2e-aws |
1 similar comment
/test odf-console-e2e-aws |
/test odf-console-e2e-aws |