vault/ui/lib/kv/addon/utils/kv-deleted.js
Angel Garbarino 7556dfd158
Fix KV bug on deletion_time (#22842)
* the fix

* working, but work in progress maybe change to another helper, put draft up?

* some fixes and restructing

* change names

* test assert wrong locally, lets see about gh
2023-09-07 15:09:33 -06:00

15 lines
565 B
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import timestamp from 'core/utils/timestamp';
export function isDeleted(date) {
// on the kv/data model, deletion_time does not always mean the secret has been deleted.
// if the delete_version_after is set then the deletion_time will be UTC of that time, even if it's a future time from now.
// to determine if the secret is deleted we check if deletion_time <= time right now.
const deletionTime = new Date(date);
const now = timestamp.now();
return deletionTime <= now;
}