Skip to content

Commit

Permalink
Merge pull request #541 from Security-Onion-Solutions/cogburn/bulk-ba…
Browse files Browse the repository at this point in the history
…nner

Show tip when Bulk Action starts
  • Loading branch information
coreyogburn authored Jun 11, 2024
2 parents 3e1c59a + 81b39ba commit df36e43
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
10 changes: 6 additions & 4 deletions html/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -697,10 +697,12 @@ $(document).ready(function() {
},
updateEditorTheme() {
var link = $('link[href^="css/external/prism-custom-"]')[0];
if (this.$vuetify.theme.dark) {
link.href = "css/external/prism-custom-dark-v1.29.0.css";
} else {
link.href = "css/external/prism-custom-light-v1.29.0.css";
if (link) {
if (this.$vuetify.theme.dark) {
link.href = "css/external/prism-custom-dark-v1.29.0.css";
} else {
link.href = "css/external/prism-custom-light-v1.29.0.css";
}
}
},
subscribe(kind, fn) {
Expand Down
2 changes: 2 additions & 0 deletions html/js/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ const i18n = {
betweenOp: 'Between',
blog: 'Blog',
bulkAction: 'Bulk Action:',
bulkActionStarted: 'Updating {total} detections. This may take awhile.',
bulkActionDeleteStarted: 'Deleting {total} detections. This may take awhile.',
bulkError: '',
bulkSuccessUpdate: 'Bulk update successfully updated {modified} of {total} events. ({time})',
bulkSuccessDelete: 'Bulk delete successfully deleted {modified} of {total} events. ({time})',
Expand Down
10 changes: 10 additions & 0 deletions html/js/routes/hunt.js
Original file line number Diff line number Diff line change
Expand Up @@ -2216,6 +2216,16 @@ const huntComponent = {

try {
await this.$root.papi.post('detection/bulk/' + this.selectedAction, payload);

let msg = this.i18n.bulkActionStarted;
if (this.selectedAction === 'delete') {
msg = this.i18n.bulkActionDeleteStarted;
}

msg = msg.replace('{total}', this.selectedCount.toLocaleString());

this.$root.showTip(msg);

this.selectAllState = false;
this.selectedCount = 0;
this.hunt(false);
Expand Down
7 changes: 7 additions & 0 deletions html/js/routes/hunt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,7 @@ test('bulkAction - delete - pre-confirm', async () => {

expect(comp.showBulkDeleteConfirmDialog).toBe(true);
expect(comp.selectedCount).toBe(2);
expect(comp.$root.tip).toBe(false);
});

test('bulkAction - enable', async () => {
Expand All @@ -1219,6 +1220,8 @@ test('bulkAction - enable', async () => {
expect(mock).toHaveBeenCalledWith('detection/bulk/enable', { ids: ["1", "3"] });
expect(comp.hunt).toHaveBeenCalledTimes(1);
expect(comp.hunt).toHaveBeenCalledWith(false);
expect(comp.$root.tip).toBe(true);
expect(comp.$root.tipMessage).toBe('Updating 2 detections. This may take awhile.');
});

test('bulkAction - disable', async () => {
Expand All @@ -1238,6 +1241,8 @@ test('bulkAction - disable', async () => {
expect(mock).toHaveBeenCalledWith('detection/bulk/disable', { ids: ["1", "3"] });
expect(comp.hunt).toHaveBeenCalledTimes(1);
expect(comp.hunt).toHaveBeenCalledWith(false);
expect(comp.$root.tip).toBe(true);
expect(comp.$root.tipMessage).toBe('Updating 2 detections. This may take awhile.');
});

test('bulkAction - delete - confirm - success', async () => {
Expand All @@ -1258,6 +1263,8 @@ test('bulkAction - delete - confirm - success', async () => {
expect(mock).toHaveBeenCalledWith('detection/bulk/delete', { ids: ["1", "3"] });
expect(comp.hunt).toHaveBeenCalledTimes(1);
expect(comp.hunt).toHaveBeenCalledWith(false);
expect(comp.$root.tip).toBe(true);
expect(comp.$root.tipMessage).toBe('Deleting 2 detections. This may take awhile.');
});

test('bulkAction - delete - confirm - failure', async () => {
Expand Down

0 comments on commit df36e43

Please sign in to comment.