mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix no being able to revert to initial value
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
78578a48e4
commit
ace81d49ad
@ -107,6 +107,10 @@ export class EditResourceStore extends DockTabStore<EditingResource> {
|
||||
return dockStore.getTabById(tabId);
|
||||
}
|
||||
|
||||
clearInitialDraft(tabId: TabId): void {
|
||||
delete this.getData(tabId)?.firstDraft;
|
||||
}
|
||||
|
||||
reset() {
|
||||
super.reset();
|
||||
Array.from(this.watchers).forEach(([tabId, dispose]) => {
|
||||
|
||||
@ -97,14 +97,15 @@ export class EditResource extends React.Component<Props> {
|
||||
if (this.error) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const store = editResourceStore.getStore(this.tabId);
|
||||
const currentVersion = yaml.safeLoad(this.draft);
|
||||
const firstVersion = yaml.safeLoad(editResourceStore.getData(this.tabId).firstDraft ?? this.draft);
|
||||
const patches = createPatch(firstVersion, currentVersion);
|
||||
|
||||
console.log({ currentVersion, firstVersion, patches });
|
||||
const updatedResource = await store.patch(this.resource, patches);
|
||||
|
||||
editResourceStore.clearInitialDraft(this.tabId);
|
||||
|
||||
return (
|
||||
<p>
|
||||
{updatedResource.kind} <b>{updatedResource.getName()}</b> updated.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user