Commit 81099a12 authored by Justin Ho's avatar Justin Ho

Extract i18n strings to constants

To be reused in tests
parent 088d5822
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
import { GlButton, GlIcon } from '@gitlab/ui'; import { GlButton, GlIcon } from '@gitlab/ui';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { redirectTo } from '~/lib/utils/url_utility'; import { redirectTo } from '~/lib/utils/url_utility';
import { __ } from '~/locale';
import { addProjectToSlack } from '../api'; import { addProjectToSlack } from '../api';
import { i18n } from '../constants';
import ProjectsDropdown from './projects_dropdown.vue'; import ProjectsDropdown from './projects_dropdown.vue';
export default { export default {
...@@ -40,6 +40,7 @@ export default { ...@@ -40,6 +40,7 @@ export default {
required: true, required: true,
}, },
}, },
i18n,
data() { data() {
return { return {
selectedProject: null, selectedProject: null,
...@@ -59,7 +60,7 @@ export default { ...@@ -59,7 +60,7 @@ export default {
.then((response) => redirectTo(response.data.add_to_slack_link)) .then((response) => redirectTo(response.data.add_to_slack_link))
.catch(() => .catch(() =>
createFlash({ createFlash({
message: __('Unable to build Slack link.'), message: i18n.slackErrorMessage,
}), }),
); );
}, },
...@@ -70,22 +71,22 @@ export default { ...@@ -70,22 +71,22 @@ export default {
<template> <template>
<div class="gitlab-slack-body gl-mx-auto gl-mt-11 gl-text-center"> <div class="gitlab-slack-body gl-mx-auto gl-mt-11 gl-text-center">
<div v-once class="gl-my-5 gl-display-flex gl-justify-content-center gl-align-items-center"> <div v-once class="gl-my-5 gl-display-flex gl-justify-content-center gl-align-items-center">
<img :src="gitlabLogoPath" :alt="__('GitLab logo')" class="gl-h-11 gl-w-11" /> <img :src="gitlabLogoPath" :alt="$options.i18n.gitlabLogoAlt" class="gl-h-11 gl-w-11" />
<gl-icon name="arrow-right" :size="32" class="gl-mx-5 gl-text-gray-200" /> <gl-icon name="arrow-right" :size="32" class="gl-mx-5 gl-text-gray-200" />
<img <img
:src="slackLogoPath" :src="slackLogoPath"
:alt="__('Slack logo')" :alt="$options.i18n.slackLogoAlt"
class="gitlab-slack-slack-logo gl-h-11 gl-w-11" class="gitlab-slack-slack-logo gl-h-11 gl-w-11"
/> />
</div> </div>
<h2>{{ s__('SlackIntegration|GitLab for Slack') }}</h2> <h2>{{ $options.i18n.title }}</h2>
<div class="gl-mt-6" data-testid="gitlab-slack-content"> <div class="gl-mt-6" data-testid="gitlab-slack-content">
<template v-if="isSignedIn"> <template v-if="isSignedIn">
<template v-if="hasProjects"> <template v-if="hasProjects">
<p> <p>
{{ s__('SlackIntegration|Select a GitLab project to link with your Slack workspace.') }} {{ $options.i18n.dropdownLabel }}
</p> </p>
<projects-dropdown <projects-dropdown
...@@ -101,18 +102,18 @@ export default { ...@@ -101,18 +102,18 @@ export default {
:disabled="!selectedProject" :disabled="!selectedProject"
@click="addToSlack" @click="addToSlack"
> >
{{ __('Continue') }} {{ $options.i18n.dropdownButtonText }}
</gl-button> </gl-button>
</div> </div>
</template> </template>
<p v-else>{{ __("You don't have any projects available.") }}</p> <p v-else>{{ $options.i18n.noProjects }}</p>
</template> </template>
<template v-else> <template v-else>
<p>{{ s__('JiraService|Sign in to GitLab.com to get started.') }}</p> <p>{{ $options.i18n.signInLabel }}</p>
<gl-button category="primary" variant="confirm" :href="signInPath">{{ <gl-button category="primary" variant="confirm" :href="signInPath">
__('Sign in to GitLab') {{ $options.i18n.signInButtonText }}
}}</gl-button> </gl-button>
</template> </template>
</div> </div>
</div> </div>
......
import { __, s__ } from '~/locale';
export const i18n = {
slackErrorMessage: __('Unable to build Slack link.'),
gitlabLogoAlt: __('GitLab logo'),
slackLogoAlt: __('Slack logo'),
title: s__('SlackIntegration|GitLab for Slack'),
dropdownLabel: s__('SlackIntegration|Select a GitLab project to link with your Slack workspace.'),
dropdownButtonText: __('Continue'),
noProjects: __("You don't have any projects available."),
signInLabel: s__('JiraService|Sign in to GitLab.com to get started.'),
signInButtonText: __('Sign in to GitLab'),
};
...@@ -2,6 +2,7 @@ import { GlButton } from '@gitlab/ui'; ...@@ -2,6 +2,7 @@ import { GlButton } from '@gitlab/ui';
import GitlabSlackApplication from 'ee/integrations/gitlab_slack_application/components/gitlab_slack_application.vue'; import GitlabSlackApplication from 'ee/integrations/gitlab_slack_application/components/gitlab_slack_application.vue';
import { addProjectToSlack } from 'ee/integrations/gitlab_slack_application/api'; import { addProjectToSlack } from 'ee/integrations/gitlab_slack_application/api';
import { i18n } from 'ee/integrations/gitlab_slack_application/constants';
import ProjectsDropdown from 'ee/integrations/gitlab_slack_application/components/projects_dropdown.vue'; import ProjectsDropdown from 'ee/integrations/gitlab_slack_application/components/projects_dropdown.vue';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper'; import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
...@@ -57,7 +58,7 @@ describe('GitlabSlackApplication', () => { ...@@ -57,7 +58,7 @@ describe('GitlabSlackApplication', () => {
it('renders empty text', () => { it('renders empty text', () => {
createComponent(); createComponent();
expect(findAppContent().text()).toBe("You don't have any projects available."); expect(findAppContent().text()).toBe(i18n.noProjects);
}); });
}); });
......
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