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

fine-tuning / more fixes

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman 2021-10-10 18:34:28 +03:00
parent 59efe2a544
commit e9ee815cc8
4 changed files with 18 additions and 10 deletions

View File

@ -52,17 +52,19 @@ export class EditResourceStore extends DockTabStore<EditingResource> {
} }
async editResource(tabId: TabId) { async editResource(tabId: TabId) {
await this.whenReady;
const store = this.getStore(tabId); const store = this.getStore(tabId);
const data = this.getData(tabId); const data = this.getData(tabId);
let resource = this.getResource(tabId);
if (!store || !data) return; if (data.resource && !data.draft) {
try {
let resource = this.getResource(tabId);
try { resource ??= await store.loadFromPath(data.resource);
resource ??= await store.loadFromPath(data.resource); data.draft ||= jsYaml.safeDump(resource.toPlainObject()); // dump resource if empty
data.draft ||= jsYaml.safeDump(resource.toPlainObject()); } catch (error) {
} catch (error) { console.error(`[DOCK]: dumping '${data.resource}' has failed: ${error}`, { store, data });
console.error(`[DOCK]: dumping '${data.resource}' has failed: ${error}`, { store, data }); }
} }
} }

View File

@ -96,7 +96,7 @@ dockViewsManager.register(TabKind.EDIT_RESOURCE, {
InfoPanel: EditResourceInfoPanel, InfoPanel: EditResourceInfoPanel,
editor: { editor: {
getValue(tabId) { getValue(tabId) {
return editResourceStore.getData(tabId).draft; return editResourceStore.getData(tabId)?.draft ?? "";
}, },
setValue(tabId, value) { setValue(tabId, value) {
editResourceStore.getData(tabId).draft = value; editResourceStore.getData(tabId).draft = value;

View File

@ -58,6 +58,7 @@ export class InstallChartStore extends DockTabStore<IChartInstallData> {
@action @action
async loadData(tabId: TabId) { async loadData(tabId: TabId) {
await this.whenReady;
const promises = []; const promises = [];
if (!this.getData(tabId).values) { if (!this.getData(tabId).values) {
@ -73,6 +74,7 @@ export class InstallChartStore extends DockTabStore<IChartInstallData> {
@action @action
async loadVersions(tabId: TabId) { async loadVersions(tabId: TabId) {
await this.whenReady;
const { repo, name, version } = this.getData(tabId); const { repo, name, version } = this.getData(tabId);
this.versions.delete(tabId); // reset this.versions.delete(tabId); // reset
@ -84,6 +86,8 @@ export class InstallChartStore extends DockTabStore<IChartInstallData> {
@action @action
async loadValues(tabId: TabId, attempt = 0): Promise<void> { async loadValues(tabId: TabId, attempt = 0): Promise<void> {
await this.whenReady;
const data = this.getData(tabId); const data = this.getData(tabId);
const { repo, name, version } = data; const { repo, name, version } = data;
const values = await getChartValues(repo, name, version); const values = await getChartValues(repo, name, version);

View File

@ -58,6 +58,8 @@ export class UpgradeChartStore extends DockTabStore<IChartUpgradeData> {
} }
async loadData(tabId: TabId) { async loadData(tabId: TabId) {
await this.whenReady;
await Promise.all([ await Promise.all([
this.loadValues(tabId), this.loadValues(tabId),
this.loadVersions(tabId), this.loadVersions(tabId),
@ -73,7 +75,7 @@ export class UpgradeChartStore extends DockTabStore<IChartUpgradeData> {
} }
@action @action
async loadVersions(tabId: TabId) { private async loadVersions(tabId: TabId) {
try { try {
const { releaseName } = this.getData(tabId); const { releaseName } = this.getData(tabId);
@ -87,7 +89,7 @@ export class UpgradeChartStore extends DockTabStore<IChartUpgradeData> {
} }
@action @action
async loadValues(tabId: TabId, { forceReload = false } = {}) { private async loadValues(tabId: TabId, { forceReload = false } = {}) {
if (this.hasValues(tabId) && !forceReload) { if (this.hasValues(tabId) && !forceReload) {
return; return;
} }