Skip to content

Commit

Permalink
Added lock user attribution
Browse files Browse the repository at this point in the history
  • Loading branch information
akhenry committed Oct 8, 2024
1 parent 3389b3b commit e7d485a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/plugins/persistence/couch/scripts/lockObjects.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ function processObjectTreeFrom(parentObjectIdentifier) {
//2. Lock or unlock object
document.model.locked = locked;
document.model.disallowUnlock = locked;

if (locked) {
document.model.lockedBy = 'script';
} else {
delete document.model.lockedBy;
}
//3. Push document to a batch
documentBatch.push(document);
//4. Persist batch if necessary, reporting failures
Expand Down
19 changes: 18 additions & 1 deletion src/ui/layout/BrowseBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,26 @@ export default {
this.actionCollection.off('update', this.updateActionItems);
delete this.actionCollection;
},
toggleLock(flag) {
async toggleLock(flag) {
if (!this.domainObject.disallowUnlock) {
const wasTransactionActive = this.openmct.objects.isTransactionActive();

Check warning on line 434 in src/ui/layout/BrowseBar.vue

View check run for this annotation

Codecov / codecov/patch

src/ui/layout/BrowseBar.vue#L434

Added line #L434 was not covered by tests
let transaction;

if (!wasTransactionActive) {
transaction = this.openmct.objects.startTransaction();

Check warning on line 438 in src/ui/layout/BrowseBar.vue

View check run for this annotation

Codecov / codecov/patch

src/ui/layout/BrowseBar.vue#L438

Added line #L438 was not covered by tests
}

this.openmct.objects.mutate(this.domainObject, 'locked', flag);
const userName = await this.openmct.user.getCurrentUser();

Check warning on line 442 in src/ui/layout/BrowseBar.vue

View check run for this annotation

Codecov / codecov/patch

src/ui/layout/BrowseBar.vue#L441-L442

Added lines #L441 - L442 were not covered by tests

if (userName !== undefined) {
this.openmct.objects.mutate(this.domainObject, 'lockedBy', userName);

Check warning on line 445 in src/ui/layout/BrowseBar.vue

View check run for this annotation

Codecov / codecov/patch

src/ui/layout/BrowseBar.vue#L445

Added line #L445 was not covered by tests
}

if (!wasTransactionActive) {
await transaction.commit();
this.openmct.objects.endTransaction();

Check warning on line 450 in src/ui/layout/BrowseBar.vue

View check run for this annotation

Codecov / codecov/patch

src/ui/layout/BrowseBar.vue#L449-L450

Added lines #L449 - L450 were not covered by tests
}
}
},
setStatus(status) {
Expand Down

0 comments on commit e7d485a

Please sign in to comment.