Commit 36f4701f authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'nfriend-edit-release-ux-cleanup' into 'master'

Update "Tag name" help text on Edit Release page

See merge request gitlab-org/gitlab!19321
parents ffe7a87a 867a30d3
<script> <script>
import { mapState, mapActions } from 'vuex'; import { mapState, mapActions } from 'vuex';
import { GlButton, GlFormInput, GlFormGroup } from '@gitlab/ui'; import { GlButton, GlFormInput, GlFormGroup } from '@gitlab/ui';
import _ from 'underscore';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import MarkdownField from '~/vue_shared/components/markdown/field.vue'; import MarkdownField from '~/vue_shared/components/markdown/field.vue';
import autofocusonshow from '~/vue_shared/directives/autofocusonshow'; import autofocusonshow from '~/vue_shared/directives/autofocusonshow';
...@@ -23,6 +24,7 @@ export default { ...@@ -23,6 +24,7 @@ export default {
'markdownDocsPath', 'markdownDocsPath',
'markdownPreviewPath', 'markdownPreviewPath',
'releasesPagePath', 'releasesPagePath',
'updateReleaseApiDocsPath',
]), ]),
showForm() { showForm() {
return !this.isFetchingRelease && !this.fetchError; return !this.isFetchingRelease && !this.fetchError;
...@@ -42,6 +44,20 @@ export default { ...@@ -42,6 +44,20 @@ export default {
tagName() { tagName() {
return this.$store.state.release.tagName; return this.$store.state.release.tagName;
}, },
tagNameHintText() {
return sprintf(
__(
'Changing a Release tag is only supported via Releases API. %{linkStart}More information%{linkEnd}',
),
{
linkStart: `<a href="${_.escape(
this.updateReleaseApiDocsPath,
)}" target="_blank" rel="noopener noreferrer">`,
linkEnd: '</a>',
},
false,
);
},
releaseTitle: { releaseTitle: {
get() { get() {
return this.$store.state.release.name; return this.$store.state.release.name;
...@@ -77,8 +93,9 @@ export default { ...@@ -77,8 +93,9 @@ export default {
<div class="d-flex flex-column"> <div class="d-flex flex-column">
<p class="pt-3 js-subtitle-text" v-html="subtitleText"></p> <p class="pt-3 js-subtitle-text" v-html="subtitleText"></p>
<form v-if="showForm" @submit.prevent="updateRelease()"> <form v-if="showForm" @submit.prevent="updateRelease()">
<gl-form-group>
<div class="row"> <div class="row">
<gl-form-group class="col-md-6 col-lg-5 col-xl-4"> <div class="col-md-6 col-lg-5 col-xl-4">
<label for="git-ref">{{ __('Tag name') }}</label> <label for="git-ref">{{ __('Tag name') }}</label>
<gl-form-input <gl-form-input
id="git-ref" id="git-ref"
...@@ -88,11 +105,10 @@ export default { ...@@ -88,11 +105,10 @@ export default {
aria-describedby="tag-name-help" aria-describedby="tag-name-help"
disabled disabled
/> />
<div id="tag-name-help" class="form-text text-muted">
{{ __('Choose an existing tag, or create a new one') }}
</div> </div>
</gl-form-group>
</div> </div>
<div id="tag-name-help" class="form-text text-muted" v-html="tagNameHintText"></div>
</gl-form-group>
<gl-form-group> <gl-form-group>
<label for="release-title">{{ __('Release title') }}</label> <label for="release-title">{{ __('Release title') }}</label>
<gl-form-input <gl-form-input
......
...@@ -4,6 +4,7 @@ export default () => ({ ...@@ -4,6 +4,7 @@ export default () => ({
releasesPagePath: null, releasesPagePath: null,
markdownDocsPath: null, markdownDocsPath: null,
markdownPreviewPath: null, markdownPreviewPath: null,
updateReleaseApiDocsPath: null,
release: null, release: null,
......
...@@ -26,7 +26,8 @@ module ReleasesHelper ...@@ -26,7 +26,8 @@ module ReleasesHelper
tag_name: @release.tag, tag_name: @release.tag,
markdown_preview_path: preview_markdown_path(@project), markdown_preview_path: preview_markdown_path(@project),
markdown_docs_path: help_page_path('user/markdown'), markdown_docs_path: help_page_path('user/markdown'),
releases_page_path: project_releases_path(@project, anchor: @release.tag) releases_page_path: project_releases_path(@project, anchor: @release.tag),
update_release_api_docs_path: help_page_path('api/releases/index.md', anchor: 'update-a-release')
} }
end end
end end
---
title: Update help text of "Tag name" field on Edit Release page
merge_request: 19321
author:
type: changed
...@@ -3016,6 +3016,9 @@ msgstr "" ...@@ -3016,6 +3016,9 @@ msgstr ""
msgid "Changes won't take place until the index is %{link_start}recreated%{link_end}." msgid "Changes won't take place until the index is %{link_start}recreated%{link_end}."
msgstr "" msgstr ""
msgid "Changing a Release tag is only supported via Releases API. %{linkStart}More information%{linkEnd}"
msgstr ""
msgid "Changing group path can have unintended side effects." msgid "Changing group path can have unintended side effects."
msgstr "" msgstr ""
...@@ -3142,9 +3145,6 @@ msgstr "" ...@@ -3142,9 +3145,6 @@ msgstr ""
msgid "Choose a type..." msgid "Choose a type..."
msgstr "" msgstr ""
msgid "Choose an existing tag, or create a new one"
msgstr ""
msgid "Choose any color." msgid "Choose any color."
msgstr "" msgstr ""
......
...@@ -8,15 +8,17 @@ describe('Release detail component', () => { ...@@ -8,15 +8,17 @@ describe('Release detail component', () => {
let wrapper; let wrapper;
let releaseClone; let releaseClone;
let actions; let actions;
let state;
beforeEach(() => { beforeEach(() => {
gon.api_version = 'v4'; gon.api_version = 'v4';
releaseClone = JSON.parse(JSON.stringify(convertObjectPropsToCamelCase(release))); releaseClone = JSON.parse(JSON.stringify(convertObjectPropsToCamelCase(release)));
const state = { state = {
release: releaseClone, release: releaseClone,
markdownDocsPath: 'path/to/markdown/docs', markdownDocsPath: 'path/to/markdown/docs',
updateReleaseApiDocsPath: 'path/to/update/release/api/docs',
}; };
actions = { actions = {
...@@ -46,6 +48,21 @@ describe('Release detail component', () => { ...@@ -46,6 +48,21 @@ describe('Release detail component', () => {
expect(wrapper.find('#git-ref').element.value).toBe(releaseClone.tagName); expect(wrapper.find('#git-ref').element.value).toBe(releaseClone.tagName);
}); });
it('renders the correct help text under the "Tag name" field', () => {
const helperText = wrapper.find('#tag-name-help');
const helperTextLink = helperText.find('a');
const helperTextLinkAttrs = helperTextLink.attributes();
expect(helperText.text()).toBe(
'Changing a Release tag is only supported via Releases API. More information',
);
expect(helperTextLink.text()).toBe('More information');
expect(helperTextLinkAttrs.href).toBe(state.updateReleaseApiDocsPath);
expect(helperTextLinkAttrs.rel).toContain('noopener');
expect(helperTextLinkAttrs.rel).toContain('noreferrer');
expect(helperTextLinkAttrs.target).toBe('_blank');
});
it('renders the correct release title in the "Release title" field', () => { it('renders the correct release title in the "Release title" field', () => {
expect(wrapper.find('#release-title').element.value).toBe(releaseClone.name); expect(wrapper.find('#release-title').element.value).toBe(releaseClone.name);
}); });
......
...@@ -17,9 +17,11 @@ describe ReleasesHelper do ...@@ -17,9 +17,11 @@ describe ReleasesHelper do
context 'url helpers' do context 'url helpers' do
let(:project) { build(:project, namespace: create(:group)) } let(:project) { build(:project, namespace: create(:group)) }
let(:release) { create(:release, project: project) }
before do before do
helper.instance_variable_set(:@project, project) helper.instance_variable_set(:@project, project)
helper.instance_variable_set(:@release, release)
end end
describe '#data_for_releases_page' do describe '#data_for_releases_page' do
...@@ -28,5 +30,17 @@ describe ReleasesHelper do ...@@ -28,5 +30,17 @@ describe ReleasesHelper do
expect(helper.data_for_releases_page.keys).to eq(keys) expect(helper.data_for_releases_page.keys).to eq(keys)
end end
end end
describe '#data_for_edit_release_page' do
it 'has the needed data to display the "edit release" page' do
keys = %i(project_id
tag_name
markdown_preview_path
markdown_docs_path
releases_page_path
update_release_api_docs_path)
expect(helper.data_for_edit_release_page.keys).to eq(keys)
end
end
end end
end end
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