Simplify add cluster view (#2716)

- Only shows editor, and will save all text to file

- Reports some validation errors, but doesn't block the add cluster
  button

- Cleanup kube helpers to facilitate clearer FS interactions

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton authored and GitHub committed 2021-06-07 08:14:43 -04:00
1 parent 07c7653a70
commit 817c8e00db
18 files changed
+343 -395

No files matched your search

+4 -2
View File
@@ -21,7 +21,9 @@
// Common utils (main OR renderer)
export const noop: any = () => { /* empty */ };
export function noop<T extends any[]>(...args: T): void {
return void args;
}
export * from "./app-version";
export * from "./autobind";
@@ -39,8 +41,8 @@ export * from "./escapeRegExp";
export * from "./extended-map";
export * from "./getRandId";
export * from "./openExternal";
export * from "./paths";
export * from "./reject-promise";
export * from "./saveToAppFiles";
export * from "./singleton";
export * from "./splitArray";
export * from "./tar";
@@ -19,17 +19,17 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// Save file to electron app directory (e.g. "/Users/$USER/Library/Application Support/Lens" for MacOS)
import path from "path";
import { app, remote } from "electron";
import { ensureDirSync, writeFileSync } from "fs-extra";
import type { WriteFileOptions } from "fs";
import os from "os";
export function saveToAppFiles(filePath: string, contents: any, options?: WriteFileOptions): string {
const absPath = path.resolve((app || remote.app).getPath("userData"), filePath);
function resolveTilde(filePath: string) {
if (filePath[0] === "~" && (filePath[1] === "/" || filePath.length === 1)) {
return filePath.replace("~", os.homedir());
}
ensureDirSync(path.dirname(absPath));
writeFileSync(absPath, contents, options);
return filePath;
}
return absPath;
export function resolvePath(filePath: string): string {
return path.resolve(resolveTilde(filePath));
}