1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

fix sizing

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2021-04-29 10:11:26 -04:00
parent 2085383987
commit a3bf07ab02
3 changed files with 20 additions and 12 deletions

View File

@ -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<void> {
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<CatalogEntity[]>, Disposer] {
async function watchFileChanges(filePath: string, port: number): Promise<[IComputedValue<CatalogEntity[]>, 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<string, ObservableMap<string, RootSourceValue>>(observable.map);

View File

@ -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()}
/>
<div className="hint">
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).
</div>
{this.renderEntries()}
</section>

View File

@ -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));
}
}
}