-
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
Views management refactoring #669
Conversation
@@ -41,8 +40,7 @@ async function main() { | |||
const updater = new AppUpdater() | |||
updater.start(); | |||
|
|||
registerFileProtocol(appProto, app.getPath("userData")); |
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 appProto
has been removed?
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.
Because it's never used
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.
Might be a dumb question but how do we display uploaded cluster icons then?
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 switched to saving the base64 encoding of them in the user 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.
It removes the filename issue that we were seeing with some unicode characters, and it removes the security problems when running on dev mode.
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 switched to saving the base64 encoding of them in the user store
Ok, do we have a migration for 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 did not code one up, I should do that then
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 did not code one up, I should do that then
Yes we should have a migration. Otherwise Lens will drop all the existing cluster icons on upgrade.
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.
Looks good from a top level
src/common/cluster-store.ts
Outdated
const cluster = this.getById(state.id); | ||
if (cluster) { | ||
cluster.updateModel(state) | ||
} |
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 cluster = this.getById(state.id); | |
if (cluster) { | |
cluster.updateModel(state) | |
} | |
this.getById(state.id)?.updatedModel(state); |
src/common/ipc.ts
Outdated
} | ||
|
||
export function createIpcChannel({ autoBind = true, mode = IpcMode.ASYNC, timeout = 0, handle, channel }: IpcChannelInit) { | ||
channel = `${mode}:${channel}` |
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.
Shouldn't it be an error to given channel === ""
?
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 critical imo, why not an empty string as a 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.
Just seems like a weird that a channel called "sync:"
or "async:"
could be made. Another possible solution could be
channel = `${mode}:${channel || "default"}`
src/common/ipc.ts
Outdated
if (mode === IpcMode.ASYNC) { | ||
event.reply(channel, res); | ||
} | ||
if (mode === IpcMode.SYNC) { | ||
event.returnValue = res; | ||
} |
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.
shouldn't this either be a switch
or if ... else if
?
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.
doesn't really matter, only if it's a question of code-readability? :)
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.
IMHO if ... else if
would be better here.
src/common/ipc.ts
Outdated
if (mode === IpcMode.SYNC) { | ||
ipcRenderer.sendSync(channel, req) | ||
} | ||
return new Promise(async (resolve, reject) => { |
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 are we returning a promise if the mode is sync
?
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.
maybe we should, haven't even tested sync
mode and it's better to use this "as last resort" as defined in docs:
https://www.electronjs.org/docs/api/ipc-renderer#ipcrenderersendsyncchannel-args
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.
Just thinking that do we need sync
mode here if we are only using async messaging?
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.
Well, this IPC
helper is intended to be multi-functional, so I would keep it, but have to test if it's really works as expected.
|
Layout is fixed. |
src/common/user-store.ts
Outdated
.filter(ctx => ctx.cluster) | ||
.filter(ctx => !this.seenContexts.has(ctx.name)) | ||
.forEach(ctx => this.newContexts.add(ctx.name)); | ||
localContexts.forEach(({ cluster, 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.
I think this is matter of taste. I would revert this change as it's not related to views management at all, right?
src/main/cluster-manager.ts
Outdated
return cluster; | ||
logger.debug(`getClusterForRequest(): ${req.headers.host}${req.url}`) | ||
const clusterId = req.headers.host.split(".")[0] | ||
return this.getCluster(clusterId) |
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 logic has been removed? Don't we use 127.0.0.1:<port>/uuid
anymore anywhere?
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.
Seems so.. Looks like outdated code from very beginning of lens-app.
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 asked because I port/uuid
addresses were used when doing requests outside of renderer (wildcard dns to localhost works only within browser scope). Anyway I don't like to see changes that are totally outside of PR scope, it makes review unnecessary complicated.
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.
Ok, reverted back. Someone should check if this is actually works, cause top comment:
// lens-server is connecting to 127.0.0.1:<port>/<uid>
which unclear in terms of what you saying how this might be used outside.
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: Lauri Nevala <lauri.nevala@gmail.com>
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: Lauri Nevala <lauri.nevala@gmail.com>
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: Lauri Nevala <lauri.nevala@gmail.com>
* 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: Roman <ixrock@gmail.com> Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
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: Lauri Nevala <lauri.nevala@gmail.com>
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: Lauri Nevala <lauri.nevala@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com> Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
…"404"-route 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: Lauri Nevala <lauri.nevala@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com> Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
* add parsing of quota values which are non-numeric in the general case * add unit tests Signed-off-by: Sebastian Malton <smalton@mirantis.com> Co-authored-by: Sebastian Malton <smalton@mirantis.com> Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
* adding port-forward for containers in pods address review comments use more idiomatic approach for async code move some files in advance of merge conflict with Lens restructure work * Separate the port forward links in the UI (so they don't all spin when one link is clicked) * minor fixes * addressed review comments (replaced <p> with <div>, moved key attribute to proper element) * fix lint issue * removed extraneous <div> from pod container port details Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
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: Lauri Nevala <lauri.nevala@gmail.com>
Signed-off-by: alexfront <alex.andreev.email@gmail.com> Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com> Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
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: Lauri Nevala <lauri.nevala@gmail.com>
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: Lauri Nevala <lauri.nevala@gmail.com>
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: Lauri Nevala <lauri.nevala@gmail.com>
Signed-off-by: alexfront <alex.andreev.email@gmail.com> Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
Allowing to check http(s) and format without domain like http://localhost:8080 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: Lauri Nevala <lauri.nevala@gmail.com>
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: Lauri Nevala <lauri.nevala@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com> Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
* Reconnecting selected cluster Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Cleaning up ClusteStatus render() method Signed-off-by: alexfront <alex.andreev.email@gmail.com>
Signed-off-by: Roman <ixrock@gmail.com> Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
* Adding 'centering' option to WizardLayout Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Using centered layout in Cluster Settings Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Restyling Preferences section Signed-off-by: alexfront <alex.andreev.email@gmail.com> * Simplifying Helm loading state Signed-off-by: alexfront <alex.andreev.email@gmail.com> Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
* replace webview-tag to iframe with nodeIntegrationInSubFrames=true Signed-off-by: Roman <ixrock@gmail.com> * clean up Signed-off-by: Roman <ixrock@gmail.com> * chore: fix type ipc#handle Signed-off-by: Roman <ixrock@gmail.com> Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
599b761
to
07c3143
Compare
Back to managing views with
webview
(iframe) in favour of smoothest clusters switching