-
Notifications
You must be signed in to change notification settings - Fork 195
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
frontend: Fix a circular dependency in KubeObject #2786
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Oleksandr Dubenko <oldubenko@microsoft.com>
…link methods Signed-off-by: Oleksandr Dubenko <oldubenko@microsoft.com>
…keKubeObject Signed-off-by: Oleksandr Dubenko <oldubenko@microsoft.com>
Signed-off-by: Oleksandr Dubenko <oldubenko@microsoft.com>
774c556
to
5f01d58
Compare
path: '/storage/classes', | ||
path: '/storageclasses', |
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.
What exactly are these fixing? I think changing a long standing URL may represent a breaking change.
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 inconsistent with the rest of the paths, every other route is using /apiName/:namespace/:name
const cluster = this.cluster ?? getCluster(); | ||
if (this.isNamespaced) { | ||
return `/c/${cluster}/${this._class().apiName}/${params.namespace}/${params.name}`; | ||
} | ||
return `/c/${cluster}/${this._class().apiName}/${params.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.
Is replacing a function that produces a full URL by a repetition of the different URL parts a good idea? I'd say these changes make things harder to maintain and more error prone.
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.
yeah in the current form it will make it a bit worse.
but if we take this convention a step further and replace all the routes with:
{
details: {
path: '/:apiName/:?namespace/:name',
component: KubeObjectDetails,
},
list: {
path: '/:apiName/',
component: KubeObjectList
}
}
I think it will make it less error prone in the long term
This fixes hot module reloading during development and reenables App.test.tsx
This is a fix for a problem I've been trying to fix for a long time. You might have noticed that during development if you're making any changes the whole page reloads. This is because Hot Module Reload is failing due to a circular dependency. Not every circular dependency causes this kind of failure.
This PR fixes circular dependency: KubeObject -> Router -> All Routes -> The whole app. By reimplementing getDetailsLink and getListLink methods without requiring router. Since routes follow the convention to use apiName, we can take a shortcut and avoid importing and assume the routes follow this convention. The only resources that weren't following this were Storage resources which were updated.
This unfortunately doesn't fix the storybook issue, so that workaround is still there