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

Views management refactoring #669

Merged
merged 54 commits into from
Aug 19, 2020
Merged

Conversation

ixrock
Copy link
Contributor

@ixrock ixrock commented Aug 10, 2020

Back to managing views with webview (iframe) in favour of smoothest clusters switching

@ixrock ixrock requested review from nevalla, jakolehm and a team August 10, 2020 19:04
@@ -41,8 +40,7 @@ async function main() {
const updater = new AppUpdater()
updater.start();

registerFileProtocol(appProto, app.getPath("userData"));
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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?

Copy link
Collaborator

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

Copy link
Collaborator

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.

Copy link
Contributor

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?

Copy link
Collaborator

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

Copy link
Contributor

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.

Copy link
Collaborator

@Nokel81 Nokel81 left a 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

Comment on lines 68 to 71
const cluster = this.getById(state.id);
if (cluster) {
cluster.updateModel(state)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
const cluster = this.getById(state.id);
if (cluster) {
cluster.updateModel(state)
}
this.getById(state.id)?.updatedModel(state);

}

export function createIpcChannel({ autoBind = true, mode = IpcMode.ASYNC, timeout = 0, handle, channel }: IpcChannelInit) {
channel = `${mode}:${channel}`
Copy link
Collaborator

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 === ""?

Copy link
Contributor Author

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?

Copy link
Collaborator

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"}`

Comment on lines 53 to 58
if (mode === IpcMode.ASYNC) {
event.reply(channel, res);
}
if (mode === IpcMode.SYNC) {
event.returnValue = res;
}
Copy link
Collaborator

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?

Copy link
Contributor Author

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? :)

Copy link
Contributor

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.

if (mode === IpcMode.SYNC) {
ipcRenderer.sendSync(channel, req)
}
return new Promise(async (resolve, reject) => {
Copy link
Collaborator

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?

Copy link
Contributor Author

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

Copy link
Contributor

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?

Copy link
Contributor Author

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.

@nevalla
Copy link
Contributor

nevalla commented Aug 11, 2020

Cluster settings does not open when clicking from left menu. It's working if opening from system menu, but the layout is broken. (FIXED)

@aleksfront
Copy link
Contributor

Cluster settings does not open when clicking from left menu. It's working if opening from system menu, but the layout is broken.

Layout is fixed.

.filter(ctx => ctx.cluster)
.filter(ctx => !this.seenContexts.has(ctx.name))
.forEach(ctx => this.newContexts.add(ctx.name));
localContexts.forEach(({ cluster, name }) => {
Copy link
Contributor

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?

return cluster;
logger.debug(`getClusterForRequest(): ${req.headers.host}${req.url}`)
const clusterId = req.headers.host.split(".")[0]
return this.getCluster(clusterId)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

@ixrock ixrock Aug 12, 2020

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.

ixrock and others added 22 commits August 18, 2020 11:50
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>
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>
ixrock and others added 24 commits August 18, 2020 12:02
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: 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>
@nevalla nevalla force-pushed the views_management_refactoring branch from 599b761 to 07c3143 Compare August 18, 2020 09:12
@nevalla nevalla merged commit 47bcb63 into vue_react_migration Aug 19, 2020
@ixrock ixrock deleted the views_management_refactoring branch August 19, 2020 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants