Commit bcb5725d authored by Phil Hughes's avatar Phil Hughes

updates to component

parent 5f5995dd
<script> <script>
import { mapState } from 'vuex'; import { mapState } from 'vuex';
import { sprintf, __ } from '~/locale'; import { sprintf, __ } from '~/locale';
import * as consts from '../../stores/modules/commit/constants'; import * as consts from '../../stores/modules/commit/constants';
import RadioGroup from './radio_group.vue'; import RadioGroup from './radio_group.vue';
export default { export default {
components: { components: {
RadioGroup, RadioGroup,
}, },
computed: { computed: {
...mapState([ ...mapState(['currentBranchId']),
'currentBranchId',
]),
newMergeRequestHelpText() {
return sprintf(
__('Creates a new branch from %{branchName} and re-directs to create a new merge request'),
{ branchName: this.currentBranchId },
);
},
commitToCurrentBranchText() { commitToCurrentBranchText() {
return sprintf( return sprintf(
__('Commit to %{branchName} branch'), __('Commit to %{branchName} branch'),
...@@ -25,17 +17,11 @@ ...@@ -25,17 +17,11 @@
false, false,
); );
}, },
commitToNewBranchText() {
return sprintf(
__('Creates a new branch from %{branchName}'),
{ branchName: this.currentBranchId },
);
},
}, },
commitToCurrentBranch: consts.COMMIT_TO_CURRENT_BRANCH, commitToCurrentBranch: consts.COMMIT_TO_CURRENT_BRANCH,
commitToNewBranch: consts.COMMIT_TO_NEW_BRANCH, commitToNewBranch: consts.COMMIT_TO_NEW_BRANCH,
commitToNewBranchMR: consts.COMMIT_TO_NEW_BRANCH_MR, commitToNewBranchMR: consts.COMMIT_TO_NEW_BRANCH_MR,
}; };
</script> </script>
<template> <template>
...@@ -53,13 +39,11 @@ ...@@ -53,13 +39,11 @@
:value="$options.commitToNewBranch" :value="$options.commitToNewBranch"
:label="__('Create a new branch')" :label="__('Create a new branch')"
:show-input="true" :show-input="true"
:help-text="commitToNewBranchText"
/> />
<radio-group <radio-group
:value="$options.commitToNewBranchMR" :value="$options.commitToNewBranchMR"
:label="__('Create a new branch and merge request')" :label="__('Create a new branch and merge request')"
:show-input="true" :show-input="true"
:help-text="newMergeRequestHelpText"
/> />
</div> </div>
</template> </template>
<script> <script>
import { __ } from '../../../locale'; import { __, sprintf } from '../../../locale';
import Icon from '../../../vue_shared/components/icon.vue';
import popover from '../../../vue_shared/directives/popover'; import popover from '../../../vue_shared/directives/popover';
import { MAX_TITLE_LENGTH, MAX_BODY_LENGTH } from '../../constants';
export const MAX_TITLE_LENGTH = 50;
export const MAX_BODY_LENGTH = 72;
export default { export default {
directives: { directives: {
popover, popover,
}, },
components: {
Icon,
},
props: { props: {
text: { text: {
type: String, type: String,
...@@ -45,13 +47,15 @@ export default { ...@@ -45,13 +47,15 @@ export default {
}, },
}, },
popoverOptions: { popoverOptions: {
html: true,
trigger: 'hover', trigger: 'hover',
placement: 'top', placement: 'top',
content: __(` content: sprintf(
The character highligher helps you keep the subject line to 50 characters __(`
and wrap the body at 72 so they are readable in git. The character highligher helps you keep the subject line to %{titleLength} characters
and wrap the body at %{bodyLength} so they are readable in git.
`), `),
{ titleLength: MAX_TITLE_LENGTH, bodyLength: MAX_BODY_LENGTH },
),
}, },
}; };
</script> </script>
...@@ -75,10 +79,9 @@ export default { ...@@ -75,10 +79,9 @@ export default {
v-popover="$options.popoverOptions" v-popover="$options.popoverOptions"
class="help-block prepend-left-10" class="help-block prepend-left-10"
> >
<i <icon
aria-hidden="true" name="question"
class="fa fa-question-circle" />
></i>
</span> </span>
</li> </li>
</ul> </ul>
...@@ -99,7 +102,7 @@ export default { ...@@ -99,7 +102,7 @@ export default {
v-text="line.substr(0, getLineLength(index)) || ' '" v-text="line.substr(0, getLineLength(index)) || ' '"
> >
</span><mark </span><mark
v-if="line.length > getLineLength(index)" v-show="line.length > getLineLength(index)"
v-text="line.substr(getLineLength(index))" v-text="line.substr(getLineLength(index))"
> >
</mark> </mark>
......
<script> <script>
import { mapActions, mapState, mapGetters } from 'vuex'; import { mapActions, mapState, mapGetters } from 'vuex';
import tooltip from '~/vue_shared/directives/tooltip'; import tooltip from '~/vue_shared/directives/tooltip';
export default { export default {
directives: { directives: {
tooltip, tooltip,
}, },
...@@ -26,27 +26,15 @@ ...@@ -26,27 +26,15 @@
required: false, required: false,
default: false, default: false,
}, },
helpText: {
type: String,
required: false,
default: null,
},
}, },
computed: { computed: {
...mapState('commit', [ ...mapState('commit', ['commitAction']),
'commitAction', ...mapGetters('commit', ['newBranchName']),
]),
...mapGetters('commit', [
'newBranchName',
]),
}, },
methods: { methods: {
...mapActions('commit', [ ...mapActions('commit', ['updateCommitAction', 'updateBranchName']),
'updateCommitAction',
'updateBranchName',
]),
}, },
}; };
</script> </script>
<template> <template>
...@@ -65,18 +53,6 @@ ...@@ -65,18 +53,6 @@
{{ label }} {{ label }}
</template> </template>
<slot v-else></slot> <slot v-else></slot>
<span
v-if="helpText"
v-tooltip
class="help-block inline"
:title="helpText"
>
<i
class="fa fa-question-circle"
aria-hidden="true"
>
</i>
</span>
</span> </span>
</label> </label>
<div <div
......
// Fuzzy file finder
export const MAX_TITLE_LENGTH = 50;
export const MAX_BODY_LENGTH = 72;
...@@ -850,7 +850,7 @@ ...@@ -850,7 +850,7 @@
} }
.help-block { .help-block {
margin-top: 0; margin-top: 2px;
color: $blue-500; color: $blue-500;
cursor: pointer; cursor: pointer;
} }
......
...@@ -75,7 +75,7 @@ describe('IDE commit message field', () => { ...@@ -75,7 +75,7 @@ describe('IDE commit message field', () => {
expect(vm.$el.querySelector('.highlights span').textContent).toContain( expect(vm.$el.querySelector('.highlights span').textContent).toContain(
'text less than 50 chars', 'text less than 50 chars',
); );
expect(vm.$el.querySelector('mark')).toBeNull(); expect(vm.$el.querySelector('mark').style.display).toBe('none');
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
...@@ -91,7 +91,7 @@ describe('IDE commit message field', () => { ...@@ -91,7 +91,7 @@ describe('IDE commit message field', () => {
expect(vm.$el.querySelector('.highlights span').textContent).toContain( expect(vm.$el.querySelector('.highlights span').textContent).toContain(
'text less than 50 chars that should not highlighte', 'text less than 50 chars that should not highlighte',
); );
expect(vm.$el.querySelector('mark')).not.toBeNull(); expect(vm.$el.querySelector('mark').style.display).not.toBe('none');
expect(vm.$el.querySelector('mark').textContent).toBe( expect(vm.$el.querySelector('mark').textContent).toBe(
'd. text more than 50 should be highlighted', 'd. text more than 50 should be highlighted',
); );
...@@ -109,7 +109,7 @@ describe('IDE commit message field', () => { ...@@ -109,7 +109,7 @@ describe('IDE commit message field', () => {
.$nextTick() .$nextTick()
.then(() => { .then(() => {
expect(vm.$el.querySelectorAll('.highlights span').length).toBe(2); expect(vm.$el.querySelectorAll('.highlights span').length).toBe(2);
expect(vm.$el.querySelector('mark')).toBeNull(); expect(vm.$el.querySelectorAll('mark')[1].style.display).toBe('none');
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
...@@ -123,8 +123,8 @@ describe('IDE commit message field', () => { ...@@ -123,8 +123,8 @@ describe('IDE commit message field', () => {
.$nextTick() .$nextTick()
.then(() => { .then(() => {
expect(vm.$el.querySelectorAll('.highlights span').length).toBe(2); expect(vm.$el.querySelectorAll('.highlights span').length).toBe(2);
expect(vm.$el.querySelector('mark')).not.toBeNull(); expect(vm.$el.querySelectorAll('mark')[1].style.display).not.toBe('none');
expect(vm.$el.querySelector('mark').textContent).toBe(' in length'); expect(vm.$el.querySelectorAll('mark')[1].textContent).toBe(' in length');
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
......
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