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:
parent
de93812ee3
commit
150c3dc831
@ -32,5 +32,5 @@ export function downloadFile(opts: DownloadFileOptions): DownloadFileTicket {
|
|||||||
cancel() {
|
cancel() {
|
||||||
req.abort();
|
req.abort();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,7 @@ export function readFileFromTar(tarFilePath: string, opts: ReadFileFromTarOpts):
|
|||||||
if (!fileChunks.length) {
|
if (!fileChunks.length) {
|
||||||
reject(notFoundMessage);
|
reject(notFoundMessage);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function extractTar(filePath: string, opts: ExtractOptions & { sync?: boolean } = {}) {
|
export function extractTar(filePath: string, opts: ExtractOptions & { sync?: boolean } = {}) {
|
||||||
@ -45,5 +45,5 @@ export function extractTar(filePath: string, opts: ExtractOptions & { sync?: boo
|
|||||||
file: filePath,
|
file: filePath,
|
||||||
cwd: path.dirname(filePath),
|
cwd: path.dirname(filePath),
|
||||||
...opts,
|
...opts,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@ -121,7 +121,7 @@ export class AddCluster extends React.Component {
|
|||||||
onDropKubeConfig = (files: File[]) => {
|
onDropKubeConfig = (files: File[]) => {
|
||||||
this.sourceTab = KubeConfigSourceTab.FILE;
|
this.sourceTab = KubeConfigSourceTab.FILE;
|
||||||
this.setKubeConfig(files[0].path);
|
this.setKubeConfig(files[0].path);
|
||||||
}
|
};
|
||||||
|
|
||||||
@action
|
@action
|
||||||
addClusters = () => {
|
addClusters = () => {
|
||||||
|
|||||||
@ -58,12 +58,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.InstallingExtensionNotification {
|
.InstallingExtensionNotification {
|
||||||
.folder-remove-warning {
|
.remove-folder-warning {
|
||||||
font-size: $font-size-small;
|
font-size: $font-size-small;
|
||||||
color: inherit;
|
|
||||||
cursor: pointer;
|
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
opacity: .8;
|
opacity: .8;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
|
|||||||
@ -77,7 +77,7 @@ export class Extensions extends React.Component {
|
|||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
installExtensions = () => {
|
installExtensions = () => {
|
||||||
if (this.downloadUrl) {
|
if (this.downloadUrl) {
|
||||||
@ -86,13 +86,14 @@ export class Extensions extends React.Component {
|
|||||||
} else {
|
} else {
|
||||||
this.installFromSelectFileDialog();
|
this.installFromSelectFileDialog();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
installFromNpmOrUrl = async (url = this.downloadUrl) => {
|
installFromNpmOrUrl = async (url = this.downloadUrl) => {
|
||||||
if (!InputValidators.isUrl.validate(url)) {
|
if (!InputValidators.isUrl.validate(url)) {
|
||||||
url = extensionManager.getNpmPackageTarballUrl(url);
|
const npmPackageName = url;
|
||||||
|
url = extensionManager.getNpmPackageTarballUrl(npmPackageName);
|
||||||
if (!url) {
|
if (!url) {
|
||||||
Notifications.error(`Error: npm package "${url}" not found!`);
|
Notifications.error(`Error: npm package "${npmPackageName}" not found!`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,7 +111,7 @@ export class Extensions extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
installOnDrop = (files: File[]) => {
|
installOnDrop = (files: File[]) => {
|
||||||
logger.info('Install from D&D');
|
logger.info('Install from D&D');
|
||||||
@ -120,7 +121,7 @@ export class Extensions extends React.Component {
|
|||||||
filePath: file.path,
|
filePath: file.path,
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
async requestInstall(installRequests: InstallRequest[]) {
|
async requestInstall(installRequests: InstallRequest[]) {
|
||||||
const pendingFiles: Promise<any>[] = [];
|
const pendingFiles: Promise<any>[] = [];
|
||||||
@ -133,7 +134,7 @@ export class Extensions extends React.Component {
|
|||||||
.catch(err => {
|
.catch(err => {
|
||||||
Notifications.error(`Error while reading "${ext.filePath}": ${String(err)}`);
|
Notifications.error(`Error while reading "${ext.filePath}": ${String(err)}`);
|
||||||
});
|
});
|
||||||
pendingFiles.push(promise)
|
pendingFiles.push(promise);
|
||||||
});
|
});
|
||||||
await Promise.all(pendingFiles);
|
await Promise.all(pendingFiles);
|
||||||
installRequests = installRequests.filter(item => item.data); // remove items with reading errors
|
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);
|
await fse.ensureDir(tempFolder);
|
||||||
|
|
||||||
// copy files to temp, get extension info from package.json and do basic validation
|
// 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 { fileName, data } = installReq;
|
||||||
const tempFile = path.join(tempFolder, fileName);
|
const tempFile = path.join(tempFolder, fileName);
|
||||||
await fse.writeFileSync(tempFile, data); // copy to temp
|
await fse.writeFileSync(tempFile, data); // copy to temp
|
||||||
@ -161,7 +162,7 @@ export class Extensions extends React.Component {
|
|||||||
...installReq,
|
...installReq,
|
||||||
manifest: manifest,
|
manifest: manifest,
|
||||||
tmpFile: tempFile,
|
tmpFile: tempFile,
|
||||||
}
|
};
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
fse.unlink(tempFile).catch(() => null); // remove invalid temp file
|
fse.unlink(tempFile).catch(() => null); // remove invalid temp file
|
||||||
Notifications.error(
|
Notifications.error(
|
||||||
@ -189,11 +190,8 @@ export class Extensions extends React.Component {
|
|||||||
<p>Install extension <b title={fileName}>{name}@{version}</b>?</p>
|
<p>Install extension <b title={fileName}>{name}@{version}</b>?</p>
|
||||||
<p>Description: <em>{description}</em></p>
|
<p>Description: <em>{description}</em></p>
|
||||||
{folderExists && (
|
{folderExists && (
|
||||||
<div className="folder-remove-warning flex gaps inline align-center" onClick={() => shell.openPath(extensionFolder)}>
|
<div className="remove-folder-warning" onClick={() => shell.openPath(extensionFolder)}>
|
||||||
<Icon small material="warning"/>
|
<b>Warning:</b> <code>{extensionFolder}</code> will be removed before installation.
|
||||||
<p>
|
|
||||||
<b>Warning:</b> <code>{extensionFolder}</code> will be removed before installation.
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@ -203,7 +201,7 @@ export class Extensions extends React.Component {
|
|||||||
}}/>
|
}}/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async unpackExtension({ fileName, tmpFile, manifest: { name, version } }: InstallRequestValidated) {
|
async unpackExtension({ fileName, tmpFile, manifest: { name, version } }: InstallRequestValidated) {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import "./clipboard.scss"
|
import "./clipboard.scss";
|
||||||
import React from "react"
|
import React from "react";
|
||||||
import { findDOMNode } from "react-dom";
|
import { findDOMNode } from "react-dom";
|
||||||
import { autobind } from "../../../common/utils";
|
import { autobind } from "../../../common/utils";
|
||||||
import { Notifications } from "../notifications";
|
import { Notifications } from "../notifications";
|
||||||
@ -16,12 +16,12 @@ export interface CopyToClipboardProps {
|
|||||||
|
|
||||||
export const defaultProps: Partial<CopyToClipboardProps> = {
|
export const defaultProps: Partial<CopyToClipboardProps> = {
|
||||||
getNotificationMessage(copiedText: string) {
|
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> {
|
export class Clipboard extends React.Component<CopyToClipboardProps> {
|
||||||
static displayName = "Clipboard"
|
static displayName = "Clipboard";
|
||||||
static defaultProps = defaultProps as object;
|
static defaultProps = defaultProps as object;
|
||||||
|
|
||||||
get rootElem(): HTMLElement {
|
get rootElem(): HTMLElement {
|
||||||
@ -49,13 +49,13 @@ export class Clipboard extends React.Component<CopyToClipboardProps> {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
try {
|
try {
|
||||||
let rootElem = this.rootReactElem;
|
const rootElem = this.rootReactElem;
|
||||||
return React.cloneElement(rootElem, {
|
return React.cloneElement(rootElem, {
|
||||||
className: cssNames(Clipboard.displayName, rootElem.props.className),
|
className: cssNames(Clipboard.displayName, rootElem.props.className),
|
||||||
onClick: this.onClick,
|
onClick: this.onClick,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} 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;
|
return this.rootReactElem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
export * from "./clipboard"
|
export * from "./clipboard";
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import "./drop-file-input.scss"
|
import "./drop-file-input.scss";
|
||||||
import React from "react"
|
import React from "react";
|
||||||
import { autobind, cssNames, IClassName } from "../../utils";
|
import { autobind, cssNames, IClassName } from "../../utils";
|
||||||
import { observable } from "mobx";
|
import { observable } from "mobx";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
@ -69,7 +69,7 @@ export class DropFileInput<T extends HTMLElement = any> extends React.Component<
|
|||||||
return React.cloneElement(contentElem, contentElemProps);
|
return React.cloneElement(contentElem, contentElemProps);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} 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;
|
return this.props.children;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user