Restructure to monorepo (#6907)

* wip: restructure to monorepo

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* refactor create-release-pr to a package

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* build fixes

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* github workflow fixes

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* fix typo

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* add webpack-env types to core

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* fix github workflows

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* refactor/fix integration tests

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* lint fix

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* yarn run dev

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* eslint settings for vscode

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* move templates to right package

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* open-lens build fixes

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* integration test fix

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* fix nx task dependencies

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* use bash shell for unit tests in test workflow

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* fix test:unit for windows

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* fix win-ca webpack error in open-lens

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* fix win-ca webpack error in open-lens

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* fix build:app on windows

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* remove ELECTRON_BUILDER_EXTRA_ARGS

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* sync src/ from master

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

* remove Makefile from core

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>

Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
Jari Kolehmainen authored and GitHub committed 2023-01-24 10:46:26 -08:00
1 parent 0066ca4ea2
commit 2657df2293
3321 files changed
+28699 -11447

No files matched your search

@@ -0,0 +1,6 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
export * from "./resource-metrics";
@@ -0,0 +1,16 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import React from "react";
import { Icon } from "../icon";
export function NoMetrics() {
return (
<div className="flex justify-center align-center">
<Icon material="info"/>
&nbsp;Metrics not available at the moment
</div>
);
}
@@ -0,0 +1,43 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
.ResourceMetrics {
$metricsHeight: 200px;
position: relative;
margin-bottom: $margin * 2;
.switchers {
margin-bottom: $margin * 2;
text-align: center;
}
.graph {
&:empty + .loader {
display: flex;
height: #{$metricsHeight + $unit * 2.75};
align-items: center;
justify-content: center;
}
.Chart {
.chart-container {
min-height: $metricsHeight;
}
.legend {
justify-content: center;
> * {
margin-right: $margin * 2;
}
}
}
}
.loader {
display: none;
}
}
@@ -0,0 +1,86 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import "./resource-metrics.scss";
import React, { createContext, useState } from "react";
import { Radio, RadioGroup } from "../radio";
import type { KubeObject } from "../../../common/k8s-api/kube-object";
import { cssNames } from "../../utils";
import { Spinner } from "../spinner";
import type { MetricsTab } from "../chart/options";
import type { MetricData } from "../../../common/k8s-api/endpoints/metrics.api";
import type { IAsyncComputed } from "@ogre-tools/injectable-react";
import { isComputed } from "mobx";
import { observer } from "mobx-react-lite";
export type AtLeastOneMetricTab = [MetricsTab, ...MetricsTab[]];
export interface ResourceMetricsProps<Keys extends string> {
tabs: AtLeastOneMetricTab;
object: KubeObject;
className?: string;
metrics: IAsyncComputed<Partial<Record<Keys, MetricData>> | null | undefined> | Partial<Record<Keys, MetricData>>;
children: React.ReactChild | React.ReactChild[];
}
function isAsyncComputedMetrics<Keys extends string>(metrics: IAsyncComputed<Partial<Record<Keys, MetricData>> | null | undefined> | Partial<Record<Keys, MetricData>>): metrics is IAsyncComputed<Partial<Record<Keys, MetricData>> | null | undefined> {
return isComputed((metrics as any).value);
}
export interface ResourceMetricsValue {
object: KubeObject;
tab: MetricsTab;
metrics: Partial<Record<string, MetricData>> | null | undefined;
}
export const ResourceMetricsContext = createContext<ResourceMetricsValue | null>(null);
export const ResourceMetrics = observer(<Keys extends string>({
object,
tabs,
children,
className,
metrics,
}: ResourceMetricsProps<Keys>) => {
const [tab, setTab] = useState<MetricsTab>(tabs[0]);
return (
<div className={cssNames("ResourceMetrics flex column", className)}>
<div className="switchers">
<RadioGroup
asButtons
className="flex box grow gaps"
value={tab}
onChange={setTab}
>
{tabs.map((tab, index) => (
<Radio
key={index}
className="box grow"
label={tab}
value={tab} />
))}
</RadioGroup>
</div>
<ResourceMetricsContext.Provider
value={{
object,
tab,
metrics: isAsyncComputedMetrics(metrics)
? metrics.value.get()
: metrics,
}}
>
<div className="graph">
{children}
</div>
</ResourceMetricsContext.Provider>
<div className="loader">
<Spinner />
</div>
</div>
);
});