mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
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:
1 parent
0066ca4ea2
commit
2657df2293
3321 files changed
+28699
-11447
No files matched your search
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { computed } from "mobx";
|
||||
import { ConfirmDialog } from "./confirm-dialog";
|
||||
import { clusterFrameChildComponentInjectionToken } from "../../frames/cluster-frame/cluster-frame-child-component-injection-token";
|
||||
|
||||
const confirmDialogClusterFrameChildComponentInjectable = getInjectable({
|
||||
id: "confirm-dialog-cluster-frame-child-component",
|
||||
|
||||
instantiate: () => ({
|
||||
id: "confirm-dialog",
|
||||
shouldRender: computed(() => true),
|
||||
Component: ConfirmDialog,
|
||||
}),
|
||||
|
||||
injectionToken: clusterFrameChildComponentInjectionToken,
|
||||
});
|
||||
|
||||
export default confirmDialogClusterFrameChildComponentInjectable;
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { rootFrameChildComponentInjectionToken } from "../../frames/root-frame/root-frame-child-component-injection-token";
|
||||
import { computed } from "mobx";
|
||||
import { ConfirmDialog } from "./confirm-dialog";
|
||||
|
||||
const confirmDialogRootFrameChildComponentInjectable = getInjectable({
|
||||
id: "confirm-dialog-root-frame-child-component",
|
||||
|
||||
instantiate: () => ({
|
||||
id: "confirm-dialog",
|
||||
shouldRender: computed(() => true),
|
||||
Component: ConfirmDialog,
|
||||
}),
|
||||
|
||||
injectionToken: rootFrameChildComponentInjectionToken,
|
||||
});
|
||||
|
||||
export default confirmDialogRootFrameChildComponentInjectable;
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
|
||||
.ConfirmDialog {
|
||||
$spacing: $padding * 3;
|
||||
|
||||
&.warning {
|
||||
.Button.ok {
|
||||
background: var(--colorSoftError);
|
||||
}
|
||||
}
|
||||
|
||||
> .box {
|
||||
max-width: 50vw;
|
||||
min-width: 45 * $unit;
|
||||
background-color: white;
|
||||
border-radius: $radius;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.confirm-content {
|
||||
padding: $spacing;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
word-break: break-word;
|
||||
|
||||
> .Icon {
|
||||
margin-left: inherit;
|
||||
margin-right: $margin * 2;
|
||||
color: var(--colorSoftError);
|
||||
}
|
||||
|
||||
> :not(.Icon) {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.warning {
|
||||
font-size: small;
|
||||
margin-top: $margin;
|
||||
}
|
||||
}
|
||||
|
||||
.confirm-buttons {
|
||||
background: #f4f4f4;
|
||||
padding: $padding * 2.5;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
border-bottom-left-radius: $radius;
|
||||
border-bottom-right-radius: $radius;
|
||||
|
||||
> * {
|
||||
margin-left: $margin
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import "./confirm-dialog.scss";
|
||||
|
||||
import type { ReactNode } from "react";
|
||||
import React from "react";
|
||||
import type { IObservableValue } from "mobx";
|
||||
import { observable, makeObservable, computed } from "mobx";
|
||||
import { observer } from "mobx-react";
|
||||
import { cssNames, noop, prevDefault } from "../../utils";
|
||||
import type { ButtonProps } from "../button";
|
||||
import { Button } from "../button";
|
||||
import type { DialogProps } from "../dialog";
|
||||
import { Dialog } from "../dialog";
|
||||
import { Icon } from "../icon";
|
||||
import type { ShowNotification } from "../notifications";
|
||||
import { withInjectables } from "@ogre-tools/injectable-react";
|
||||
import confirmDialogStateInjectable from "./state.injectable";
|
||||
import showErrorNotificationInjectable from "../notifications/show-error-notification.injectable";
|
||||
|
||||
export interface ConfirmDialogProps extends Partial<DialogProps> {
|
||||
}
|
||||
|
||||
export interface ConfirmDialogParams extends ConfirmDialogBooleanParams {
|
||||
ok?: () => any | Promise<any>;
|
||||
cancel?: () => any | Promise<any>;
|
||||
}
|
||||
|
||||
export interface ConfirmDialogBooleanParams {
|
||||
labelOk?: ReactNode;
|
||||
labelCancel?: ReactNode;
|
||||
message: ReactNode;
|
||||
icon?: ReactNode;
|
||||
okButtonProps?: Partial<ButtonProps>;
|
||||
cancelButtonProps?: Partial<ButtonProps>;
|
||||
}
|
||||
|
||||
interface Dependencies {
|
||||
state: IObservableValue<ConfirmDialogParams | undefined>;
|
||||
showErrorNotification: ShowNotification;
|
||||
}
|
||||
|
||||
const defaultParams = {
|
||||
ok: noop,
|
||||
cancel: noop,
|
||||
labelOk: "Ok",
|
||||
labelCancel: "Cancel",
|
||||
icon: <Icon big material="warning"/>,
|
||||
};
|
||||
|
||||
@observer
|
||||
class NonInjectedConfirmDialog extends React.Component<ConfirmDialogProps & Dependencies> {
|
||||
@observable isSaving = false;
|
||||
|
||||
constructor(props: ConfirmDialogProps & Dependencies) {
|
||||
super(props);
|
||||
makeObservable(this);
|
||||
}
|
||||
|
||||
@computed
|
||||
get params() {
|
||||
return Object.assign({}, defaultParams, this.props.state.get() ?? {} as ConfirmDialogParams);
|
||||
}
|
||||
|
||||
ok = async () => {
|
||||
try {
|
||||
this.isSaving = true;
|
||||
await (async () => this.params.ok())();
|
||||
} catch (error) {
|
||||
this.props.showErrorNotification(
|
||||
<>
|
||||
<p>Confirmation action failed:</p>
|
||||
<p>
|
||||
{(
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: typeof error === "string"
|
||||
? error
|
||||
: "Unknown error occured while ok-ing"
|
||||
)}
|
||||
</p>
|
||||
</>,
|
||||
);
|
||||
} finally {
|
||||
this.isSaving = false;
|
||||
this.props.state.set(undefined);
|
||||
}
|
||||
};
|
||||
|
||||
onClose = () => {
|
||||
this.isSaving = false;
|
||||
};
|
||||
|
||||
close = async () => {
|
||||
try {
|
||||
await Promise.resolve(this.params.cancel());
|
||||
} catch (error) {
|
||||
this.props.showErrorNotification(
|
||||
<>
|
||||
<p>Cancelling action failed:</p>
|
||||
<p>
|
||||
{(
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: typeof error === "string"
|
||||
? error
|
||||
: "Unknown error occured while cancelling"
|
||||
)}
|
||||
</p>
|
||||
</>,
|
||||
);
|
||||
} finally {
|
||||
this.isSaving = false;
|
||||
this.props.state.set(undefined);
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const { state, className, ...dialogProps } = this.props;
|
||||
const isOpen = Boolean(state.get());
|
||||
const {
|
||||
icon, labelOk, labelCancel, message,
|
||||
okButtonProps = {},
|
||||
cancelButtonProps = {},
|
||||
} = this.params;
|
||||
|
||||
return (
|
||||
<Dialog
|
||||
{...dialogProps}
|
||||
className={cssNames("ConfirmDialog", className)}
|
||||
isOpen={isOpen}
|
||||
onClose={this.onClose}
|
||||
close={this.close}
|
||||
{...(isOpen ? { "data-testid": "confirmation-dialog" } : {})}
|
||||
>
|
||||
<div className="confirm-content">
|
||||
{icon}
|
||||
{" "}
|
||||
{message}
|
||||
</div>
|
||||
<div className="confirm-buttons">
|
||||
<Button
|
||||
plain
|
||||
className="cancel"
|
||||
label={labelCancel}
|
||||
onClick={prevDefault(this.close)}
|
||||
{...cancelButtonProps}
|
||||
/>
|
||||
<Button
|
||||
autoFocus
|
||||
primary
|
||||
className="ok"
|
||||
label={labelOk}
|
||||
onClick={prevDefault(this.ok)}
|
||||
waiting={this.isSaving}
|
||||
data-testid="confirm"
|
||||
{...okButtonProps}
|
||||
/>
|
||||
</div>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export const ConfirmDialog = withInjectables<Dependencies, ConfirmDialogProps>(NonInjectedConfirmDialog, {
|
||||
getProps: (di, props) => ({
|
||||
...props,
|
||||
state: di.inject(confirmDialogStateInjectable),
|
||||
showErrorNotification: di.inject(showErrorNotificationInjectable),
|
||||
}),
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { ConfirmDialogBooleanParams } from "./confirm-dialog";
|
||||
import openConfirmDialogInjectable from "./open.injectable";
|
||||
|
||||
export type Confirm = (params: ConfirmDialogBooleanParams) => Promise<boolean>;
|
||||
|
||||
const confirmInjectable = getInjectable({
|
||||
id: "confirm",
|
||||
instantiate: (di): Confirm => {
|
||||
const open = di.inject(openConfirmDialogInjectable);
|
||||
|
||||
return (params) => new Promise(resolve => {
|
||||
open({
|
||||
ok: () => resolve(true),
|
||||
cancel: () => resolve(false),
|
||||
...params,
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export default confirmInjectable;
|
||||
@@ -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 "./confirm-dialog";
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { ConfirmDialogParams } from "./confirm-dialog";
|
||||
import confirmDialogStateInjectable from "./state.injectable";
|
||||
|
||||
export type OpenConfirmDialog = (params: ConfirmDialogParams) => void;
|
||||
|
||||
const openConfirmDialogInjectable = getInjectable({
|
||||
id: "open-confirm-dialog",
|
||||
instantiate: (di): OpenConfirmDialog => {
|
||||
const state = di.inject(confirmDialogStateInjectable);
|
||||
|
||||
return params => state.set(params);
|
||||
},
|
||||
});
|
||||
|
||||
export default openConfirmDialogInjectable;
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { observable } from "mobx";
|
||||
import type { ConfirmDialogParams } from "./confirm-dialog";
|
||||
|
||||
const confirmDialogStateInjectable = getInjectable({
|
||||
id: "confirm-dialog-state",
|
||||
instantiate: () => observable.box<ConfirmDialogParams | undefined>(),
|
||||
});
|
||||
|
||||
export default confirmDialogStateInjectable;
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import type { ConfirmDialogParams } from "./confirm-dialog";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import openConfirmDialogInjectable from "./open.injectable";
|
||||
|
||||
export type WithConfirmation = (params: ConfirmDialogParams) => () => void;
|
||||
|
||||
const withConfirmationInjectable = getInjectable({
|
||||
id: "with-confirmation",
|
||||
instantiate: (di): WithConfirmation => {
|
||||
const open = di.inject(openConfirmDialogInjectable);
|
||||
|
||||
return (params) => () => open(params);
|
||||
},
|
||||
});
|
||||
|
||||
export default withConfirmationInjectable;
|
||||
Reference in new issue
Block a user