mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add auto-update notifications and confirmation (#1941)
* add auto-update notifications and confirmation * Show single update notification (#1985) * Moving notification icons to top (#1987) * Switch to EventEmitter (producer&consumer) model * Add `onCorrect` and `onceCorrect` to ipc module for typechecking ipc messages * move type enforced ipc methods to seperate file, add unit tests Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com> Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
741973dd29
commit
a61425124f
23 files changed
+434
-47
No files matched your search
@@ -8,7 +8,7 @@ import { workloadURL, workloadStores } from "../+workloads";
|
||||
import { namespaceStore } from "../+namespaces/namespace.store";
|
||||
import { NamespaceSelectFilter } from "../+namespaces/namespace-select";
|
||||
import { isAllowedResource, KubeResource } from "../../../common/rbac";
|
||||
import { ResourceNames } from "../../../renderer/utils/rbac";
|
||||
import { ResourceNames } from "../../utils/rbac";
|
||||
import { autobind } from "../../utils";
|
||||
|
||||
const resources: KubeResource[] = [
|
||||
|
||||
@@ -21,10 +21,16 @@
|
||||
&.primary {
|
||||
background: $buttonPrimaryBackground;
|
||||
}
|
||||
|
||||
&.accent {
|
||||
background: $buttonAccentBackground;
|
||||
}
|
||||
|
||||
&.light {
|
||||
background-color: $buttonLightBackground;
|
||||
color: #505050;
|
||||
}
|
||||
|
||||
&.plain {
|
||||
color: inherit;
|
||||
background: transparent;
|
||||
|
||||
@@ -8,6 +8,7 @@ export interface ButtonProps extends ButtonHTMLAttributes<any>, TooltipDecorator
|
||||
waiting?: boolean;
|
||||
primary?: boolean;
|
||||
accent?: boolean;
|
||||
light?: boolean;
|
||||
plain?: boolean;
|
||||
outlined?: boolean;
|
||||
hidden?: boolean;
|
||||
@@ -24,13 +25,16 @@ export class Button extends React.PureComponent<ButtonProps, {}> {
|
||||
private button: HTMLButtonElement;
|
||||
|
||||
render() {
|
||||
const { className, waiting, label, primary, accent, plain, hidden, active, big, round, outlined, tooltip, children, ...props } = this.props;
|
||||
const btnProps = props as Partial<ButtonProps>;
|
||||
const {
|
||||
className, waiting, label, primary, accent, plain, hidden, active, big,
|
||||
round, outlined, tooltip, light, children, ...props
|
||||
} = this.props;
|
||||
const btnProps: Partial<ButtonProps> = props;
|
||||
|
||||
if (hidden) return null;
|
||||
|
||||
btnProps.className = cssNames("Button", className, {
|
||||
waiting, primary, accent, plain, active, big, round, outlined
|
||||
waiting, primary, accent, plain, active, big, round, outlined, light,
|
||||
});
|
||||
|
||||
const btnContent: ReactNode = (
|
||||
|
||||
@@ -42,5 +42,9 @@
|
||||
box-shadow: 0 0 20px $boxShadow;
|
||||
}
|
||||
}
|
||||
|
||||
.close {
|
||||
margin-top: -2px;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -18,6 +18,7 @@ export interface Notification {
|
||||
message: NotificationMessage;
|
||||
status?: NotificationStatus;
|
||||
timeout?: number; // auto-hiding timeout in milliseconds, 0 = no hide
|
||||
onClose?(): void; // additonal logic on when the notification times out or is closed by the "x"
|
||||
}
|
||||
|
||||
@autobind()
|
||||
@@ -72,23 +72,26 @@ export class Notifications extends React.Component {
|
||||
return (
|
||||
<div className="Notifications flex column align-flex-end" ref={e => this.elem = e}>
|
||||
{notifications.map(notification => {
|
||||
const { id, status } = notification;
|
||||
const { id, status, onClose } = notification;
|
||||
const msgText = this.getMessage(notification);
|
||||
|
||||
return (
|
||||
<Animate key={id}>
|
||||
<div
|
||||
className={cssNames("notification flex align-center", status)}
|
||||
className={cssNames("notification flex", status)}
|
||||
onMouseLeave={() => addAutoHideTimer(id)}
|
||||
onMouseEnter={() => removeAutoHideTimer(id)}>
|
||||
<div className="box center">
|
||||
<div className="box">
|
||||
<Icon material="info_outline"/>
|
||||
</div>
|
||||
<div className="message box grow">{msgText}</div>
|
||||
<div className="box center">
|
||||
<div className="box">
|
||||
<Icon
|
||||
material="close" className="close"
|
||||
onClick={prevDefault(() => remove(id))}
|
||||
onClick={prevDefault(() => {
|
||||
remove(id);
|
||||
onClose?.();
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user