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
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
7d3e876
part 1
ixrock Aug 5, 2020
8925186
part 2
ixrock Aug 6, 2020
a78d5a0
cluster-view battling -- part 1 (iframe failing support nodeintegration)
ixrock Aug 6, 2020
5452fdb
ipc-refactoring, fixes
ixrock Aug 6, 2020
09c765c
cluster-view battling -- part 2
ixrock Aug 7, 2020
2287332
cluster-view battling -- part 3
ixrock Aug 7, 2020
2894f31
fixes
ixrock Aug 7, 2020
1204e9e
fix menu navigation
ixrock Aug 7, 2020
3e86729
cluster-view bugfixing, attempt 100500..
ixrock Aug 7, 2020
9818c07
Fixing Cluster Settings layout (#651)
aleksfront Aug 7, 2020
795a98c
base-migration-branch merge-fix
ixrock Aug 7, 2020
7364cb7
cluster-view reworks
ixrock Aug 8, 2020
0b80032
todo/fixme: hide active view on disconnect
ixrock Aug 8, 2020
ceca2d7
moved some runtime deps from dev-deps-list in package.json
ixrock Aug 10, 2020
8e6d886
cluster-view fixes
ixrock Aug 10, 2020
7b5092d
cluster-view more fixes & UX optimizations
ixrock Aug 10, 2020
6f6680b
fix: cluster-manager initial loading, redirect to startPage from any …
ixrock Aug 10, 2020
4ef26be
fix: handle navigation from global menu
ixrock Aug 10, 2020
d2be0e4
more fixes
ixrock Aug 10, 2020
8e626ee
Fix CRD api parsing (#622)
nevalla Jul 31, 2020
b3f97a6
Fix Resource Quota Rendering (#624)
Nokel81 Aug 4, 2020
6293dad
adding port-forward for containers in pods (#528)
jim-docker Aug 7, 2020
3a50255
use the Kubernetes regex for matching system names (#659)
Nokel81 Aug 7, 2020
df764ca
Removing legacy browserCheck() utility
aleksfront Aug 10, 2020
26e93e7
Revert select box-shadow (outline) color
aleksfront Aug 10, 2020
aa63624
Allowing to save prometheus service address
aleksfront Aug 10, 2020
bb382d2
Improving code readabilty
aleksfront Aug 10, 2020
503888a
Setting overflow:hidden on lens-view elem (#664)
aleksfront Aug 10, 2020
39391e7
Fixing broken/missing icons (#665)
aleksfront Aug 10, 2020
6c40d33
fix menu/navigation
ixrock Aug 10, 2020
93b42ff
moar random fixes
ixrock Aug 10, 2020
631826a
clean up
ixrock Aug 10, 2020
916a101
Fix Cluster Settings style specificity
aleksfront Aug 11, 2020
ae3fdea
fix: navigate to cluster-settings page from clusters-menu
ixrock Aug 11, 2020
260bbbd
Revert system menu layout (#671)
nevalla Aug 12, 2020
e7d4317
fix: navigating to cluster-view from common-view
ixrock Aug 12, 2020
7903eba
revering user-store refactoring
ixrock Aug 12, 2020
f5a978e
moving cluster-settings view lens-app views (common)
ixrock Aug 12, 2020
2228957
reverted cluster-manager.ts/getClusterForRequest()
ixrock Aug 12, 2020
77066ee
Adding unit tests to ClusterStore (#678)
aleksfront Aug 13, 2020
c4ae765
Navigate to landing page on cluster disconnect
aleksfront Aug 13, 2020
bc339e4
Add Cluster page visual fixes
aleksfront Aug 13, 2020
877fe18
Improve isUrl validator
aleksfront Aug 13, 2020
1987c12
Fixing Cluster Settings typo
aleksfront Aug 13, 2020
161b356
fix: use `env NODE_ENV=production` for `yarn compile`
ixrock Aug 13, 2020
8275e15
prod-build fix
ixrock Aug 13, 2020
a28d671
extracting missing localization
ixrock Aug 13, 2020
38aefc5
Reconnecting cluster after selection (#685)
aleksfront Aug 14, 2020
50a2e1f
fix: skip redefining global `__static` in tests
ixrock Aug 14, 2020
fb124ad
Preferences section restyling (#700)
aleksfront Aug 17, 2020
0353ee7
Replace webview to iframe (#701)
ixrock Aug 17, 2020
948421b
Fix integration tests (#698)
nevalla Aug 18, 2020
07c3143
Minor WizardLayout fix
aleksfront Aug 18, 2020
fe42219
Merge branch 'vue_react_migration' into views_management_refactoring
nevalla Aug 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cluster-view reworks
Signed-off-by: Roman <ixrock@gmail.com>
Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
  • Loading branch information
ixrock authored and nevalla committed Aug 18, 2020
commit 7364cb75d68173e9185b72ab990715ee769eba85
2 changes: 2 additions & 0 deletions src/renderer/components/cluster-manager/cluster-status.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
.ClusterStatus {
--flex-gap: #{$padding * 2};

position: relative;
min-width: 350px;
margin: auto;
text-align: center;
z-index: 1;

pre {
@include hidden-scrollbar;
Expand Down
30 changes: 18 additions & 12 deletions src/renderer/components/cluster-manager/cluster-view.scss
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
.ClusterView {
position: relative;
width: 100%;
height: 100%;
display: none;
display: flex;
flex: 1;
}

#lens-views {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
display: flex;

&.loaded {
display: flex;
> * {
flex: 1;
}
}

//#lens-views {
// position: absolute;
// left: 0;
// top: 0;
// width: 0;
// height: 0;
// overflow: hidden;
//}
body > & {
display: none;
}
}
86 changes: 54 additions & 32 deletions src/renderer/components/cluster-manager/cluster-view.tsx
Original file line number Diff line number Diff line change
@@ -1,66 +1,87 @@
import "./cluster-view.scss"
import React from "react";
import { WebviewTag } from "electron"
import { action, autorun, computed, observable } from "mobx";
import { WebviewTag } from "electron";
import { observable, reaction } from "mobx";
import { disposeOnUnmount, observer } from "mobx-react";
import { ClusterId, clusterStore } from "../../../common/cluster-store";
import { getMatchedClusterId } from "./cluster-view.route";
import { ClusterStatus } from "./cluster-status";
import logger from "../../../main/logger";
import { clusterIpc } from "../../../common/cluster-ipc";
import logger from "../../../main/logger";

const lensViews = observable.map<ClusterId, WebviewTag>()
const isLoaded = observable.map<ClusterId, boolean>()
// todo: figure out how to replace webview-tag to iframe
// fixme: webview reloading/blinking when switching common <-> cluster views

interface LensView {
clusterId: ClusterId;
webview: WebviewTag
isLoaded?: boolean
}

const lensViews = observable.map<ClusterId, LensView>()
const lensViewsHolder = document.createElement("div")
lensViewsHolder.id = "lens-views"
document.body.appendChild(lensViewsHolder);

@observer
export class ClusterView extends React.Component {
protected placeholder: HTMLElement;

@computed get cluster() {
get cluster() {
return clusterStore.getById(getMatchedClusterId())
}

// fixme: attach/detach doesn't work properly
componentDidMount() {
// disposeOnUnmount(this, [
// autorun(() => {
// const activeClusterId = this.cluster?.id;
// if (activeClusterId) {
// this.initView(activeClusterId);
// Array.from(lensViews).forEach(([clusterId, view]) => {
// if (activeClusterId === clusterId && isLoaded.has(clusterId)) {
// this.placeholder.appendChild(view)
// } else {
// view.parentElement.removeChild(view);
// }
// })
// }
// }),
// ])
this.attachViews();
disposeOnUnmount(this, [
reaction(() => this.cluster, selectedCluster => {
this.initView(selectedCluster?.id)
this.refreshViews()
}, {
fireImmediately: true
})
])
}

componentWillUnmount() {
this.detachViews();
}

@action
initView(clusterId: ClusterId) {
if (lensViews.has(clusterId)) {
initView = (clusterId: ClusterId) => {
if (!clusterId || lensViews.has(clusterId)) {
return;
}
logger.info(`[WEBVIEW]: init view for clusterId=${clusterId}`)
const webview = document.createElement("webview");
webview.className = "ClusterView"
webview.setAttribute("src", `//${clusterId}.${location.host}`)
webview.setAttribute("nodeintegration", "true")
webview.setAttribute("enableremotemodule", "true")
webview.addEventListener("did-finish-load", () => {
logger.info(`[WEBVIEW]: loaded, clusterId=${clusterId}`)
isLoaded.set(clusterId, true);
webview.classList.add("loaded")
clusterIpc.init.invokeFromRenderer(clusterId); // push cluster-state to webview
lensViews.get(clusterId).isLoaded = true;
this.refreshViews();
});
webview.addEventListener("did-fail-load", (event) => {
logger.error(`[WEBVIEW]: failed to load, clusterId=${clusterId}`, event)
});
lensViews.set(clusterId, webview);
document.body.appendChild(webview);
lensViews.set(clusterId, { clusterId, webview });
lensViewsHolder.appendChild(webview); // add to dom and start loading frame
}

attachViews = () => {
this.placeholder.appendChild(lensViewsHolder)
}

detachViews = () => {
document.body.appendChild(lensViewsHolder);
}

refreshViews = () => {
lensViews.forEach(({ clusterId, webview, isLoaded }) => {
const isActive = clusterId === this.cluster?.id;
webview.style.display = isLoaded && isActive ? "flex" : "none"
})
}

bindRef = (elem: HTMLElement) => {
Expand All @@ -69,10 +90,11 @@ export class ClusterView extends React.Component {

render() {
const { cluster } = this;
const showStatus = cluster && !cluster.accessible;
const view = lensViews.get(cluster?.id);
const showStatusPage = cluster && (!cluster.accessible || !view?.isLoaded);
return (
<div className="ClusterView" ref={this.bindRef}>
{showStatus && <ClusterStatus clusterId={cluster.id}/>}
{showStatusPage && <ClusterStatus clusterId={cluster.id}/>}
</div>
)
}
Expand Down