-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Migrating Vue components to React and stores refactoring #585
Conversation
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
# Conflicts: # src/common/cluster-store.ts # src/common/cluster-store_spec.ts
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
}); | ||
server.on("error", error => { | ||
logger.error(`Can't resolve new port: "${error}"`); | ||
reject(error); |
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.
should there be a defensive server.close()
here?
@@ -10,7 +12,10 @@ jest.mock("net", () => { | |||
return this | |||
}) | |||
address = () => { | |||
return { port: 12345 } | |||
newPort = Math.round(Math.random() * 10000) |
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 use a random number in this test? (this could return 0, which although it would still pass the test, isn't a valid TCP port number)
* A bit of cleaning in Add Cluster page Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Adding head-col to WizardLayout Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Fixing Cluster Settings general layout bugs Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Cluster Status view refactoring Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Install Metrics component refactoring Using notifications for error, removed picking button icon method, simplified button generation. Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Remove icons / checks from RemoveClusterButton Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Fixing colorError in Input styles Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Preventing Input's spellchecking Signed-off-by: alexfront <alex.andreev.email@gmail.com> * ClusterNameSettings refactoring Signed-off-by: alexfront <alex.andreev.email@gmail.com> * ClusterWorkspaceSettings refactoring/fixing Signed-off-by: alexfront <alex.andreev.email@gmail.com> * ClusterProxySetting refactoring Signed-off-by: alexfront <alex.andreev.email@gmail.com> * ClusterPrometheusSetting refactoring Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Clean up Removal section Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Glued InstallMetrics & InstallUserMode into 1 component Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Removing unused styles in Cluster Settings Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Cluster Settings styling Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Adding close button to settings header Signed-off-by: alexfront <alex.andreev.email@gmail.com> * ClusterHomeDirSetting refactoring Signed-off-by: alexfront <alex.andreev.email@gmail.com> * FilePicker restyling Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Fixing Prometheus selector Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Fixing Hashicon Passing cluster name instead of cluster id to prevent icon changing while typing new cluster name Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Minor ClusterSettings fixes Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Increasing opacity for non-interactive icons Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Keep feature install loading state Waiting for props to change before disabling loading state (gray button width spinner) Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Remove arrays in disposeOnUnmount() Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Fix Cluster select behavior Now clicking cluster icon in sidebar always leads to / dashboard. And 'Settings' submenu switches active cluster at first and only the showing Cluster Settings Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Using structuralComparator in feature installer Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Saving input fields on blur Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Setting Select color same as Input color Signed-off-by: alexfront <alex.andreev.email@gmail.com>
Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
Signed-off-by: alexfront <alex.andreev.email@gmail.com>
Signed-off-by: alexfront <alex.andreev.email@gmail.com>
Signed-off-by: alexfront <alex.andreev.email@gmail.com>
Signed-off-by: alexfront <alex.andreev.email@gmail.com>
* Removing legacy browserCheck() utility Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Revert select box-shadow (outline) color Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Allowing to save prometheus service address Signed-off-by: alexfront <alex.andreev.email@gmail.com>
This prevents scrollbar flickering caused by Animation component with 'slide-left' appearing. Signed-off-by: alexfront <alex.andreev.email@gmail.com>
* Normalizing titles size and weight Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Replacing deployment scale icon Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Replacing download logs icon Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Making <h4> tag bigger than <h5> Signed-off-by: alexfront <alex.andreev.email@gmail.com>
* add some simple user store tests Signed-off-by: Sebastian Malton <smalton@mirantis.com> Co-authored-by: Sebastian Malton <smalton@mirantis.com>
syncEnabled: true, | ||
...params, | ||
} | ||
this.init(); |
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 this call is fundamentally broken. It is not awaited (so when the getInstance
call finishes the store isn't even up to date) and the default params to init block from enabling sync.
Especially since the load is just called later anyway.
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.
Wat? :) can you elablorate/provide more examples?
When you call getInstance()
you always have an instance of the store.
Yes, it might be not loaded with a data yet because of async load()
and it doesn't mean it is ready-to-use immediately. Every store has isLoaded
field which takes in account before app ready to start.
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 mean that it seems like a massive foot gun to get one of these and not be able to get the correct data immediately afterwards.
What I mean is that even if you pass into getInstance
the argument { parms: { autoLoad: true } }
it won't be correct.
Further more, in the default case it seems weird for the unbounded promise (which in future versions of node will abort the process if it throws) halts on await this.whenLoaded
. I understand that the point of this is so that enableSync
can be started only once the store has loaded but the current method seems clunky.
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.
not be able to get the correct data immediately afterwards
how you can get it immediately for async store loading? (yes, currently it can be loaded sync from file-system, but it was developed to support async load)
didn't get what you mean about await this.whenLoaded
and what's wrong with it?
electron has similar stuff, like app.whenReady
src/common/base-store.ts
Outdated
* [Symbol.iterator]() { | ||
yield* Object.entries(this.toJSON()); | ||
} |
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 it's not used anywhere why we added it? Sounds like a dead code to me 🤔
src/common/kube-helpers.ts
Outdated
} | ||
|
||
// Logic adapted from dashboard | ||
// see: https://github.com/kontena/kontena-k8s-dashboard/blob/7d8f9cb678cc817a22dd1886c5e79415b212b9bf/client/api/endpoints/nodes.api.ts#L147 |
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 link is not publicly accessible, we should remove it.
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.
removed
src/common/tracker.ts
Outdated
const userPrefs = userStore.getPreferences() | ||
return !!userPrefs.allowTelemetry | ||
} catch (err) { | ||
console.error(`Failed to track "${eventCategory}:${eventAction}"`, err) |
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.
Should this use logger?
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, maybe
@action | ||
protected fromStore({ currentWorkspace, workspaces = [] }: WorkspaceStoreModel) { | ||
if (currentWorkspace) { | ||
this.currentWorkspaceId = currentWorkspace |
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 agree with @jim-docker here, this code is a bit confusing if it first expects that there are always workspaces and then it still checks if there are none. Maybe stop hard if we detect invalid state (== no workspaces)?
this.contextName = cluster.contextName; | ||
this.defaultNamespace = kc.getContextObject(cluster.contextName).namespace | ||
this.url = `http://${this.id}.localhost:${cluster.port}/` | ||
this.kubernetesApi = `http://127.0.0.1:${cluster.port}/${this.id}` |
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.
How these changes are related to Vue->React refactoring (I mean most changes in this file)? I'm a bit afraid that these will cause troubles without more testing.
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.
Vue->React + stores + overall design requires this changes..
throw("getNextAvailablePort() threw: '" + error + "'") | ||
} | ||
return freePort | ||
export async function getFreePort(): Promise<number> { |
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.
Same here, how this is related to Vue->React refactoring?
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 not like normal converting single vue->react component :)
so please percept this like almost kick-starting new app with extra refactoring (only where it's simple or neccesary)
"electron-builder": "^22.7.0", | ||
"electron-notarize": "^0.3.0", | ||
"electron-rebuild": "^1.11.0", |
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.
electron-rebuild not required if you use electron-builder, please consider to remove excess dependency from devDependencies
I think we should remove this.
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 used in yarn rebuild-pty
(this commands helps when switching electron versions)
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 wondering why it's caring about devDependencies
🤔
Signed-off-by: Roman <ixrock@gmail.com>
* add some basic workspace store tests Signed-off-by: Sebastian Malton <smalton@mirantis.com> Co-authored-by: Sebastian Malton <smalton@mirantis.com>
* Views management refactoring Signed-off-by: Roman <ixrock@gmail.com> Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com>
Most noticeable changes:
ipc
In follow-up PRs
cluster-menu.tsx
(fixed in add drag and drop capabilities for the order of cluster icons on the side bar #623)