Commit 373b8c26 authored by Phil Hughes's avatar Phil Hughes

added help block

fixed commit section spec
parent c3bee6f4
...@@ -37,11 +37,13 @@ ...@@ -37,11 +37,13 @@
:value="COMMIT_TO_NEW_BRANCH" :value="COMMIT_TO_NEW_BRANCH"
label="Create a new branch" label="Create a new branch"
:show-input="true" :show-input="true"
:help-text="`Creates a new branch from ${currentBranchId}`"
/> />
<radio-group <radio-group
:value="COMMIT_TO_NEW_BRANCH_MR" :value="COMMIT_TO_NEW_BRANCH_MR"
label="Create a new branch and merge request" label="Create a new branch and merge request"
:show-input="true" :show-input="true"
:help-text="`Creates a new branch from ${currentBranchId} and re-directs to create a new merge request`"
/> />
</div> </div>
</template> </template>
<script> <script>
import { mapActions, mapState, mapGetters } from 'vuex'; import { mapActions, mapState, mapGetters } from 'vuex';
import tooltip from '../../../vue_shared/directives/tooltip';
export default { export default {
directives: {
tooltip,
},
props: { props: {
value: { value: {
type: String, type: String,
...@@ -22,6 +26,11 @@ ...@@ -22,6 +26,11 @@
required: false, required: false,
default: false, default: false,
}, },
helpText: {
type: String,
required: false,
default: null,
}
}, },
computed: { computed: {
...mapState('commit', [ ...mapState('commit', [
...@@ -55,11 +64,19 @@ ...@@ -55,11 +64,19 @@
{{ 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"></i>
</span>
</span> </span>
</label> </label>
<div <div
v-if="commitAction === value && showInput" v-if="commitAction === value && showInput"
class="prepend-left-20" class="ide-commit-new-branch"
> >
<input <input
type="text" type="text"
......
...@@ -110,7 +110,7 @@ export default { ...@@ -110,7 +110,7 @@ export default {
> >
<div class="multi-file-commit-fieldset"> <div class="multi-file-commit-fieldset">
<textarea <textarea
class="form-control multi-file-commit-message" class="form-control input-sm multi-file-commit-message"
name="commit-message" name="commit-message"
:value="commitMessage" :value="commitMessage"
placeholder="Write a commit message..." placeholder="Write a commit message..."
......
...@@ -635,4 +635,13 @@ table.table tr td.multi-file-table-name { ...@@ -635,4 +635,13 @@ table.table tr td.multi-file-table-name {
label { label {
font-weight: normal; font-weight: normal;
} }
.help-block {
margin-top: 0;
line-height: 0;
}
}
.ide-commit-new-branch {
margin-left: 25px;
} }
...@@ -116,7 +116,7 @@ describe('RepoCommitSection', () => { ...@@ -116,7 +116,7 @@ describe('RepoCommitSection', () => {
}); });
it('resets commitMessage when clicking discard button', (done) => { it('resets commitMessage when clicking discard button', (done) => {
vm.$store.state.commitMessage = 'testinig commit message'; vm.$store.state.commit.commitMessage = 'testing commit message';
getSetTimeoutPromise() getSetTimeoutPromise()
.then(() => { .then(() => {
...@@ -133,14 +133,17 @@ describe('RepoCommitSection', () => { ...@@ -133,14 +133,17 @@ describe('RepoCommitSection', () => {
describe('when submitting', () => { describe('when submitting', () => {
beforeEach(() => { beforeEach(() => {
vm.$store.state.commitMessage = 'testing'; spyOn(vm, 'commitChanges');
}); });
it('calls store', (done) => { it('calls commitChanges', (done) => {
spyOn(vm, 'commitChanges'); vm.$store.state.commit.commitMessage = 'testing commit message';
vm.$el.querySelector('.multi-file-commit-form .btn-success').click();
Vue.nextTick() getSetTimeoutPromise()
.then(() => {
vm.$el.querySelector('.multi-file-commit-form .btn-success').click();
})
.then(Vue.nextTick)
.then(() => { .then(() => {
expect(vm.commitChanges).toHaveBeenCalled(); expect(vm.commitChanges).toHaveBeenCalled();
}) })
......
...@@ -3,10 +3,11 @@ import state from '~/ide/stores/state'; ...@@ -3,10 +3,11 @@ import state from '~/ide/stores/state';
import commitState from '~/ide/stores/modules/commit/state'; import commitState from '~/ide/stores/modules/commit/state';
export const resetStore = (store) => { export const resetStore = (store) => {
store.replaceState(state()); const newState = {
Object.assign(store.state, { ...state(),
commit: commitState(), commit: commitState(),
}); };
store.replaceState(newState);
}; };
export const file = (name = 'name', id = name, type = '') => decorateData({ export const file = (name = 'name', id = name, type = '') => decorateData({
......
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