All files / ee/app/assets/javascripts/audit_events/components audit_events_app.vue

100% Statements 3/3
100% Branches 2/2
100% Functions 2/2
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63          1x                                       5x         1x                                                                
<script>
import { GlTabs, GlTab } from '@gitlab/ui';
import Tracking from '~/tracking';
import { AUDIT_EVENTS_TAB_TITLES } from '../constants';
import AuditEventsLog from './audit_events_log.vue';
import AuditEventsStream from './audit_events_stream.vue';
 
export default {
  components: {
    GlTabs,
    GlTab,
    AuditEventsLog,
    AuditEventsStream,
  },
  mixins: [Tracking.mixin()],
  inject: {
    isProject: {
      default: false,
    },
    showStreams: {
      default: false,
    },
  },
  computed: {
    showTabs() {
      return !this.isProject && this.showStreams;
    },
  },
  methods: {
    onTabClick() {
      this.track('click_tab', { label: 'audit_events_streams_tab' });
    },
  },
  i18n: AUDIT_EVENTS_TAB_TITLES,
};
</script>
 
<template>
  <gl-tabs
    v-if="showTabs"
    content-class="gl-pt-5"
    :sync-active-tab-with-query-params="true"
    data-testid="audit-events-tabs"
  >
    <gl-tab :title="$options.i18n.LOG" query-param-value="log">
      <audit-events-log />
    </gl-tab>
    <gl-tab
      :title="$options.i18n.STREAM"
      query-param-value="streams"
      lazy
      data-testid="streams-tab"
      :title-link-attributes="/* eslint-disable @gitlab/vue-no-new-non-primitive-in-template */ {
        'data-testid': 'streams-tab-button',
      } /* eslint-enable @gitlab/vue-no-new-non-primitive-in-template */"
      @click="onTabClick"
    >
      <audit-events-stream />
    </gl-tab>
  </gl-tabs>
  <audit-events-log v-else />
</template>