All files / ee/app/assets/javascripts/geo_nodes/components/details/secondary_node geo_node_sync_settings.vue

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

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 64 65                                                                                                        33x                        
<script>
import { timeIntervalInWords } from '~/lib/utils/datetime_utility';
import { sprintf, __, s__ } from '~/locale';
 
export default {
  name: 'GeoNodeSyncSettings',
  i18n: {
    full: __('Full'),
    groups: __('groups'),
    syncLabel: s__('Geo|Selective (%{syncLabel})'),
    pendingEvents: s__('Geo|%{timeAgoStr} (%{pendingEvents} events)'),
  },
  props: {
    node: {
      type: Object,
      required: true,
    },
  },
 
  computed: {
    syncType() {
      if (this.node.selectiveSyncType === null || this.node.selectiveSyncType === '') {
        return this.$options.i18n.full;
      }
 
      // Renaming namespaces to groups in the UI for Geo Selective Sync
      const syncLabel =
        this.node.selectiveSyncType === 'namespaces'
          ? this.$options.i18n.groups
          : this.node.selectiveSyncType;
 
      return sprintf(this.$options.i18n.syncLabel, { syncLabel });
    },
    eventTimestampEmpty() {
      return !this.node.lastEventTimestamp || !this.node.cursorLastEventTimestamp;
    },
    syncLagInSeconds() {
      return this.node.cursorLastEventTimestamp - this.node.lastEventTimestamp;
    },
    syncStatusEventInfo() {
      const timeAgoStr = timeIntervalInWords(this.syncLagInSeconds);
      const pendingEvents = this.node.lastEventId - this.node.cursorLastEventId;
 
      return sprintf(this.$options.i18n.pendingEvents, {
        timeAgoStr,
        pendingEvents,
      });
    },
  },
};
</script>
 
<template>
  <div class="gl-display-flex gl-align-items-center">
    <span class="gl-font-weight-bold" data-testid="sync-type">{{ syncType }}</span>
    <span
      v-if="!eventTimestampEmpty"
      class="gl-ml-3 gl-text-gray-500 gl-font-sm"
      data-testid="sync-status-event-info"
    >
      {{ syncStatusEventInfo }}
    </span>
  </div>
</template>