diff options
author | Phil Hughes <me@iamphill.com> | 2018-05-03 11:41:05 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-05-03 11:41:05 +0100 |
commit | efed5aed411237ea94e9530e3033119d75f44886 (patch) | |
tree | 7ee97c1cca516a00e360872cfc5cb6337dfe9ec2 | |
parent | 58c270330ea987382913ec9b5b0de028ab93b0aa (diff) | |
download | gitlab-ce-efed5aed411237ea94e9530e3033119d75f44886.tar.gz |
removed unused computed prop
remove object.assign instead directly assign to state
created new constants
4 files changed, 26 insertions, 26 deletions
diff --git a/app/assets/javascripts/ide/components/commit_sidebar/actions.vue b/app/assets/javascripts/ide/components/commit_sidebar/actions.vue index 378c93b2e2e..4ecc8e0db51 100644 --- a/app/assets/javascripts/ide/components/commit_sidebar/actions.vue +++ b/app/assets/javascripts/ide/components/commit_sidebar/actions.vue @@ -10,7 +10,6 @@ export default { }, computed: { ...mapState(['currentBranchId', 'changedFiles', 'stagedFiles']), - ...mapGetters(['hasChanges']), commitToCurrentBranchText() { return sprintf( __('Commit to %{branchName} branch'), @@ -18,6 +17,9 @@ export default { false, ); }, + disableMergeRequestRadio() { + return this.changedFiles.length > 0 && this.stagedFiles.length > 0; + }, }, commitToCurrentBranch: consts.COMMIT_TO_CURRENT_BRANCH, commitToNewBranch: consts.COMMIT_TO_NEW_BRANCH, @@ -45,7 +47,7 @@ export default { :value="$options.commitToNewBranchMR" :label="__('Create a new branch and merge request')" :show-input="true" - :disabled="!!changedFiles.length && !!stagedFiles.length" + :disabled="disableMergeRequestRadio" /> </div> </template> diff --git a/app/assets/javascripts/ide/components/commit_sidebar/form.vue b/app/assets/javascripts/ide/components/commit_sidebar/form.vue index 71809ea0900..385cc6d51d5 100644 --- a/app/assets/javascripts/ide/components/commit_sidebar/form.vue +++ b/app/assets/javascripts/ide/components/commit_sidebar/form.vue @@ -4,7 +4,7 @@ import { sprintf, __ } from '~/locale'; import LoadingButton from '~/vue_shared/components/loading_button.vue'; import CommitMessageField from './message_field.vue'; import Actions from './actions.vue'; -import { activityBarViews } from '../../constants'; +import { activityBarViews, MAX_WINDOW_HEIGHT_COMPACT, COMMIT_ITEM_PADDING } from '../../constants'; export default { components: { @@ -38,7 +38,8 @@ export default { watch: { currentActivityView() { this.isCompact = !( - this.currentActivityView === activityBarViews.commit && window.innerHeight >= 750 + this.currentActivityView === activityBarViews.commit && + window.innerHeight >= MAX_WINDOW_HEIGHT_COMPACT ); }, }, @@ -59,7 +60,7 @@ export default { ? this.$refs.formEl && this.$refs.formEl.offsetHeight : this.$refs.compactEl && this.$refs.compactEl.offsetHeight; - this.componentHeight = elHeight + 32; + this.componentHeight = elHeight + COMMIT_ITEM_PADDING; }, enterTransition() { this.$nextTick(() => { @@ -67,7 +68,7 @@ export default { ? this.$refs.compactEl && this.$refs.compactEl.offsetHeight : this.$refs.formEl && this.$refs.formEl.offsetHeight; - this.componentHeight = elHeight + 32; + this.componentHeight = elHeight + COMMIT_ITEM_PADDING; }); }, afterEndTransition() { diff --git a/app/assets/javascripts/ide/constants.js b/app/assets/javascripts/ide/constants.js index 16110b2f5a4..dbaf370a18c 100644 --- a/app/assets/javascripts/ide/constants.js +++ b/app/assets/javascripts/ide/constants.js @@ -3,6 +3,10 @@ export const MAX_FILE_FINDER_RESULTS = 40; export const FILE_FINDER_ROW_HEIGHT = 55; export const FILE_FINDER_EMPTY_ROW_HEIGHT = 33; +export const MAX_WINDOW_HEIGHT_COMPACT = 750; + +export const COMMIT_ITEM_PADDING = 32; + // Commit message textarea export const MAX_TITLE_LENGTH = 50; export const MAX_BODY_LENGTH = 72; diff --git a/app/assets/javascripts/ide/stores/mutations/file.js b/app/assets/javascripts/ide/stores/mutations/file.js index 59650e0cea9..32fc3798a5f 100644 --- a/app/assets/javascripts/ide/stores/mutations/file.js +++ b/app/assets/javascripts/ide/stores/mutations/file.js @@ -1,3 +1,4 @@ +/* eslint-disable no-param-reassign */ import * as types from '../mutation_types'; export default { @@ -169,26 +170,18 @@ export default { }); }, [types.ADD_PENDING_TAB](state, { file, keyPrefix = 'pending' }) { - const key = `${keyPrefix}-${file.key}`; - - Object.assign(state, { - entries: Object.assign(state.entries, { - [file.path]: Object.assign(state.entries[file.path], { - opened: false, - active: false, - lastOpenedAt: new Date().getTime(), - }), - }), - openFiles: [ - { - ...file, - key, - pending: true, - opened: true, - active: true, - }, - ], - }); + state.entries[file.path].opened = false; + state.entries[file.path].active = false; + state.entries[file.path].lastOpenedAt = new Date().getTime(); + state.openFiles = [ + { + ...file, + key: `${keyPrefix}-${file.key}`, + pending: true, + opened: true, + active: true, + }, + ]; }, [types.REMOVE_PENDING_TAB](state, file) { Object.assign(state, { |