From a3bf07ab02a2d57f1afba6bef271ea12138e7152 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Thu, 29 Apr 2021 10:11:26 -0400 Subject: [PATCH] fix sizing Signed-off-by: Sebastian Malton --- src/main/catalog-sources/kubeconfig-sync.ts | 18 ++++++++++++------ .../+preferences/kubeconfig-syncs.tsx | 4 +--- .../components/+preferences/preferences.scss | 10 +++++++--- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/main/catalog-sources/kubeconfig-sync.ts b/src/main/catalog-sources/kubeconfig-sync.ts index 239bb29999..4a3f31796b 100644 --- a/src/main/catalog-sources/kubeconfig-sync.ts +++ b/src/main/catalog-sources/kubeconfig-sync.ts @@ -2,6 +2,7 @@ import { action, observable, IComputedValue, computed, ObservableMap, runInActio import { CatalogEntity, catalogEntityRegistry } from "../../common/catalog"; import { watch } from "chokidar"; import fs from "fs"; +import fse from "fs-extra"; import * as uuid from "uuid"; import stream from "stream"; import { Disposer, ExtendedObservableMap, iter, Singleton } from "../../common/utils"; @@ -71,16 +72,20 @@ export class KubeconfigSyncManager extends Singleton { } @action - protected startNewSync(filePath: string, port: number): void { + protected async startNewSync(filePath: string, port: number): Promise { if (this.sources.has(filePath)) { // don't start a new sync if we already have one return void logger.debug(`${logPrefix} already syncing file/folder`, { filePath }); } - this.sources.set(filePath, watchFileChanges(filePath, port)); + try { + this.sources.set(filePath, await watchFileChanges(filePath, port)); - logger.info(`${logPrefix} starting sync of file/folder`, { filePath }); - logger.debug(`${logPrefix} ${this.sources.size} files/folders watched`, { files: Array.from(this.sources.keys()) }); + logger.info(`${logPrefix} starting sync of file/folder`, { filePath }); + logger.debug(`${logPrefix} ${this.sources.size} files/folders watched`, { files: Array.from(this.sources.keys()) }); + } catch (error) { + logger.warn(`${logPrefix} failed to start watching changes: ${error}`); + } } @action @@ -213,10 +218,11 @@ function diffChangedConfig(filePath: string, source: RootSource, port: number): }; } -function watchFileChanges(filePath: string, port: number): [IComputedValue, Disposer] { +async function watchFileChanges(filePath: string, port: number): Promise<[IComputedValue, Disposer]> { + const stat = await fse.stat(filePath); // traverses symlinks, is a race condition const watcher = watch(filePath, { followSymlinks: true, - depth: 1, // shallow + depth: stat.isDirectory() ? 0 : 1, // DIRs works with 0 but files need 1 (bug: https://github.com/paulmillr/chokidar/issues/1095) disableGlobbing: true, }); const rootSource = new ExtendedObservableMap>(observable.map); diff --git a/src/renderer/components/+preferences/kubeconfig-syncs.tsx b/src/renderer/components/+preferences/kubeconfig-syncs.tsx index d79b9ec730..89432dcac8 100644 --- a/src/renderer/components/+preferences/kubeconfig-syncs.tsx +++ b/src/renderer/components/+preferences/kubeconfig-syncs.tsx @@ -1,5 +1,3 @@ - - import React from "react"; import { remote } from "electron"; import { Avatar, IconButton, List, ListItem, ListItemAvatar, ListItemSecondaryAction, ListItemText, Paper } from "@material-ui/core"; @@ -168,7 +166,7 @@ export class KubeconfigSyncs extends React.Component { onClick={() => void this.openFileDialog()} />
- Sync an individual file or folders (and subfolders to a depth of 1). + Sync an individual file or all files in a folder (non-recursive).
{this.renderEntries()} diff --git a/src/renderer/components/+preferences/preferences.scss b/src/renderer/components/+preferences/preferences.scss index ccf231e9dd..4320def3d0 100644 --- a/src/renderer/components/+preferences/preferences.scss +++ b/src/renderer/components/+preferences/preferences.scss @@ -13,15 +13,19 @@ .MuiAvatar-root { color: var(--buttonPrimaryBackground); + font-size: calc(2.5 * var(--unit)); } .description { font-family: monospace; - font-size: inherit; + + .MuiTypography-body1 { + font-size: var(--font-size); + } } - .action { - font-size: inherit; + .action .MuiIconButton-root { + font-size: calc(2.5 * var(--unit)); } } }