Skip to content

Commit

Permalink
fix pivot! (arkime#2570)
Browse files Browse the repository at this point in the history
oops
  • Loading branch information
31453 authored Jan 3, 2024
1 parent be30d7f commit 0c544ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 5 additions & 7 deletions cont3xt/vueapp/src/utils/Field.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ SPDX-License-Identifier: Apache-2.0
<b-dropdown-item
key="pivot"
target="_blank"
v-if="options.pivot"
:href="pivotHref">
:href="pivotHref"
v-if="options.pivot">
{{ options.pivot }}
</b-dropdown-item>
</div>
Expand Down Expand Up @@ -95,7 +95,9 @@ export default {
},
computed: {
pivotHref () {
return window.location.search;
const params = new URLSearchParams(window.location.search);
params.set('b', window.btoa(this.value));
return `?${params.toString()}`;
}
},
methods: {
Expand All @@ -115,10 +117,6 @@ export default {
doCopy (value) {
this.$copyText(value);
this.isOpen = false;
},
/* base64 encodes value */
base64Encode (value) {
return window.btoa(value);
}
}
};
Expand Down
6 changes: 4 additions & 2 deletions cont3xt/vueapp/tests/utils.field.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Cont3xtField from '../src/utils/Field.vue';
Vue.use(BootstrapVue);
Vue.use(VueClipboard);

window.location = { search: '?b=dGhyZWF0YnV0dC5jb20%3D&startDate=2023-12-16T21%3A53%3A03Z' };
window.btoa = jest.fn().mockImplementation((str) => str);

test('field - defaults', async () => {
const { getByText, getByTestId, queryByTestId } = render(Cont3xtField, {
Expand All @@ -35,7 +35,9 @@ test('field - defaults', async () => {
expect(queryByTestId('field-dropdown')).not.toBeInTheDocument();

// pivot button uses current url search parameters
expect(pivotBtn.href).toBe(`http://localhost/#${window.location.search}`);
expect(pivotBtn.href).toBe('http://localhost/?b=field+value');
expect(window.btoa).toHaveBeenCalledWith('field value');
expect(window.btoa).toHaveBeenCalledTimes(1);
});

test('field - with options', async () => {
Expand Down

0 comments on commit 0c544ab

Please sign in to comment.