mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Responding to review comments
- use moment instead of dateformat - remove unused code - moved formatting notification buttons to renderer Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
96eb84e425
commit
7f2ff980f8
@ -162,7 +162,6 @@
|
|||||||
"@hapi/subtext": "^7.0.3",
|
"@hapi/subtext": "^7.0.3",
|
||||||
"@kubernetes/client-node": "^0.12.0",
|
"@kubernetes/client-node": "^0.12.0",
|
||||||
"@types/crypto-js": "^3.1.47",
|
"@types/crypto-js": "^3.1.47",
|
||||||
"@types/dateformat": "^3.0.1",
|
|
||||||
"@types/electron-window-state": "^2.0.34",
|
"@types/electron-window-state": "^2.0.34",
|
||||||
"@types/fs-extra": "^9.0.1",
|
"@types/fs-extra": "^9.0.1",
|
||||||
"@types/http-proxy": "^1.17.4",
|
"@types/http-proxy": "^1.17.4",
|
||||||
@ -180,7 +179,6 @@
|
|||||||
"chalk": "^4.1.0",
|
"chalk": "^4.1.0",
|
||||||
"conf": "^7.0.1",
|
"conf": "^7.0.1",
|
||||||
"crypto-js": "^4.0.0",
|
"crypto-js": "^4.0.0",
|
||||||
"dateformat": "^4.3.1",
|
|
||||||
"electron-updater": "^4.3.1",
|
"electron-updater": "^4.3.1",
|
||||||
"electron-window-state": "^5.0.3",
|
"electron-window-state": "^5.0.3",
|
||||||
"file-type": "^14.7.1",
|
"file-type": "^14.7.1",
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import type { ThemeId } from "../renderer/theme.store";
|
|||||||
import { app, remote } from 'electron';
|
import { app, remote } from 'electron';
|
||||||
import semver from "semver"
|
import semver from "semver"
|
||||||
import { readFile } from "fs-extra"
|
import { readFile } from "fs-extra"
|
||||||
import { action, IReactionDisposer, observable, reaction, toJS } from "mobx";
|
import { action, observable, reaction, toJS } from "mobx";
|
||||||
import { BaseStore } from "./base-store";
|
import { BaseStore } from "./base-store";
|
||||||
import migrations from "../migrations/user-store"
|
import migrations from "../migrations/user-store"
|
||||||
import { getAppVersion } from "./utils/app-version";
|
import { getAppVersion } from "./utils/app-version";
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import { autoUpdater, UpdateInfo } from "electron-updater";
|
import { autoUpdater, UpdateInfo } from "electron-updater";
|
||||||
import logger from "./logger";
|
import logger from "./logger";
|
||||||
import dateFormat from "dateformat";
|
|
||||||
import { broadcastIpc, IpcChannel, NotificationChannelAdd, NotificationChannelPrefix } from "../common/ipc";
|
import { broadcastIpc, IpcChannel, NotificationChannelAdd, NotificationChannelPrefix } from "../common/ipc";
|
||||||
import { ipcMain } from "electron";
|
import { ipcMain } from "electron";
|
||||||
import { isDevelopment } from "../common/vars";
|
import { isDevelopment } from "../common/vars";
|
||||||
import { SemVer } from "semver";
|
import { SemVer } from "semver";
|
||||||
|
import moment from "moment";
|
||||||
|
|
||||||
function delay(duration: number): Promise<void> {
|
function delay(duration: number): Promise<void> {
|
||||||
return new Promise(resolve => setTimeout(resolve, duration));
|
return new Promise(resolve => setTimeout(resolve, duration));
|
||||||
@ -20,24 +20,6 @@ class NotificationBackchannel {
|
|||||||
|
|
||||||
const title = "Lens Updater";
|
const title = "Lens Updater";
|
||||||
|
|
||||||
async function autoUpdateNow(): Promise<void> {
|
|
||||||
const body = "Downloading and installing update.";
|
|
||||||
broadcastIpc({
|
|
||||||
channel: NotificationChannelAdd,
|
|
||||||
args: [{
|
|
||||||
title,
|
|
||||||
body,
|
|
||||||
status: "info",
|
|
||||||
timeout: 5000,
|
|
||||||
}]
|
|
||||||
})
|
|
||||||
|
|
||||||
logger.info("[UPDATE CHECKER]: update downloaded started");
|
|
||||||
await autoUpdater.downloadUpdate();
|
|
||||||
logger.info("[UPDATE CHECKER]: update downloadeded");
|
|
||||||
autoUpdater.quitAndInstall();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function autoUpdateCheck(args: UpdateInfo): Promise<void> {
|
async function autoUpdateCheck(args: UpdateInfo): Promise<void> {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
const body = "Install and restart Lens?";
|
const body = "Install and restart Lens?";
|
||||||
@ -83,23 +65,17 @@ async function autoUpdateCheck(args: UpdateInfo): Promise<void> {
|
|||||||
{
|
{
|
||||||
label: "Yes, now",
|
label: "Yes, now",
|
||||||
backchannel: yesNowChannel,
|
backchannel: yesNowChannel,
|
||||||
style: {
|
action: true,
|
||||||
background: "green",
|
|
||||||
marginRight: "10px"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Yes, on quit",
|
label: "Yes, on quit",
|
||||||
backchannel: yesLaterChannel,
|
backchannel: yesLaterChannel,
|
||||||
style: {
|
action: true,
|
||||||
background: "green",
|
|
||||||
marginRight: "10px"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "No",
|
label: "No",
|
||||||
backchannel: noChannel,
|
backchannel: noChannel,
|
||||||
accent: true
|
secondary: true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
closeChannel: noChannel,
|
closeChannel: noChannel,
|
||||||
@ -122,8 +98,8 @@ export function startUpdateChecking(interval = 1000 * 60 * 60 * 24): void {
|
|||||||
autoUpdater
|
autoUpdater
|
||||||
.on("update-available", async (args: UpdateInfo) => {
|
.on("update-available", async (args: UpdateInfo) => {
|
||||||
try {
|
try {
|
||||||
const releaseDate = new Date(args.releaseDate);
|
const releaseDate = moment(args.releaseDate);
|
||||||
const body = `Version ${args.version} was release on ${dateFormat(releaseDate, "dddd, mmmm dS, yyyy")}.`;
|
const body = `Version ${args.version} was release on ${releaseDate.format("dddd, mmmm dS, yyyy")}.`;
|
||||||
broadcastIpc({
|
broadcastIpc({
|
||||||
channel: NotificationChannelAdd,
|
channel: NotificationChannelAdd,
|
||||||
args: [{
|
args: [{
|
||||||
@ -142,7 +118,7 @@ export function startUpdateChecking(interval = 1000 * 60 * 60 * 24): void {
|
|||||||
.on("update-not-available", (args: UpdateInfo) => {
|
.on("update-not-available", (args: UpdateInfo) => {
|
||||||
try {
|
try {
|
||||||
const version = new SemVer(args.version);
|
const version = new SemVer(args.version);
|
||||||
const stream = version.prerelease !== null ? "prerelease" : "stable";
|
const stream = version.prerelease === null ? "stable" : "prerelease";
|
||||||
const body = `Lens is running the latest ${stream} version.`;
|
const body = `Lens is running the latest ${stream} version.`;
|
||||||
broadcastIpc({
|
broadcastIpc({
|
||||||
channel: NotificationChannelAdd,
|
channel: NotificationChannelAdd,
|
||||||
|
|||||||
@ -20,10 +20,19 @@
|
|||||||
&.primary {
|
&.primary {
|
||||||
background: $buttonPrimaryBackground;
|
background: $buttonPrimaryBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.accent {
|
&.accent {
|
||||||
background: $buttonAccentBackground;
|
background: $buttonAccentBackground;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.action {
|
||||||
|
background: $buttonActionBackground;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.secondary {
|
||||||
|
background: $buttonSecondaryBackground;
|
||||||
|
}
|
||||||
|
|
||||||
&.plain {
|
&.plain {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
|
|||||||
@ -8,6 +8,8 @@ export interface ButtonProps extends ButtonHTMLAttributes<any>, TooltipDecorator
|
|||||||
waiting?: boolean;
|
waiting?: boolean;
|
||||||
primary?: boolean;
|
primary?: boolean;
|
||||||
accent?: boolean;
|
accent?: boolean;
|
||||||
|
secondary?: boolean;
|
||||||
|
action?: boolean;
|
||||||
plain?: boolean;
|
plain?: boolean;
|
||||||
hidden?: boolean;
|
hidden?: boolean;
|
||||||
active?: boolean;
|
active?: boolean;
|
||||||
@ -23,12 +25,15 @@ export class Button extends React.PureComponent<ButtonProps, {}> {
|
|||||||
private button: HTMLButtonElement;
|
private button: HTMLButtonElement;
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { className, waiting, label, primary, accent, plain, hidden, active, big, round, tooltip, children, ...props } = this.props;
|
const {
|
||||||
|
className, waiting, label, primary, accent, plain, hidden, active, big,
|
||||||
|
round, tooltip, children, secondary, action, ...props
|
||||||
|
} = this.props;
|
||||||
const btnProps = props as Partial<ButtonProps>;
|
const btnProps = props as Partial<ButtonProps>;
|
||||||
if (hidden) return null;
|
if (hidden) return null;
|
||||||
|
|
||||||
btnProps.className = cssNames('Button', className, {
|
btnProps.className = cssNames('Button', className, {
|
||||||
waiting, primary, accent, plain, active, big, round,
|
waiting, primary, accent, plain, active, big, round, secondary, action,
|
||||||
});
|
});
|
||||||
|
|
||||||
const btnContent: ReactNode = (
|
const btnContent: ReactNode = (
|
||||||
|
|||||||
@ -25,6 +25,12 @@
|
|||||||
margin-bottom: $margin * 2;
|
margin-bottom: $margin * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
> .button {
|
||||||
|
&:not(:last-of-type) {
|
||||||
|
margin-right: $margin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
> .message {
|
> .message {
|
||||||
white-space: pre-line;
|
white-space: pre-line;
|
||||||
padding-left: $padding;
|
padding-left: $padding;
|
||||||
|
|||||||
@ -26,6 +26,8 @@
|
|||||||
"buttonPrimaryBackground": "#3d90ce",
|
"buttonPrimaryBackground": "#3d90ce",
|
||||||
"buttonDefaultBackground": "#414448",
|
"buttonDefaultBackground": "#414448",
|
||||||
"buttonAccentBackground": "#e85555",
|
"buttonAccentBackground": "#e85555",
|
||||||
|
"buttonActionBackground": "#1dcc1f",
|
||||||
|
"buttonSecondaryBackground": "#edd70c",
|
||||||
"buttonDisabledBackground": "#808080",
|
"buttonDisabledBackground": "#808080",
|
||||||
"tableBgcStripe": "#2a2d33",
|
"tableBgcStripe": "#2a2d33",
|
||||||
"tableBgcSelected": "#383c42",
|
"tableBgcSelected": "#383c42",
|
||||||
|
|||||||
@ -27,6 +27,8 @@
|
|||||||
"buttonPrimaryBackground": "#3d90ce",
|
"buttonPrimaryBackground": "#3d90ce",
|
||||||
"buttonDefaultBackground": "#414448",
|
"buttonDefaultBackground": "#414448",
|
||||||
"buttonAccentBackground": "#e85555",
|
"buttonAccentBackground": "#e85555",
|
||||||
|
"buttonActionBackground": "#1dcc1f",
|
||||||
|
"buttonSecondaryBackground": "#edd70c",
|
||||||
"buttonDisabledBackground": "#808080",
|
"buttonDisabledBackground": "#808080",
|
||||||
"tableBgcStripe": "#f8f8f8",
|
"tableBgcStripe": "#f8f8f8",
|
||||||
"tableBgcSelected": "#f4f5f5",
|
"tableBgcSelected": "#f4f5f5",
|
||||||
|
|||||||
@ -35,6 +35,8 @@ $sidebarBackground: var(--sidebarBackground);
|
|||||||
$buttonPrimaryBackground: var(--buttonPrimaryBackground);
|
$buttonPrimaryBackground: var(--buttonPrimaryBackground);
|
||||||
$buttonDefaultBackground: var(--buttonDefaultBackground);
|
$buttonDefaultBackground: var(--buttonDefaultBackground);
|
||||||
$buttonAccentBackground: var(--buttonAccentBackground);
|
$buttonAccentBackground: var(--buttonAccentBackground);
|
||||||
|
$buttonSecondaryBackground: var(--buttonSecondaryBackground);
|
||||||
|
$buttonActionBackground: var(--buttonActionBackground);
|
||||||
$buttonDisabledBackground: var(--buttonDisabledBackground);
|
$buttonDisabledBackground: var(--buttonDisabledBackground);
|
||||||
|
|
||||||
// Tables
|
// Tables
|
||||||
@ -125,4 +127,4 @@ $filterAreaBackground: var(--filterAreaBackground);
|
|||||||
$selectOptionHoveredColor: var(--selectOptionHoveredColor);
|
$selectOptionHoveredColor: var(--selectOptionHoveredColor);
|
||||||
$lineProgressBackground: var(--lineProgressBackground);
|
$lineProgressBackground: var(--lineProgressBackground);
|
||||||
$radioActiveBackground: var(--radioActiveBackground);
|
$radioActiveBackground: var(--radioActiveBackground);
|
||||||
$menuActiveBackground: var(--menuActiveBackground);
|
$menuActiveBackground: var(--menuActiveBackground);
|
||||||
|
|||||||
10
yarn.lock
10
yarn.lock
@ -1723,11 +1723,6 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@types/crypto-js/-/crypto-js-3.1.47.tgz#36e549dd3f1322742a3a738e7c113ebe48221860"
|
resolved "https://registry.yarnpkg.com/@types/crypto-js/-/crypto-js-3.1.47.tgz#36e549dd3f1322742a3a738e7c113ebe48221860"
|
||||||
integrity sha512-eI6gvpcGHLk3dAuHYnRCAjX+41gMv1nz/VP55wAe5HtmAKDOoPSfr3f6vkMc08ov1S0NsjvUBxDtHHxqQY1LGA==
|
integrity sha512-eI6gvpcGHLk3dAuHYnRCAjX+41gMv1nz/VP55wAe5HtmAKDOoPSfr3f6vkMc08ov1S0NsjvUBxDtHHxqQY1LGA==
|
||||||
|
|
||||||
"@types/dateformat@^3.0.1":
|
|
||||||
version "3.0.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/@types/dateformat/-/dateformat-3.0.1.tgz#98d747a2e5e9a56070c6bf14e27bff56204e34cc"
|
|
||||||
integrity sha512-KlPPdikagvL6ELjWsljbyDIPzNCeliYkqRpI+zea99vBBbCIA5JNshZAwQKTON139c87y9qvTFVgkFd14rtS4g==
|
|
||||||
|
|
||||||
"@types/debug@^4.1.5":
|
"@types/debug@^4.1.5":
|
||||||
version "4.1.5"
|
version "4.1.5"
|
||||||
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.5.tgz#b14efa8852b7768d898906613c23f688713e02cd"
|
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.5.tgz#b14efa8852b7768d898906613c23f688713e02cd"
|
||||||
@ -4311,11 +4306,6 @@ date-fns@^2.0.1, date-fns@^2.14.0:
|
|||||||
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.14.0.tgz#359a87a265bb34ef2e38f93ecf63ac453f9bc7ba"
|
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.14.0.tgz#359a87a265bb34ef2e38f93ecf63ac453f9bc7ba"
|
||||||
integrity sha512-1zD+68jhFgDIM0rF05rcwYO8cExdNqxjq4xP1QKM60Q45mnO6zaMWB4tOzrIr4M4GSLntsKeE4c9Bdl2jhL/yw==
|
integrity sha512-1zD+68jhFgDIM0rF05rcwYO8cExdNqxjq4xP1QKM60Q45mnO6zaMWB4tOzrIr4M4GSLntsKeE4c9Bdl2jhL/yw==
|
||||||
|
|
||||||
dateformat@^4.3.1:
|
|
||||||
version "4.3.1"
|
|
||||||
resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-4.3.1.tgz#e010ca5915f0c7d47e5b4e4287dd5ecb41125a96"
|
|
||||||
integrity sha512-xhq1wI5BQ0TMJDvio0BLP8lNeYlhAvmh/7H52H9n6kfzqSmRpIhH5KEIjJ7onFEAh5CQVrAP2MAG8wZ6j0BKzQ==
|
|
||||||
|
|
||||||
debounce-fn@^4.0.0:
|
debounce-fn@^4.0.0:
|
||||||
version "4.0.0"
|
version "4.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/debounce-fn/-/debounce-fn-4.0.0.tgz#ed76d206d8a50e60de0dd66d494d82835ffe61c7"
|
resolved "https://registry.yarnpkg.com/debounce-fn/-/debounce-fn-4.0.0.tgz#ed76d206d8a50e60de0dd66d494d82835ffe61c7"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user