1
0
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:
Sebastian Malton 2021-10-04 13:45:29 -04:00
parent 78578a48e4
commit ace81d49ad
2 changed files with 7 additions and 2 deletions

View File

@ -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]) => {

View File

@ -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.