Commit a457bfe8 authored by Nicolò Maria Mezzopera's avatar Nicolò Maria Mezzopera

Merge branch '217779-move-audit-log-into-shared-template' into 'master'

Move audit log app to shared audit events dir

Closes #217779

See merge request gitlab-org/gitlab!33257
parents fd05e5ef 6f42d926
<script> <script>
import AuditLogFilter from './audit_log_filter.vue'; import AuditEventsFilter from './audit_events_filter.vue';
import DateRangeField from './date_range_field.vue'; import DateRangeField from './date_range_field.vue';
import SortingField from './sorting_field.vue'; import SortingField from './sorting_field.vue';
import LogsTable from './logs_table.vue'; import AuditEventsTable from './audit_events_table.vue';
export default { export default {
components: { components: {
AuditLogFilter, AuditEventsFilter,
DateRangeField, DateRangeField,
SortingField, SortingField,
LogsTable, AuditEventsTable,
}, },
props: { props: {
formPath: { formPath: {
...@@ -55,18 +55,18 @@ export default { ...@@ -55,18 +55,18 @@ export default {
class="filter-form d-flex justify-content-between audit-controls row" class="filter-form d-flex justify-content-between audit-controls row"
> >
<div class="col-lg-auto flex-fill form-group align-items-lg-center pr-lg-8"> <div class="col-lg-auto flex-fill form-group align-items-lg-center pr-lg-8">
<AuditLogFilter v-bind="{ enabledTokenTypes }" /> <audit-events-filter v-bind="{ enabledTokenTypes }" />
</div> </div>
<div class="d-flex col-lg-auto flex-wrap pl-lg-0"> <div class="d-flex col-lg-auto flex-wrap pl-lg-0">
<div <div
class="audit-controls d-flex align-items-lg-center flex-column flex-lg-row col-lg-auto px-0" class="audit-controls d-flex align-items-lg-center flex-column flex-lg-row col-lg-auto px-0"
> >
<DateRangeField v-if="formElement" :form-element="formElement" /> <date-range-field v-if="formElement" :form-element="formElement" />
<SortingField /> <sorting-field />
</div> </div>
</div> </div>
</form> </form>
</div> </div>
<LogsTable v-bind="{ events, isLastPage }" /> <audit-events-table v-bind="{ events, isLastPage }" />
</div> </div>
</template> </template>
...@@ -7,7 +7,6 @@ import UrlTableCell from './url_table_cell.vue'; ...@@ -7,7 +7,6 @@ import UrlTableCell from './url_table_cell.vue';
const TABLE_HEADER_CLASSES = 'bg-transparent border-bottom p-3'; const TABLE_HEADER_CLASSES = 'bg-transparent border-bottom p-3';
export default { export default {
name: 'LogsTable',
components: { components: {
GlTable, GlTable,
GlPagination, GlPagination,
......
...@@ -5,7 +5,6 @@ import { parsePikadayDate, pikadayToString } from '~/lib/utils/datetime_utility' ...@@ -5,7 +5,6 @@ import { parsePikadayDate, pikadayToString } from '~/lib/utils/datetime_utility'
import { queryToObject } from '~/lib/utils/url_utility'; import { queryToObject } from '~/lib/utils/url_utility';
export default { export default {
name: 'DateRangeField',
components: { components: {
GlDaterangePicker, GlDaterangePicker,
}, },
......
...@@ -17,7 +17,6 @@ const SORTING_OPTIONS = [ ...@@ -17,7 +17,6 @@ const SORTING_OPTIONS = [
]; ];
export default { export default {
name: 'SortingField',
components: { components: {
GlNewDropdown, GlNewDropdown,
GlNewDropdownHeader, GlNewDropdownHeader,
......
import Vue from 'vue';
import { parseBoolean } from '~/lib/utils/common_utils';
import AuditEventsApp from './components/audit_events_app.vue';
export default selector => {
const el = document.querySelector(selector);
const { events, isLastPage, formPath, enabledTokenTypes } = el.dataset;
return new Vue({
el,
render: createElement =>
createElement(AuditEventsApp, {
props: {
events: JSON.parse(events),
isLastPage: parseBoolean(isLastPage),
enabledTokenTypes: JSON.parse(enabledTokenTypes),
formPath,
},
}),
});
};
import Vue from 'vue'; import initAuditEvents from 'ee/audit_events/init_audit_events';
import { parseBoolean } from '~/lib/utils/common_utils';
import AuditLogApp from 'ee/audit_logs/components/audit_log_app.vue';
document.addEventListener('DOMContentLoaded', () => { initAuditEvents('#js-audit-log-app');
const el = document.querySelector('#js-audit-log-app');
const { events, isLastPage, formPath, enabledTokenTypes } = el.dataset;
// eslint-disable-next-line no-new
new Vue({
el,
name: 'AuditLogApp',
render: createElement =>
createElement(AuditLogApp, {
props: {
events: JSON.parse(events),
isLastPage: parseBoolean(isLastPage),
enabledTokenTypes: JSON.parse(enabledTokenTypes),
formPath,
},
}),
});
});
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`AuditLogApp when initialized matches the snapshot 1`] = ` exports[`AuditEventsApp when initialized matches the snapshot 1`] = `
<div <div
dataqaselector="qa_selector" dataqaselector="qa_selector"
> >
...@@ -46,17 +46,17 @@ exports[`AuditLogApp when initialized matches the snapshot 1`] = ` ...@@ -46,17 +46,17 @@ exports[`AuditLogApp when initialized matches the snapshot 1`] = `
<div <div
class="audit-controls d-flex align-items-lg-center flex-column flex-lg-row col-lg-auto px-0" class="audit-controls d-flex align-items-lg-center flex-column flex-lg-row col-lg-auto px-0"
> >
<daterangefield-stub <date-range-field-stub
formelement="[object HTMLFormElement]" formelement="[object HTMLFormElement]"
/> />
<sortingfield-stub /> <sorting-field-stub />
</div> </div>
</div> </div>
</form> </form>
</div> </div>
<logstable-stub <audit-events-table-stub
events="[object Object]" events="[object Object]"
islastpage="true" islastpage="true"
/> />
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import AuditLogApp from 'ee/audit_logs/components/audit_log_app.vue'; import AuditEventsApp from 'ee/audit_events/components/audit_events_app.vue';
import DateRangeField from 'ee/audit_logs/components/date_range_field.vue'; import DateRangeField from 'ee/audit_events/components/date_range_field.vue';
import LogsTable from 'ee/audit_logs/components/logs_table.vue'; import AuditEventsTable from 'ee/audit_events/components/audit_events_table.vue';
import AuditLogFilter from 'ee/audit_logs/components/audit_log_filter.vue'; import AuditEventsFilter from 'ee/audit_events/components/audit_events_filter.vue';
import { AVAILABLE_TOKEN_TYPES } from 'ee/audit_logs/constants'; import { AVAILABLE_TOKEN_TYPES } from 'ee/audit_events/constants';
describe('AuditLogApp', () => { describe('AuditEventsApp', () => {
let wrapper; let wrapper;
const events = [{ foo: 'bar' }]; const events = [{ foo: 'bar' }];
const enabledTokenTypes = AVAILABLE_TOKEN_TYPES; const enabledTokenTypes = AVAILABLE_TOKEN_TYPES;
const initComponent = (props = {}) => { const initComponent = (props = {}) => {
wrapper = shallowMount(AuditLogApp, { wrapper = shallowMount(AuditEventsApp, {
propsData: { propsData: {
formPath: 'form/path', formPath: 'form/path',
isLastPage: true, isLastPage: true,
...@@ -23,7 +23,7 @@ describe('AuditLogApp', () => { ...@@ -23,7 +23,7 @@ describe('AuditLogApp', () => {
...props, ...props,
}, },
stubs: { stubs: {
AuditLogFilter, AuditEventsFilter,
}, },
}); });
}; };
...@@ -48,11 +48,11 @@ describe('AuditLogApp', () => { ...@@ -48,11 +48,11 @@ describe('AuditLogApp', () => {
}); });
it('passes its events property to the logs table', () => { it('passes its events property to the logs table', () => {
expect(wrapper.find(LogsTable).props('events')).toEqual(events); expect(wrapper.find(AuditEventsTable).props('events')).toEqual(events);
}); });
it('passes its avilable token types to the logs filter', () => { it('passes its avilable token types to the logs filter', () => {
expect(wrapper.find(AuditLogFilter).props('enabledTokenTypes')).toEqual(enabledTokenTypes); expect(wrapper.find(AuditEventsFilter).props('enabledTokenTypes')).toEqual(enabledTokenTypes);
}); });
}); });
}); });
import { GlFilteredSearch } from '@gitlab/ui'; import { GlFilteredSearch } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import AuditLogFilter from 'ee/audit_logs/components/audit_log_filter.vue'; import AuditEventsFilter from 'ee/audit_events/components/audit_events_filter.vue';
import { AVAILABLE_TOKEN_TYPES } from 'ee/audit_logs/constants'; import { AVAILABLE_TOKEN_TYPES } from 'ee/audit_events/constants';
describe('AuditLogFilter', () => { describe('AuditEventsFilter', () => {
let wrapper; let wrapper;
const formElement = document.createElement('form'); const formElement = document.createElement('form');
formElement.submit = jest.fn(); formElement.submit = jest.fn();
...@@ -15,7 +15,7 @@ describe('AuditLogFilter', () => { ...@@ -15,7 +15,7 @@ describe('AuditLogFilter', () => {
getAvailableTokens().filter(token => token.type === type)[0]; getAvailableTokens().filter(token => token.type === type)[0];
const initComponent = (props = {}) => { const initComponent = (props = {}) => {
wrapper = shallowMount(AuditLogFilter, { wrapper = shallowMount(AuditEventsFilter, {
propsData: { propsData: {
...props, ...props,
}, },
......
import { mount } from '@vue/test-utils'; import { mount } from '@vue/test-utils';
import { GlPagination, GlTable } from '@gitlab/ui'; import { GlPagination, GlTable } from '@gitlab/ui';
import LogsTable from 'ee/audit_logs/components/logs_table.vue'; import AuditEventsTable from 'ee/audit_events/components/audit_events_table.vue';
import createEvents from '../mock_data'; import createEvents from '../mock_data';
const EVENTS = createEvents(); const EVENTS = createEvents();
describe('LogsTable component', () => { describe('AuditEventsTable component', () => {
let wrapper; let wrapper;
const createComponent = (props = {}) => { const createComponent = (props = {}) => {
return mount(LogsTable, { return mount(AuditEventsTable, {
propsData: { propsData: {
events: EVENTS, events: EVENTS,
isLastPage: false, isLastPage: false,
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlDaterangePicker } from '@gitlab/ui'; import { GlDaterangePicker } from '@gitlab/ui';
import DateRangeField from 'ee/audit_logs/components/date_range_field.vue'; import DateRangeField from 'ee/audit_events/components/date_range_field.vue';
import { parsePikadayDate } from '~/lib/utils/datetime_utility'; import { parsePikadayDate } from '~/lib/utils/datetime_utility';
describe('DateRangeField component', () => { describe('DateRangeField component', () => {
......
...@@ -3,7 +3,7 @@ import { GlNewDropdownItem } from '@gitlab/ui'; ...@@ -3,7 +3,7 @@ import { GlNewDropdownItem } from '@gitlab/ui';
import * as urlUtils from '~/lib/utils/url_utility'; import * as urlUtils from '~/lib/utils/url_utility';
import SortingField from 'ee/audit_logs/components/sorting_field.vue'; import SortingField from 'ee/audit_events/components/sorting_field.vue';
describe('SortingField component', () => { describe('SortingField component', () => {
let wrapper; let wrapper;
......
...@@ -3,7 +3,7 @@ import { shallowMount } from '@vue/test-utils'; ...@@ -3,7 +3,7 @@ import { shallowMount } from '@vue/test-utils';
import httpStatusCodes from '~/lib/utils/http_status'; import httpStatusCodes from '~/lib/utils/http_status';
import createFlash from '~/flash'; import createFlash from '~/flash';
import AuditFilterToken from 'ee/audit_logs/components/tokens/shared/audit_filter_token.vue'; import AuditFilterToken from 'ee/audit_events/components/tokens/shared/audit_filter_token.vue';
jest.mock('~/flash'); jest.mock('~/flash');
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import UrlTableCell from 'ee/audit_logs/components/url_table_cell.vue'; import UrlTableCell from 'ee/audit_events/components/url_table_cell.vue';
describe('UrlTableCell component', () => { describe('UrlTableCell component', () => {
it('should show the link if the URL is provided', () => { it('should show the link if the URL is provided', () => {
......
import { sample } from 'lodash'; import { sample } from 'lodash';
import { AVAILABLE_TOKEN_TYPES } from 'ee/audit_logs/constants'; import { AVAILABLE_TOKEN_TYPES } from 'ee/audit_events/constants';
import { availableTokensValidator } from 'ee/audit_logs/validators'; import { availableTokensValidator } from 'ee/audit_events/validators';
describe('availableTokensValidator', () => { describe('availableTokensValidator', () => {
it('returns true when the input contains an available token type', () => { it('returns true when the input contains an available token type', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment