Commit 57eed815 authored by Brandon Labuschagne's avatar Brandon Labuschagne Committed by Miguel Rincon

Refactor DevOps Adoption strings into primitives

parent a8407791
...@@ -11,19 +11,19 @@ import { TYPE_GROUP } from '~/graphql_shared/constants'; ...@@ -11,19 +11,19 @@ import { TYPE_GROUP } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils'; import { convertToGraphQLId } from '~/graphql_shared/utils';
import { import {
DEBOUNCE_DELAY, DEBOUNCE_DELAY,
DEVOPS_ADOPTION_GROUP_DROPDOWN_TEXT, I18N_GROUP_DROPDOWN_TEXT,
DEVOPS_ADOPTION_GROUP_DROPDOWN_HEADER, I18N_GROUP_DROPDOWN_HEADER,
DEVOPS_ADOPTION_ADMIN_DROPDOWN_TEXT, I18N_ADMIN_DROPDOWN_TEXT,
DEVOPS_ADOPTION_ADMIN_DROPDOWN_HEADER, I18N_ADMIN_DROPDOWN_HEADER,
DEVOPS_ADOPTION_NO_RESULTS, I18N_NO_RESULTS,
DEVOPS_ADOPTION_NO_SUB_GROUPS, I18N_NO_SUB_GROUPS,
} from '../constants'; } from '../constants';
import bulkEnableDevopsAdoptionNamespacesMutation from '../graphql/mutations/bulk_enable_devops_adoption_namespaces.mutation.graphql'; import bulkEnableDevopsAdoptionNamespacesMutation from '../graphql/mutations/bulk_enable_devops_adoption_namespaces.mutation.graphql';
export default { export default {
name: 'DevopsAdoptionAddDropdown', name: 'DevopsAdoptionAddDropdown',
i18n: { i18n: {
noResults: DEVOPS_ADOPTION_NO_RESULTS, noResults: I18N_NO_RESULTS,
}, },
debounceDelay: DEBOUNCE_DELAY, debounceDelay: DEBOUNCE_DELAY,
components: { components: {
...@@ -69,17 +69,13 @@ export default { ...@@ -69,17 +69,13 @@ export default {
return this.groups?.length; return this.groups?.length;
}, },
dropdownTitle() { dropdownTitle() {
return this.isGroup return this.isGroup ? I18N_GROUP_DROPDOWN_TEXT : I18N_ADMIN_DROPDOWN_TEXT;
? DEVOPS_ADOPTION_GROUP_DROPDOWN_TEXT
: DEVOPS_ADOPTION_ADMIN_DROPDOWN_TEXT;
}, },
dropdownHeader() { dropdownHeader() {
return this.isGroup return this.isGroup ? I18N_GROUP_DROPDOWN_HEADER : I18N_ADMIN_DROPDOWN_HEADER;
? DEVOPS_ADOPTION_GROUP_DROPDOWN_HEADER
: DEVOPS_ADOPTION_ADMIN_DROPDOWN_HEADER;
}, },
tooltipText() { tooltipText() {
return this.isLoadingGroups || this.hasSubgroups ? false : DEVOPS_ADOPTION_NO_SUB_GROUPS; return this.isLoadingGroups || this.hasSubgroups ? false : I18N_NO_SUB_GROUPS;
}, },
}, },
beforeDestroy() { beforeDestroy() {
......
...@@ -7,11 +7,11 @@ import API from '~/api'; ...@@ -7,11 +7,11 @@ import API from '~/api';
import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { mergeUrlParams, updateHistory, getParameterValues } from '~/lib/utils/url_utility'; import { mergeUrlParams, updateHistory, getParameterValues } from '~/lib/utils/url_utility';
import { import {
DEVOPS_ADOPTION_STRINGS, I18N_GROUPS_QUERY_ERROR,
DEVOPS_ADOPTION_ERROR_KEYS, I18N_ENABLED_NAMESPACE_QUERY_ERROR,
I18N_ENABLE_NAMESPACE_MUTATION_ERROR,
DATE_TIME_FORMAT, DATE_TIME_FORMAT,
DEFAULT_POLLING_INTERVAL, DEFAULT_POLLING_INTERVAL,
DEVOPS_ADOPTION_GROUP_LEVEL_LABEL,
DEVOPS_ADOPTION_TABLE_CONFIGURATION, DEVOPS_ADOPTION_TABLE_CONFIGURATION,
TRACK_ADOPTION_TAB_CLICK_EVENT, TRACK_ADOPTION_TAB_CLICK_EVENT,
TRACK_DEVOPS_SCORE_TAB_CLICK_EVENT, TRACK_DEVOPS_SCORE_TAB_CLICK_EVENT,
...@@ -56,10 +56,6 @@ export default { ...@@ -56,10 +56,6 @@ export default {
default: '', default: '',
}, },
}, },
i18n: {
groupLevelLabel: DEVOPS_ADOPTION_GROUP_LEVEL_LABEL,
...DEVOPS_ADOPTION_STRINGS.app,
},
trackDevopsTabClickEvent: TRACK_ADOPTION_TAB_CLICK_EVENT, trackDevopsTabClickEvent: TRACK_ADOPTION_TAB_CLICK_EVENT,
trackDevopsScoreTabClickEvent: TRACK_DEVOPS_SCORE_TAB_CLICK_EVENT, trackDevopsScoreTabClickEvent: TRACK_DEVOPS_SCORE_TAB_CLICK_EVENT,
devopsAdoptionTableConfiguration: DEVOPS_ADOPTION_TABLE_CONFIGURATION, devopsAdoptionTableConfiguration: DEVOPS_ADOPTION_TABLE_CONFIGURATION,
...@@ -70,11 +66,7 @@ export default { ...@@ -70,11 +66,7 @@ export default {
isLoadingEnableGroup: false, isLoadingEnableGroup: false,
requestCount: 0, requestCount: 0,
openModal: false, openModal: false,
errors: { errors: [],
[DEVOPS_ADOPTION_ERROR_KEYS.groups]: false,
[DEVOPS_ADOPTION_ERROR_KEYS.enabledNamespaces]: false,
[DEVOPS_ADOPTION_ERROR_KEYS.addEnabledNamespaces]: false,
},
groups: { groups: {
nodes: [], nodes: [],
pageInfo: null, pageInfo: null,
...@@ -109,7 +101,7 @@ export default { ...@@ -109,7 +101,7 @@ export default {
} }
}, },
error(error) { error(error) {
this.handleError(DEVOPS_ADOPTION_ERROR_KEYS.enabledNamespaces, error); this.handleError(I18N_ENABLED_NAMESPACE_QUERY_ERROR, error);
}, },
}, },
}, },
...@@ -124,7 +116,7 @@ export default { ...@@ -124,7 +116,7 @@ export default {
return Boolean(this.devopsAdoptionEnabledNamespaces?.nodes?.length); return Boolean(this.devopsAdoptionEnabledNamespaces?.nodes?.length);
}, },
hasLoadingError() { hasLoadingError() {
return Object.values(this.errors).some((error) => error === true); return this.errors.length;
}, },
timestamp() { timestamp() {
return dateformat( return dateformat(
...@@ -194,14 +186,14 @@ export default { ...@@ -194,14 +186,14 @@ export default {
} = data; } = data;
if (errors.length) { if (errors.length) {
this.handleError(DEVOPS_ADOPTION_ERROR_KEYS.addEnabledNamespaces, errors); this.handleError(I18N_ENABLE_NAMESPACE_MUTATION_ERROR, errors);
} else { } else {
this.addEnabledNamespacesToCache(enabledNamespaces); this.addEnabledNamespacesToCache(enabledNamespaces);
} }
}, },
}) })
.catch((error) => { .catch((error) => {
this.handleError(DEVOPS_ADOPTION_ERROR_KEYS.addEnabledNamespaces, error); this.handleError(I18N_ENABLE_NAMESPACE_MUTATION_ERROR, error);
}) })
.finally(() => { .finally(() => {
this.isLoadingEnableGroup = false; this.isLoadingEnableGroup = false;
...@@ -224,8 +216,8 @@ export default { ...@@ -224,8 +216,8 @@ export default {
startPollingTableData() { startPollingTableData() {
this.pollingTableData = setInterval(this.pollTableData, DEFAULT_POLLING_INTERVAL); this.pollingTableData = setInterval(this.pollTableData, DEFAULT_POLLING_INTERVAL);
}, },
handleError(key, error) { handleError(message, error) {
this.errors[key] = true; this.errors.push(message);
Sentry.captureException(error); Sentry.captureException(error);
}, },
fetchGroups(searchTerm = '') { fetchGroups(searchTerm = '') {
...@@ -251,7 +243,7 @@ export default { ...@@ -251,7 +243,7 @@ export default {
this.isLoadingGroups = false; this.isLoadingGroups = false;
}) })
.catch((error) => this.handleError(DEVOPS_ADOPTION_ERROR_KEYS.groups, error)); .catch((error) => this.handleError(I18N_GROUPS_QUERY_ERROR, error));
}, },
addEnabledNamespacesToCache(enabledNamespaces) { addEnabledNamespacesToCache(enabledNamespaces) {
const { cache } = this.$apollo.getClient(); const { cache } = this.$apollo.getClient();
...@@ -322,7 +314,7 @@ export default { ...@@ -322,7 +314,7 @@ export default {
<div v-if="hasLoadingError"> <div v-if="hasLoadingError">
<template v-for="(error, key) in errors"> <template v-for="(error, key) in errors">
<gl-alert v-if="error" :key="key" variant="danger" :dismissible="false" class="gl-mt-3"> <gl-alert v-if="error" :key="key" variant="danger" :dismissible="false" class="gl-mt-3">
{{ $options.i18n[key] }} {{ error }}
</gl-alert> </gl-alert>
</template> </template>
</div> </div>
......
<script> <script>
import { GlModal, GlSprintf, GlAlert } from '@gitlab/ui'; import { GlModal, GlSprintf, GlAlert } from '@gitlab/ui';
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import { DEVOPS_ADOPTION_STRINGS, DEVOPS_ADOPTION_DELETE_MODAL_ID } from '../constants'; import {
I18N_DELETE_MODAL_TITLE,
I18N_DELETE_MODAL_CONFIRMATION_MESSAGE,
I18N_DELETE_MODAL_CANCEL,
I18N_DELETE_MODAL_CONFIRM,
I18N_DELETE_MODAL_ERROR,
DELETE_MODAL_ID,
} from '../constants';
import disableDevopsAdoptionNamespaceMutation from '../graphql/mutations/disable_devops_adoption_namespace.mutation.graphql'; import disableDevopsAdoptionNamespaceMutation from '../graphql/mutations/disable_devops_adoption_namespace.mutation.graphql';
export default { export default {
name: 'DevopsAdoptionDeleteModal', name: 'DevopsAdoptionDeleteModal',
components: { GlModal, GlSprintf, GlAlert }, components: { GlModal, GlSprintf, GlAlert },
i18n: DEVOPS_ADOPTION_STRINGS.deleteModal, i18n: {
deleteModalId: DEVOPS_ADOPTION_DELETE_MODAL_ID, title: I18N_DELETE_MODAL_TITLE,
confirmationMessage: I18N_DELETE_MODAL_CONFIRMATION_MESSAGE,
cancel: I18N_DELETE_MODAL_CANCEL,
confirm: I18N_DELETE_MODAL_CONFIRM,
error: I18N_DELETE_MODAL_ERROR,
},
deleteModalId: DELETE_MODAL_ID,
props: { props: {
namespace: { namespace: {
type: Object, type: Object,
......
<script> <script>
import { GlEmptyState, GlModalDirective } from '@gitlab/ui'; import { GlEmptyState, GlModalDirective } from '@gitlab/ui';
import { DEVOPS_ADOPTION_STRINGS } from '../constants'; import { I18N_EMPTY_STATE_TITLE, I18N_EMPTY_STATE_DESCRIPTION } from '../constants';
export default { export default {
name: 'DevopsAdoptionEmptyState', name: 'DevopsAdoptionEmptyState',
...@@ -11,7 +11,10 @@ export default { ...@@ -11,7 +11,10 @@ export default {
GlModal: GlModalDirective, GlModal: GlModalDirective,
}, },
inject: ['emptyStateSvgPath'], inject: ['emptyStateSvgPath'],
i18n: DEVOPS_ADOPTION_STRINGS.emptyState, i18n: {
title: I18N_EMPTY_STATE_TITLE,
description: I18N_EMPTY_STATE_DESCRIPTION,
},
props: { props: {
hasGroupsData: { hasGroupsData: {
type: Boolean, type: Boolean,
......
...@@ -4,7 +4,7 @@ import { sprintf } from '~/locale'; ...@@ -4,7 +4,7 @@ import { sprintf } from '~/locale';
import { import {
DEVOPS_ADOPTION_TABLE_CONFIGURATION, DEVOPS_ADOPTION_TABLE_CONFIGURATION,
DEVOPS_ADOPTION_OVERALL_CONFIGURATION, DEVOPS_ADOPTION_OVERALL_CONFIGURATION,
TABLE_HEADER_TEXT, I18N_TABLE_HEADER_TEXT,
} from '../constants'; } from '../constants';
import DevopsAdoptionOverviewCard from './devops_adoption_overview_card.vue'; import DevopsAdoptionOverviewCard from './devops_adoption_overview_card.vue';
...@@ -56,7 +56,7 @@ export default { ...@@ -56,7 +56,7 @@ export default {
return [this.overallData, ...this.featuresData]; return [this.overallData, ...this.featuresData];
}, },
headerText() { headerText() {
return sprintf(TABLE_HEADER_TEXT, { timestamp: this.timestamp }); return sprintf(I18N_TABLE_HEADER_TEXT, { timestamp: this.timestamp });
}, },
}, },
}; };
......
<script> <script>
import { GlIcon, GlProgressBar } from '@gitlab/ui'; import { GlIcon, GlProgressBar } from '@gitlab/ui';
import { sprintf } from '~/locale'; import { sprintf } from '~/locale';
import { import { I18N_FEATURES_ADOPTED_TEXT, PROGRESS_BAR_HEIGHT } from '../constants';
DEVOPS_ADOPTION_FEATURES_ADOPTED_TEXT,
DEVOPS_ADOPTION_PROGRESS_BAR_HEIGHT,
} from '../constants';
import DevopsAdoptionTableCellFlag from './devops_adoption_table_cell_flag.vue'; import DevopsAdoptionTableCellFlag from './devops_adoption_table_cell_flag.vue';
export default { export default {
name: 'DevopsAdoptionOverviewCard', name: 'DevopsAdoptionOverviewCard',
progressBarHeight: DEVOPS_ADOPTION_PROGRESS_BAR_HEIGHT, progressBarHeight: PROGRESS_BAR_HEIGHT,
components: { components: {
GlIcon, GlIcon,
GlProgressBar, GlProgressBar,
...@@ -48,7 +45,7 @@ export default { ...@@ -48,7 +45,7 @@ export default {
return this.featureMeta.filter((feature) => feature.adopted).length; return this.featureMeta.filter((feature) => feature.adopted).length;
}, },
description() { description() {
return sprintf(DEVOPS_ADOPTION_FEATURES_ADOPTED_TEXT, { return sprintf(I18N_FEATURES_ADOPTED_TEXT, {
adoptedCount: this.adoptedCount, adoptedCount: this.adoptedCount,
featuresCount: this.featuresCount, featuresCount: this.featuresCount,
title: this.displayMeta ? this.title : '', title: this.displayMeta ? this.title : '',
......
<script> <script>
import { GlLoadingIcon, GlSprintf } from '@gitlab/ui'; import { GlLoadingIcon, GlSprintf } from '@gitlab/ui';
import { TABLE_HEADER_TEXT } from '../constants'; import { I18N_TABLE_HEADER_TEXT } from '../constants';
import DevopsAdoptionAddDropdown from './devops_adoption_add_dropdown.vue'; import DevopsAdoptionAddDropdown from './devops_adoption_add_dropdown.vue';
import DevopsAdoptionEmptyState from './devops_adoption_empty_state.vue'; import DevopsAdoptionEmptyState from './devops_adoption_empty_state.vue';
import DevopsAdoptionTable from './devops_adoption_table.vue'; import DevopsAdoptionTable from './devops_adoption_table.vue';
...@@ -14,7 +14,7 @@ export default { ...@@ -14,7 +14,7 @@ export default {
DevopsAdoptionAddDropdown, DevopsAdoptionAddDropdown,
}, },
i18n: { i18n: {
tableHeaderText: TABLE_HEADER_TEXT, tableHeaderText: I18N_TABLE_HEADER_TEXT,
}, },
props: { props: {
isLoading: { isLoading: {
......
...@@ -9,13 +9,17 @@ import { ...@@ -9,13 +9,17 @@ import {
} from '@gitlab/ui'; } from '@gitlab/ui';
import LocalStorageSync from '~/vue_shared/components/local_storage_sync.vue'; import LocalStorageSync from '~/vue_shared/components/local_storage_sync.vue';
import { import {
DEVOPS_ADOPTION_TABLE_TEST_IDS, TABLE_TEST_IDS_HEADERS,
DEVOPS_ADOPTION_STRINGS, TABLE_TEST_IDS_NAMESPACE,
DEVOPS_ADOPTION_DELETE_MODAL_ID, TABLE_TEST_IDS_ACTIONS,
DEVOPS_ADOPTION_TABLE_SORT_BY_STORAGE_KEY, TABLE_TEST_IDS_LOCAL_STORAGE_SORT_BY,
DEVOPS_ADOPTION_TABLE_SORT_DESC_STORAGE_KEY, TABLE_TEST_IDS_LOCAL_STORAGE_SORT_DESC,
DEVOPS_ADOPTION_TABLE_REMOVE_BUTTON_DISABLED, DELETE_MODAL_ID,
DEVOPS_ADOPTION_GROUP_COL_LABEL, TABLE_SORT_BY_STORAGE_KEY,
TABLE_SORT_DESC_STORAGE_KEY,
I18N_TABLE_REMOVE_BUTTON,
I18N_TABLE_REMOVE_BUTTON_DISABLED,
I18N_GROUP_COL_LABEL,
} from '../constants'; } from '../constants';
import DevopsAdoptionDeleteModal from './devops_adoption_delete_modal.vue'; import DevopsAdoptionDeleteModal from './devops_adoption_delete_modal.vue';
import DevopsAdoptionTableCellFlag from './devops_adoption_table_cell_flag.vue'; import DevopsAdoptionTableCellFlag from './devops_adoption_table_cell_flag.vue';
...@@ -38,14 +42,12 @@ const formatter = (value, key, item) => { ...@@ -38,14 +42,12 @@ const formatter = (value, key, item) => {
const fieldOptions = { const fieldOptions = {
thClass: 'gl-bg-white! gl-text-gray-400', thClass: 'gl-bg-white! gl-text-gray-400',
thAttr: { 'data-testid': DEVOPS_ADOPTION_TABLE_TEST_IDS.TABLE_HEADERS }, thAttr: { 'data-testid': TABLE_TEST_IDS_HEADERS },
formatter, formatter,
sortable: true, sortable: true,
sortByFormatted: true, sortByFormatted: true,
}; };
const { table: i18n } = DEVOPS_ADOPTION_STRINGS;
export default { export default {
name: 'DevopsAdoptionTable', name: 'DevopsAdoptionTable',
components: { components: {
...@@ -67,13 +69,18 @@ export default { ...@@ -67,13 +69,18 @@ export default {
}, },
}, },
i18n: { i18n: {
...i18n, removeButtonDisabled: I18N_TABLE_REMOVE_BUTTON_DISABLED,
removeButtonDisabled: DEVOPS_ADOPTION_TABLE_REMOVE_BUTTON_DISABLED, removeButton: I18N_TABLE_REMOVE_BUTTON,
}, },
deleteModalId: DEVOPS_ADOPTION_DELETE_MODAL_ID, deleteModalId: DELETE_MODAL_ID,
testids: DEVOPS_ADOPTION_TABLE_TEST_IDS, testids: {
sortByStorageKey: DEVOPS_ADOPTION_TABLE_SORT_BY_STORAGE_KEY, NAMESPACE: TABLE_TEST_IDS_NAMESPACE,
sortDescStorageKey: DEVOPS_ADOPTION_TABLE_SORT_DESC_STORAGE_KEY, ACTIONS: TABLE_TEST_IDS_ACTIONS,
LOCAL_STORAGE_SORT_BY: TABLE_TEST_IDS_LOCAL_STORAGE_SORT_BY,
LOCAL_STORAGE_SORT_DESC: TABLE_TEST_IDS_LOCAL_STORAGE_SORT_DESC,
},
sortByStorageKey: TABLE_SORT_BY_STORAGE_KEY,
sortDescStorageKey: TABLE_SORT_DESC_STORAGE_KEY,
props: { props: {
enabledNamespaces: { enabledNamespaces: {
type: Array, type: Array,
...@@ -96,7 +103,7 @@ export default { ...@@ -96,7 +103,7 @@ export default {
return [ return [
{ {
key: 'name', key: 'name',
label: DEVOPS_ADOPTION_GROUP_COL_LABEL, label: I18N_GROUP_COL_LABEL,
...fieldOptions, ...fieldOptions,
}, },
...this.cols.map((item) => ({ ...this.cols.map((item) => ({
......
<script> <script>
import { GlTooltipDirective } from '@gitlab/ui'; import { GlTooltipDirective } from '@gitlab/ui';
import { DEVOPS_ADOPTION_STRINGS } from '../constants'; import { I18N_CELL_FLAG_TRUE_TEXT, I18N_CELL_FLAG_FALSE_TEXT } from '../constants';
const {
tableCell: { trueText, falseText },
} = DEVOPS_ADOPTION_STRINGS;
export default { export default {
name: 'DevopsAdoptionTableCellFlag', name: 'DevopsAdoptionTableCellFlag',
...@@ -24,7 +20,7 @@ export default { ...@@ -24,7 +20,7 @@ export default {
}, },
computed: { computed: {
tooltipText() { tooltipText() {
return this.enabled ? trueText : falseText; return this.enabled ? I18N_CELL_FLAG_TRUE_TEXT : I18N_CELL_FLAG_FALSE_TEXT;
}, },
}, },
}; };
......
import { s__, __ } from '~/locale'; import { s__, __ } from '~/locale';
export const DEFAULT_POLLING_INTERVAL = 30000; export const DEFAULT_POLLING_INTERVAL = 30000;
export const PER_PAGE = 20; export const PER_PAGE = 20;
export const DEBOUNCE_DELAY = 500; export const DEBOUNCE_DELAY = 500;
export const PROGRESS_BAR_HEIGHT = '8px';
export const DATE_TIME_FORMAT = 'yyyy-mm-dd HH:MM';
export const DELETE_MODAL_ID = 'devopsDeleteModal';
export const DEVOPS_ADOPTION_PROGRESS_BAR_HEIGHT = '8px'; export const TABLE_TEST_IDS_HEADERS = 'header';
export const TABLE_TEST_IDS_NAMESPACE = 'namespaceCol';
export const DEVOPS_ADOPTION_DELETE_MODAL_ID = 'devopsDeleteModal'; export const TABLE_TEST_IDS_ACTIONS = 'actionsCol';
export const TABLE_TEST_IDS_LOCAL_STORAGE_SORT_BY = 'localStorageSortBy';
export const TABLE_TEST_IDS_LOCAL_STORAGE_SORT_DESC = 'localStorageSortDesc';
export const DATE_TIME_FORMAT = 'yyyy-mm-dd HH:MM'; export const TABLE_SORT_BY_STORAGE_KEY = 'devops_adoption_table_sort_by';
export const TABLE_SORT_DESC_STORAGE_KEY = 'devops_adoption_table_sort_desc';
export const DEVOPS_ADOPTION_ERROR_KEYS = { export const TRACK_ADOPTION_TAB_CLICK_EVENT = 'i_analytics_dev_ops_adoption';
groups: 'groupsError', export const TRACK_DEVOPS_SCORE_TAB_CLICK_EVENT = 'i_analytics_dev_ops_score';
enabledNamespaces: 'enabledNamespacesError',
addEnabledNamespaces: 'addEnabledNamespacesError',
};
export const TABLE_HEADER_TEXT = s__( export const I18N_GROUPS_QUERY_ERROR = s__(
'DevopsAdoption|Feature adoption is based on usage in the previous calendar month. Last updated: %{timestamp}.', 'DevopsAdoption|There was an error fetching Groups. Please refresh the page.',
);
export const I18N_ENABLED_NAMESPACE_QUERY_ERROR = s__(
'DevopsAdoption|There was an error fetching Group adoption data. Please refresh the page.',
);
export const I18N_ENABLE_NAMESPACE_MUTATION_ERROR = s__(
'DevopsAdoption|There was an error enabling the current group. Please refresh the page.',
); );
export const DEVOPS_ADOPTION_GROUP_LEVEL_LABEL = s__('DevopsAdoption|Add/remove sub-groups'); export const I18N_TABLE_REMOVE_BUTTON = s__('DevopsAdoption|Remove Group from the table.');
export const I18N_TABLE_REMOVE_BUTTON_DISABLED = s__(
export const DEVOPS_ADOPTION_TABLE_REMOVE_BUTTON_DISABLED = s__(
'DevopsAdoption|You cannot remove the group you are currently in.', 'DevopsAdoption|You cannot remove the group you are currently in.',
); );
export const DEVOPS_ADOPTION_GROUP_DROPDOWN_TEXT = s__('DevopsAdoption|Add sub-group to table'); export const I18N_GROUP_DROPDOWN_TEXT = s__('DevopsAdoption|Add sub-group to table');
export const DEVOPS_ADOPTION_GROUP_DROPDOWN_HEADER = s__('DevopsAdoption|Add sub-group'); export const I18N_GROUP_DROPDOWN_HEADER = s__('DevopsAdoption|Add sub-group');
export const DEVOPS_ADOPTION_ADMIN_DROPDOWN_TEXT = s__('DevopsAdoption|Add group to table'); export const I18N_ADMIN_DROPDOWN_TEXT = s__('DevopsAdoption|Add group to table');
export const DEVOPS_ADOPTION_ADMIN_DROPDOWN_HEADER = s__('DevopsAdoption|Add group'); export const I18N_ADMIN_DROPDOWN_HEADER = s__('DevopsAdoption|Add group');
export const DEVOPS_ADOPTION_NO_RESULTS = s__('DevopsAdoption|No results…'); export const I18N_NO_RESULTS = s__('DevopsAdoption|No results…');
export const I18N_NO_SUB_GROUPS = s__('DevopsAdoption|This group has no sub-groups');
export const DEVOPS_ADOPTION_NO_SUB_GROUPS = s__('DevopsAdoption|This group has no sub-groups'); export const I18N_FEATURES_ADOPTED_TEXT = s__(
export const DEVOPS_ADOPTION_FEATURES_ADOPTED_TEXT = s__(
'DevopsAdoption|%{adoptedCount}/%{featuresCount} %{title} features adopted', 'DevopsAdoption|%{adoptedCount}/%{featuresCount} %{title} features adopted',
); );
export const DEVOPS_ADOPTION_STRINGS = { export const I18N_EMPTY_STATE_TITLE = s__('DevopsAdoption|Add a group to get started');
app: { export const I18N_EMPTY_STATE_DESCRIPTION = s__(
[DEVOPS_ADOPTION_ERROR_KEYS.groups]: s__(
'DevopsAdoption|There was an error fetching Groups. Please refresh the page.',
),
[DEVOPS_ADOPTION_ERROR_KEYS.enabledNamespaces]: s__(
'DevopsAdoption|There was an error fetching Group adoption data. Please refresh the page.',
),
[DEVOPS_ADOPTION_ERROR_KEYS.addEnabledNamespaces]: s__(
'DevopsAdoption|There was an error enabling the current group. Please refresh the page.',
),
tableHeader: {
button: s__('DevopsAdoption|Add/remove groups'),
},
},
emptyState: {
title: s__('DevopsAdoption|Add a group to get started'),
description: s__(
'DevopsAdoption|DevOps adoption tracks the use of key features across your favorite groups. Add a group to the table to begin.', 'DevopsAdoption|DevOps adoption tracks the use of key features across your favorite groups. Add a group to the table to begin.',
), );
button: s__('DevopsAdoption|Add Group'),
},
modal: {
addingTitle: s__('DevopsAdoption|Add/remove groups'),
addingButton: s__('DevopsAdoption|Save changes'),
cancel: __('Cancel'),
namePlaceholder: s__('DevopsAdoption|My group'),
filterPlaceholder: s__('DevopsAdoption|Filter by name'),
error: s__('DevopsAdoption|An error occurred while saving changes. Please try again.'),
noResults: s__('DevopsAdoption|No filter results.'),
},
table: {
removeButton: s__('DevopsAdoption|Remove Group from the table.'),
},
deleteModal: {
title: s__('DevopsAdoption|Confirm remove Group'),
confirmationMessage: s__(
'DevopsAdoption|Are you sure that you would like to remove %{name} from the table?',
),
cancel: __('Cancel'),
confirm: s__('DevopsAdoption|Remove Group'),
error: s__('DevopsAdoption|An error occurred while removing the group. Please try again.'),
},
tableCell: {
trueText: s__('DevopsAdoption|Adopted'),
falseText: s__('DevopsAdoption|Not adopted'),
},
};
export const DEVOPS_ADOPTION_TABLE_TEST_IDS = { export const I18N_DELETE_MODAL_TITLE = s__('DevopsAdoption|Confirm remove Group');
TABLE_HEADERS: 'header', export const I18N_DELETE_MODAL_CONFIRMATION_MESSAGE = s__(
NAMESPACE: 'namespaceCol', 'DevopsAdoption|Are you sure that you would like to remove %{name} from the table?',
ACTIONS: 'actionsCol', );
LOCAL_STORAGE_SORT_BY: 'localStorageSortBy', export const I18N_DELETE_MODAL_CANCEL = __('Cancel');
LOCAL_STORAGE_SORT_DESC: 'localStorageSortDesc', export const I18N_DELETE_MODAL_CONFIRM = s__('DevopsAdoption|Remove Group');
}; export const I18N_DELETE_MODAL_ERROR = s__(
'DevopsAdoption|An error occurred while removing the group. Please try again.',
);
export const DEVOPS_ADOPTION_TABLE_SORT_BY_STORAGE_KEY = 'devops_adoption_table_sort_by'; export const I18N_TABLE_HEADER_TEXT = s__(
'DevopsAdoption|Feature adoption is based on usage in the previous calendar month. Last updated: %{timestamp}.',
);
export const DEVOPS_ADOPTION_TABLE_SORT_DESC_STORAGE_KEY = 'devops_adoption_table_sort_desc'; export const I18N_CELL_FLAG_TRUE_TEXT = s__('DevopsAdoption|Adopted');
export const I18N_CELL_FLAG_FALSE_TEXT = s__('DevopsAdoption|Not adopted');
export const DEVOPS_ADOPTION_GROUP_COL_LABEL = __('Group'); export const I18N_GROUP_COL_LABEL = __('Group');
export const DEVOPS_ADOPTION_OVERALL_CONFIGURATION = { export const DEVOPS_ADOPTION_OVERALL_CONFIGURATION = {
title: s__('DevopsAdoption|Overall adoption'), title: s__('DevopsAdoption|Overall adoption'),
...@@ -197,7 +163,3 @@ export const DEVOPS_ADOPTION_TABLE_CONFIGURATION = [ ...@@ -197,7 +163,3 @@ export const DEVOPS_ADOPTION_TABLE_CONFIGURATION = [
], ],
}, },
]; ];
export const TRACK_ADOPTION_TAB_CLICK_EVENT = 'i_analytics_dev_ops_adoption';
export const TRACK_DEVOPS_SCORE_TAB_CLICK_EVENT = 'i_analytics_dev_ops_score';
...@@ -8,7 +8,9 @@ import DevopsAdoptionApp from 'ee/analytics/devops_report/devops_adoption/compon ...@@ -8,7 +8,9 @@ import DevopsAdoptionApp from 'ee/analytics/devops_report/devops_adoption/compon
import DevopsAdoptionOverview from 'ee/analytics/devops_report/devops_adoption/components/devops_adoption_overview.vue'; import DevopsAdoptionOverview from 'ee/analytics/devops_report/devops_adoption/components/devops_adoption_overview.vue';
import DevopsAdoptionSection from 'ee/analytics/devops_report/devops_adoption/components/devops_adoption_section.vue'; import DevopsAdoptionSection from 'ee/analytics/devops_report/devops_adoption/components/devops_adoption_section.vue';
import { import {
DEVOPS_ADOPTION_STRINGS, I18N_GROUPS_QUERY_ERROR,
I18N_ENABLE_NAMESPACE_MUTATION_ERROR,
I18N_ENABLED_NAMESPACE_QUERY_ERROR,
DEFAULT_POLLING_INTERVAL, DEFAULT_POLLING_INTERVAL,
DEVOPS_ADOPTION_TABLE_CONFIGURATION, DEVOPS_ADOPTION_TABLE_CONFIGURATION,
} from 'ee/analytics/devops_report/devops_adoption/constants'; } from 'ee/analytics/devops_report/devops_adoption/constants';
...@@ -170,7 +172,7 @@ describe('DevopsAdoptionApp', () => { ...@@ -170,7 +172,7 @@ describe('DevopsAdoptionApp', () => {
it('displays the error message and calls Sentry', () => { it('displays the error message and calls Sentry', () => {
const alert = wrapper.findComponent(GlAlert); const alert = wrapper.findComponent(GlAlert);
expect(alert.exists()).toBe(true); expect(alert.exists()).toBe(true);
expect(alert.text()).toBe(DEVOPS_ADOPTION_STRINGS.app.groupsError); expect(alert.text()).toBe(I18N_GROUPS_QUERY_ERROR);
expect(Sentry.captureException.mock.calls[0][0].networkError).toBe(NETWORK_ERROR); expect(Sentry.captureException.mock.calls[0][0].networkError).toBe(NETWORK_ERROR);
}); });
}); });
...@@ -270,7 +272,7 @@ describe('DevopsAdoptionApp', () => { ...@@ -270,7 +272,7 @@ describe('DevopsAdoptionApp', () => {
it('displays the error message ', () => { it('displays the error message ', () => {
const alert = wrapper.findComponent(GlAlert); const alert = wrapper.findComponent(GlAlert);
expect(alert.exists()).toBe(true); expect(alert.exists()).toBe(true);
expect(alert.text()).toBe(DEVOPS_ADOPTION_STRINGS.app.addEnabledNamespacesError); expect(alert.text()).toBe(I18N_ENABLE_NAMESPACE_MUTATION_ERROR);
}); });
it('calls Sentry', () => { it('calls Sentry', () => {
...@@ -301,7 +303,7 @@ describe('DevopsAdoptionApp', () => { ...@@ -301,7 +303,7 @@ describe('DevopsAdoptionApp', () => {
it('displays the error message ', () => { it('displays the error message ', () => {
const alert = wrapper.findComponent(GlAlert); const alert = wrapper.findComponent(GlAlert);
expect(alert.exists()).toBe(true); expect(alert.exists()).toBe(true);
expect(alert.text()).toBe(DEVOPS_ADOPTION_STRINGS.app.enabledNamespacesError); expect(alert.text()).toBe(I18N_ENABLED_NAMESPACE_QUERY_ERROR);
}); });
it('calls Sentry', () => { it('calls Sentry', () => {
......
...@@ -4,7 +4,7 @@ import { createLocalVue, shallowMount } from '@vue/test-utils'; ...@@ -4,7 +4,7 @@ import { createLocalVue, shallowMount } from '@vue/test-utils';
import Vue from 'vue'; import Vue from 'vue';
import VueApollo from 'vue-apollo'; import VueApollo from 'vue-apollo';
import DevopsAdoptionDeleteModal from 'ee/analytics/devops_report/devops_adoption/components/devops_adoption_delete_modal.vue'; import DevopsAdoptionDeleteModal from 'ee/analytics/devops_report/devops_adoption/components/devops_adoption_delete_modal.vue';
import { DEVOPS_ADOPTION_DELETE_MODAL_ID } from 'ee/analytics/devops_report/devops_adoption/constants'; import { DELETE_MODAL_ID } from 'ee/analytics/devops_report/devops_adoption/constants';
import disableDevopsAdoptionNamespaceMutation from 'ee/analytics/devops_report/devops_adoption/graphql/mutations/disable_devops_adoption_namespace.mutation.graphql'; import disableDevopsAdoptionNamespaceMutation from 'ee/analytics/devops_report/devops_adoption/graphql/mutations/disable_devops_adoption_namespace.mutation.graphql';
import createMockApollo from 'helpers/mock_apollo_helper'; import createMockApollo from 'helpers/mock_apollo_helper';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
...@@ -72,7 +72,7 @@ describe('DevopsAdoptionDeleteModal', () => { ...@@ -72,7 +72,7 @@ describe('DevopsAdoptionDeleteModal', () => {
const modal = findModal(); const modal = findModal();
expect(modal.exists()).toBe(true); expect(modal.exists()).toBe(true);
expect(modal.props('modalId')).toBe(DEVOPS_ADOPTION_DELETE_MODAL_ID); expect(modal.props('modalId')).toBe(DELETE_MODAL_ID);
}); });
it('displays the confirmation message', () => { it('displays the confirmation message', () => {
......
import { GlEmptyState } from '@gitlab/ui'; import { GlEmptyState } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import DevopsAdoptionEmptyState from 'ee/analytics/devops_report/devops_adoption/components/devops_adoption_empty_state.vue'; import DevopsAdoptionEmptyState from 'ee/analytics/devops_report/devops_adoption/components/devops_adoption_empty_state.vue';
import { DEVOPS_ADOPTION_STRINGS } from 'ee/analytics/devops_report/devops_adoption/constants'; import {
I18N_EMPTY_STATE_TITLE,
I18N_EMPTY_STATE_DESCRIPTION,
} from 'ee/analytics/devops_report/devops_adoption/constants';
const emptyStateSvgPath = 'illustrations/monitoring/getting_started.svg'; const emptyStateSvgPath = 'illustrations/monitoring/getting_started.svg';
...@@ -40,7 +43,7 @@ describe('DevopsAdoptionEmptyState', () => { ...@@ -40,7 +43,7 @@ describe('DevopsAdoptionEmptyState', () => {
const emptyState = findEmptyState(); const emptyState = findEmptyState();
expect(emptyState.props('title')).toBe(DEVOPS_ADOPTION_STRINGS.emptyState.title); expect(emptyState.props('title')).toBe(I18N_EMPTY_STATE_TITLE);
expect(emptyState.props('description')).toBe(DEVOPS_ADOPTION_STRINGS.emptyState.description); expect(emptyState.props('description')).toBe(I18N_EMPTY_STATE_DESCRIPTION);
}); });
}); });
...@@ -5,7 +5,9 @@ import DevopsAdoptionDeleteModal from 'ee/analytics/devops_report/devops_adoptio ...@@ -5,7 +5,9 @@ import DevopsAdoptionDeleteModal from 'ee/analytics/devops_report/devops_adoptio
import DevopsAdoptionTable from 'ee/analytics/devops_report/devops_adoption/components/devops_adoption_table.vue'; import DevopsAdoptionTable from 'ee/analytics/devops_report/devops_adoption/components/devops_adoption_table.vue';
import DevopsAdoptionTableCellFlag from 'ee/analytics/devops_report/devops_adoption/components/devops_adoption_table_cell_flag.vue'; import DevopsAdoptionTableCellFlag from 'ee/analytics/devops_report/devops_adoption/components/devops_adoption_table_cell_flag.vue';
import { import {
DEVOPS_ADOPTION_TABLE_TEST_IDS as TEST_IDS, TABLE_TEST_IDS_NAMESPACE,
TABLE_TEST_IDS_ACTIONS,
TABLE_TEST_IDS_HEADERS,
DEVOPS_ADOPTION_TABLE_CONFIGURATION, DEVOPS_ADOPTION_TABLE_CONFIGURATION,
} from 'ee/analytics/devops_report/devops_adoption/constants'; } from 'ee/analytics/devops_report/devops_adoption/constants';
import { createMockDirective, getBinding } from 'helpers/vue_mock_directive'; import { createMockDirective, getBinding } from 'helpers/vue_mock_directive';
...@@ -58,7 +60,7 @@ describe('DevopsAdoptionTable', () => { ...@@ -58,7 +60,7 @@ describe('DevopsAdoptionTable', () => {
beforeEach(() => { beforeEach(() => {
createComponent(); createComponent();
headers = findTable().findAll(`[data-testid="${TEST_IDS.TABLE_HEADERS}"]`); headers = findTable().findAll(`[data-testid="${TABLE_TEST_IDS_HEADERS}"]`);
}); });
it('displays the correct number of headings', () => { it('displays the correct number of headings', () => {
...@@ -108,7 +110,7 @@ describe('DevopsAdoptionTable', () => { ...@@ -108,7 +110,7 @@ describe('DevopsAdoptionTable', () => {
it('displays the correct name', () => { it('displays the correct name', () => {
createComponent(); createComponent();
expect(findCol(TEST_IDS.NAMESPACE).text()).toBe('Group 1'); expect(findCol(TABLE_TEST_IDS_NAMESPACE).text()).toBe('Group 1');
}); });
describe('"This group" badge', () => { describe('"This group" badge', () => {
...@@ -122,7 +124,7 @@ describe('DevopsAdoptionTable', () => { ...@@ -122,7 +124,7 @@ describe('DevopsAdoptionTable', () => {
`('$scenario', ({ expected, provide }) => { `('$scenario', ({ expected, provide }) => {
createComponent({ provide }); createComponent({ provide });
const badge = findColSubComponent(TEST_IDS.NAMESPACE, GlBadge); const badge = findColSubComponent(TABLE_TEST_IDS_NAMESPACE, GlBadge);
expect(badge.exists()).toBe(expected); expect(badge.exists()).toBe(expected);
}); });
...@@ -134,7 +136,7 @@ describe('DevopsAdoptionTable', () => { ...@@ -134,7 +136,7 @@ describe('DevopsAdoptionTable', () => {
}); });
it('grays the text out', () => { it('grays the text out', () => {
const name = findColRowChild(TEST_IDS.NAMESPACE, 1, 'span'); const name = findColRowChild(TABLE_TEST_IDS_NAMESPACE, 1, 'span');
expect(name.classes()).toStrictEqual(['gl-text-gray-400']); expect(name.classes()).toStrictEqual(['gl-text-gray-400']);
}); });
...@@ -143,7 +145,7 @@ describe('DevopsAdoptionTable', () => { ...@@ -143,7 +145,7 @@ describe('DevopsAdoptionTable', () => {
let icon; let icon;
beforeEach(() => { beforeEach(() => {
icon = findColRowChild(TEST_IDS.NAMESPACE, 1, GlIcon); icon = findColRowChild(TABLE_TEST_IDS_NAMESPACE, 1, GlIcon);
}); });
it('displays the icon', () => { it('displays the icon', () => {
...@@ -174,7 +176,7 @@ describe('DevopsAdoptionTable', () => { ...@@ -174,7 +176,7 @@ describe('DevopsAdoptionTable', () => {
}); });
it('displays the actions icon', () => { it('displays the actions icon', () => {
const button = findColSubComponent(TEST_IDS.ACTIONS, GlButton); const button = findColSubComponent(TABLE_TEST_IDS_ACTIONS, GlButton);
expect(button.exists()).toBe(true); expect(button.exists()).toBe(true);
expect(button.props('disabled')).toBe(disabled); expect(button.props('disabled')).toBe(disabled);
...@@ -183,7 +185,7 @@ describe('DevopsAdoptionTable', () => { ...@@ -183,7 +185,7 @@ describe('DevopsAdoptionTable', () => {
}); });
it('wraps the icon in an element with a tooltip', () => { it('wraps the icon in an element with a tooltip', () => {
const iconWrapper = findCol(TEST_IDS.ACTIONS); const iconWrapper = findCol(TABLE_TEST_IDS_ACTIONS);
const tooltip = getBinding(iconWrapper.element, 'gl-tooltip'); const tooltip = getBinding(iconWrapper.element, 'gl-tooltip');
expect(iconWrapper.exists()).toBe(true); expect(iconWrapper.exists()).toBe(true);
...@@ -214,17 +216,17 @@ describe('DevopsAdoptionTable', () => { ...@@ -214,17 +216,17 @@ describe('DevopsAdoptionTable', () => {
beforeEach(() => { beforeEach(() => {
createComponent(); createComponent();
headers = findTable().findAll(`[data-testid="${TEST_IDS.TABLE_HEADERS}"]`); headers = findTable().findAll(`[data-testid="${TABLE_TEST_IDS_HEADERS}"]`);
}); });
it('sorts the namespaces by name', async () => { it('sorts the namespaces by name', async () => {
expect(findCol(TEST_IDS.NAMESPACE).text()).toBe('Group 1'); expect(findCol(TABLE_TEST_IDS_NAMESPACE).text()).toBe('Group 1');
headers.at(0).trigger('click'); headers.at(0).trigger('click');
await nextTick(); await nextTick();
expect(findCol(TEST_IDS.NAMESPACE).text()).toBe('Group 2'); expect(findCol(TABLE_TEST_IDS_NAMESPACE).text()).toBe('Group 2');
}); });
it('should update local storage when the sort column changes', async () => { it('should update local storage when the sort column changes', async () => {
......
...@@ -11243,9 +11243,6 @@ msgstr "" ...@@ -11243,9 +11243,6 @@ msgstr ""
msgid "DevopsAdoption|%{adoptedCount}/%{featuresCount} %{title} features adopted" msgid "DevopsAdoption|%{adoptedCount}/%{featuresCount} %{title} features adopted"
msgstr "" msgstr ""
msgid "DevopsAdoption|Add Group"
msgstr ""
msgid "DevopsAdoption|Add a group to get started" msgid "DevopsAdoption|Add a group to get started"
msgstr "" msgstr ""
...@@ -11261,21 +11258,12 @@ msgstr "" ...@@ -11261,21 +11258,12 @@ msgstr ""
msgid "DevopsAdoption|Add sub-group to table" msgid "DevopsAdoption|Add sub-group to table"
msgstr "" msgstr ""
msgid "DevopsAdoption|Add/remove groups"
msgstr ""
msgid "DevopsAdoption|Add/remove sub-groups"
msgstr ""
msgid "DevopsAdoption|Adopted" msgid "DevopsAdoption|Adopted"
msgstr "" msgstr ""
msgid "DevopsAdoption|An error occurred while removing the group. Please try again." msgid "DevopsAdoption|An error occurred while removing the group. Please try again."
msgstr "" msgstr ""
msgid "DevopsAdoption|An error occurred while saving changes. Please try again."
msgstr ""
msgid "DevopsAdoption|Approvals" msgid "DevopsAdoption|Approvals"
msgstr "" msgstr ""
...@@ -11327,21 +11315,12 @@ msgstr "" ...@@ -11327,21 +11315,12 @@ msgstr ""
msgid "DevopsAdoption|Feature adoption is based on usage in the previous calendar month. Last updated: %{timestamp}." msgid "DevopsAdoption|Feature adoption is based on usage in the previous calendar month. Last updated: %{timestamp}."
msgstr "" msgstr ""
msgid "DevopsAdoption|Filter by name"
msgstr ""
msgid "DevopsAdoption|Issues" msgid "DevopsAdoption|Issues"
msgstr "" msgstr ""
msgid "DevopsAdoption|MRs" msgid "DevopsAdoption|MRs"
msgstr "" msgstr ""
msgid "DevopsAdoption|My group"
msgstr ""
msgid "DevopsAdoption|No filter results."
msgstr ""
msgid "DevopsAdoption|No results…" msgid "DevopsAdoption|No results…"
msgstr "" msgstr ""
...@@ -11375,9 +11354,6 @@ msgstr "" ...@@ -11375,9 +11354,6 @@ msgstr ""
msgid "DevopsAdoption|SAST enabled for at least one project" msgid "DevopsAdoption|SAST enabled for at least one project"
msgstr "" msgstr ""
msgid "DevopsAdoption|Save changes"
msgstr ""
msgid "DevopsAdoption|Scanning" msgid "DevopsAdoption|Scanning"
msgstr "" msgstr ""
......
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