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

clean up, fix lint issues

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2020-11-23 23:42:39 +02:00
parent de93812ee3
commit 150c3dc831
8 changed files with 30 additions and 33 deletions

View File

@ -32,5 +32,5 @@ export function downloadFile(opts: DownloadFileOptions): DownloadFileTicket {
cancel() {
req.abort();
}
}
};
}

View File

@ -37,7 +37,7 @@ export function readFileFromTar(tarFilePath: string, opts: ReadFileFromTarOpts):
if (!fileChunks.length) {
reject(notFoundMessage);
}
})
});
}
export function extractTar(filePath: string, opts: ExtractOptions & { sync?: boolean } = {}) {
@ -45,5 +45,5 @@ export function extractTar(filePath: string, opts: ExtractOptions & { sync?: boo
file: filePath,
cwd: path.dirname(filePath),
...opts,
})
});
}

View File

@ -121,7 +121,7 @@ export class AddCluster extends React.Component {
onDropKubeConfig = (files: File[]) => {
this.sourceTab = KubeConfigSourceTab.FILE;
this.setKubeConfig(files[0].path);
}
};
@action
addClusters = () => {

View File

@ -58,12 +58,11 @@
}
.InstallingExtensionNotification {
.folder-remove-warning {
.remove-folder-warning {
font-size: $font-size-small;
color: inherit;
cursor: pointer;
font-style: italic;
opacity: .8;
cursor: pointer;
&:hover {
opacity: 1;

View File

@ -77,7 +77,7 @@ export class Extensions extends React.Component {
}))
);
}
}
};
installExtensions = () => {
if (this.downloadUrl) {
@ -86,13 +86,14 @@ export class Extensions extends React.Component {
} else {
this.installFromSelectFileDialog();
}
}
};
installFromNpmOrUrl = async (url = this.downloadUrl) => {
if (!InputValidators.isUrl.validate(url)) {
url = extensionManager.getNpmPackageTarballUrl(url);
const npmPackageName = url;
url = extensionManager.getNpmPackageTarballUrl(npmPackageName);
if (!url) {
Notifications.error(`Error: npm package "${url}" not found!`);
Notifications.error(`Error: npm package "${npmPackageName}" not found!`);
return;
}
}
@ -110,7 +111,7 @@ export class Extensions extends React.Component {
</div>
);
}
}
};
installOnDrop = (files: File[]) => {
logger.info('Install from D&D');
@ -120,7 +121,7 @@ export class Extensions extends React.Component {
filePath: file.path,
}))
);
}
};
async requestInstall(installRequests: InstallRequest[]) {
const pendingFiles: Promise<any>[] = [];
@ -133,7 +134,7 @@ export class Extensions extends React.Component {
.catch(err => {
Notifications.error(`Error while reading "${ext.filePath}": ${String(err)}`);
});
pendingFiles.push(promise)
pendingFiles.push(promise);
});
await Promise.all(pendingFiles);
installRequests = installRequests.filter(item => item.data); // remove items with reading errors
@ -143,7 +144,7 @@ export class Extensions extends React.Component {
await fse.ensureDir(tempFolder);
// copy files to temp, get extension info from package.json and do basic validation
let validatedInstalls: Promise<InstallRequestValidated>[] = installRequests.map(async installReq => {
const validatedInstalls: Promise<InstallRequestValidated>[] = installRequests.map(async installReq => {
const { fileName, data } = installReq;
const tempFile = path.join(tempFolder, fileName);
await fse.writeFileSync(tempFile, data); // copy to temp
@ -161,7 +162,7 @@ export class Extensions extends React.Component {
...installReq,
manifest: manifest,
tmpFile: tempFile,
}
};
} catch (err) {
fse.unlink(tempFile).catch(() => null); // remove invalid temp file
Notifications.error(
@ -189,11 +190,8 @@ export class Extensions extends React.Component {
<p>Install extension <b title={fileName}>{name}@{version}</b>?</p>
<p>Description: <em>{description}</em></p>
{folderExists && (
<div className="folder-remove-warning flex gaps inline align-center" onClick={() => shell.openPath(extensionFolder)}>
<Icon small material="warning"/>
<p>
<b>Warning:</b> <code>{extensionFolder}</code> will be removed before installation.
</p>
<div className="remove-folder-warning" onClick={() => shell.openPath(extensionFolder)}>
<b>Warning:</b> <code>{extensionFolder}</code> will be removed before installation.
</div>
)}
</div>
@ -203,7 +201,7 @@ export class Extensions extends React.Component {
}}/>
</div>
);
})
});
}
async unpackExtension({ fileName, tmpFile, manifest: { name, version } }: InstallRequestValidated) {

View File

@ -1,5 +1,5 @@
import "./clipboard.scss"
import React from "react"
import "./clipboard.scss";
import React from "react";
import { findDOMNode } from "react-dom";
import { autobind } from "../../../common/utils";
import { Notifications } from "../notifications";
@ -16,12 +16,12 @@ export interface CopyToClipboardProps {
export const defaultProps: Partial<CopyToClipboardProps> = {
getNotificationMessage(copiedText: string) {
return <p>Copied to clipboard: <em>{copiedText}</em></p>
return <p>Copied to clipboard: <em>{copiedText}</em></p>;
}
}
};
export class Clipboard extends React.Component<CopyToClipboardProps> {
static displayName = "Clipboard"
static displayName = "Clipboard";
static defaultProps = defaultProps as object;
get rootElem(): HTMLElement {
@ -49,13 +49,13 @@ export class Clipboard extends React.Component<CopyToClipboardProps> {
render() {
try {
let rootElem = this.rootReactElem;
const rootElem = this.rootReactElem;
return React.cloneElement(rootElem, {
className: cssNames(Clipboard.displayName, rootElem.props.className),
onClick: this.onClick,
});
} catch (err) {
logger.error(`Invalid usage components/CopyToClick usage. Children must contain root html element.`, { err: String(err) })
logger.error(`Invalid usage components/CopyToClick usage. Children must contain root html element.`, { err: String(err) });
return this.rootReactElem;
}
}

View File

@ -1 +1 @@
export * from "./clipboard"
export * from "./clipboard";

View File

@ -1,5 +1,5 @@
import "./drop-file-input.scss"
import React from "react"
import "./drop-file-input.scss";
import React from "react";
import { autobind, cssNames, IClassName } from "../../utils";
import { observable } from "mobx";
import { observer } from "mobx-react";
@ -69,7 +69,7 @@ export class DropFileInput<T extends HTMLElement = any> extends React.Component<
return React.cloneElement(contentElem, contentElemProps);
}
} catch (err) {
logger.error("Invalid root content-element for DropFileInput", { err: String(err) })
logger.error("Invalid root content-element for DropFileInput", { err: String(err) });
return this.props.children;
}
}