Files
nomad/ui/app/utils/rollback-without-changed-attrs.js
Mike Nomitch bc039a7a8a Adds Namespace UI to Access Control (#19402)
Adds Namespace UI to Access Control - Also adds two step buttons to other Access Control pages

---------

Co-authored-by: Phil Renaud <phil@riotindustries.com>
2024-01-16 09:20:50 -08:00

25 lines
634 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
export default function rollbackWithoutChangedAttrs(model) {
// The purpose of this function was to allow deletes to fail
// and then roll them back without rolling back
// other changed attributes.
// A failed delete followed by trying to re-view the
// model in question was throwing uncaught Errros
let forLater = {};
Object.keys(model.changedAttributes()).forEach((key) => {
forLater[key] = model.get(key);
});
model.rollbackAttributes();
Object.keys(forLater).forEach((key) => {
model.set(key, forLater[key]);
});
}