Commit ffd1fe29 authored by Phil Hughes's avatar Phil Hughes

styling updates

split out part of commit method
parent de53d17a
...@@ -23,12 +23,16 @@ ...@@ -23,12 +23,16 @@
</script> </script>
<template> <template>
<div class="append-bottom-15"> <div class="append-bottom-15 ide-commit-radios">
<radio-group <radio-group
:value="COMMIT_TO_CURRENT_BRANCH" :value="COMMIT_TO_CURRENT_BRANCH"
:label="`Commit to ${currentBranchId} branch`"
:checked="true" :checked="true"
/> >
<span
v-html="`Commit to <strong>${currentBranchId}</strong> branch`"
>
</span>
</radio-group>
<radio-group <radio-group
:value="COMMIT_TO_NEW_BRANCH" :value="COMMIT_TO_NEW_BRANCH"
label="Create a new branch" label="Create a new branch"
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
}, },
label: { label: {
type: String, type: String,
required: true, required: false,
default: null,
}, },
checked: { checked: {
type: Boolean, type: Boolean,
...@@ -49,10 +50,16 @@ ...@@ -49,10 +50,16 @@
:checked="checked" :checked="checked"
v-once v-once
/> />
{{ label }} <span class="prepend-left-10">
<template v-if="label">
{{ label }}
</template>
<slot v-else></slot>
</span>
</label> </label>
<template <div
v-if="commitAction === value && showInput" v-if="commitAction === value && showInput"
class="prepend-left-20"
> >
<input <input
type="text" type="text"
...@@ -60,6 +67,6 @@ ...@@ -60,6 +67,6 @@
:placeholder="newBranchName" :placeholder="newBranchName"
@input="updateBranchName($event.target.value)" @input="updateBranchName($event.target.value)"
/> />
</template> </div>
</fieldset> </fieldset>
</template> </template>
...@@ -90,7 +90,8 @@ export default { ...@@ -90,7 +90,8 @@ export default {
@submit="forceCreateNewBranch" @submit="forceCreateNewBranch"
> >
<template slot="body"> <template slot="body">
{{ __(`This branch has changed since you started editing. Would you like to create a new branch?`) }} {{ __(`This branch has changed since you started editing.
Would you like to create a new branch?`) }}
</template> </template>
</modal> </modal>
<commit-files-list <commit-files-list
......
...@@ -38,9 +38,48 @@ export const checkCommitStatus = ({ rootState }) => ...@@ -38,9 +38,48 @@ export const checkCommitStatus = ({ rootState }) =>
}) })
.catch(() => flash('Error checking branch data. Please try again.', 'alert', document, null, false, true)); .catch(() => flash('Error checking branch data. Please try again.', 'alert', document, null, false, true));
export const commitChanges = ({ export const updateFilesAfterCommit = (
commit, state, getters, dispatch, rootState, rootGetters, { commit, dispatch, state, rootState, rootGetters },
}) => { { data, branch },
) => {
const selectedProject = rootState.projects[rootState.currentProjectId];
const lastCommit = {
commit_path: `${selectedProject.web_url}/commit/${data.id}`,
commit: {
id: data.id,
message: data.message,
authored_date: data.committed_date,
author_name: data.committer_name,
},
};
commit(rootTypes.SET_BRANCH_WORKING_REFERENCE, {
projectId: rootState.currentProjectId,
branchId: rootState.currentBranchId,
reference: data.id,
}, { root: true });
rootState.changedFiles.forEach((entry) => {
commit(rootTypes.SET_LAST_COMMIT_DATA, {
entry,
lastCommit,
}, { root: true });
});
commit(rootTypes.REMOVE_ALL_CHANGES_FILES, null, { root: true });
if (state.commitAction === consts.COMMIT_TO_NEW_BRANCH) {
const fileUrl = rootGetters.activeFile.url.replace(rootState.currentBranchId, branch);
router.push(`/project${fileUrl}`);
}
window.scrollTo(0, 0);
dispatch('updateCommitAction', consts.COMMIT_TO_CURRENT_BRANCH);
};
export const commitChanges = ({ commit, state, getters, dispatch, rootState }) => {
const newBranch = state.commitAction !== consts.COMMIT_TO_CURRENT_BRANCH; const newBranch = state.commitAction !== consts.COMMIT_TO_CURRENT_BRANCH;
const payload = { const payload = {
branch: getters.branchName, branch: getters.branchName,
...@@ -76,15 +115,6 @@ export const commitChanges = ({ ...@@ -76,15 +115,6 @@ export const commitChanges = ({
return; return;
} }
const selectedProject = rootState.projects[rootState.currentProjectId];
const lastCommit = {
commit_path: `${selectedProject.web_url}/commit/${data.id}`,
commit: {
message: data.message,
authored_date: data.committed_date,
},
};
let commitMsg = `Your changes have been committed. Commit ${data.short_id}`; let commitMsg = `Your changes have been committed. Commit ${data.short_id}`;
if (data.stats) { if (data.stats) {
...@@ -94,37 +124,15 @@ export const commitChanges = ({ ...@@ -94,37 +124,15 @@ export const commitChanges = ({
commit(rootTypes.SET_LAST_COMMIT_MSG, commitMsg, { root: true }); commit(rootTypes.SET_LAST_COMMIT_MSG, commitMsg, { root: true });
if (state.commitAction === consts.COMMIT_TO_NEW_BRANCH_MR) { if (state.commitAction === consts.COMMIT_TO_NEW_BRANCH_MR) {
dispatch('discardAllChanges', null, { root: true }); const selectedProject = rootState.projects[rootState.currentProjectId];
dispatch( dispatch(
'redirectToUrl', 'redirectToUrl',
`${selectedProject.web_url}/merge_requests/new?merge_request[source_branch]=${branch}&merge_request[target_branch]=${rootState.currentBranchId}`, `${selectedProject.web_url}/merge_requests/new?merge_request[source_branch]=${branch}&merge_request[target_branch]=${rootState.currentBranchId}`,
{ root: true }, { root: true },
); );
} else { } else {
commit(rootTypes.SET_BRANCH_WORKING_REFERENCE, { dispatch('updateFilesAfterCommit', { data, branch });
projectId: rootState.currentProjectId,
branchId: rootState.currentBranchId,
reference: data.id,
}, { root: true });
rootState.changedFiles.forEach((entry) => {
commit(rootTypes.SET_LAST_COMMIT_DATA, {
entry,
lastCommit,
}, { root: true });
});
commit(rootTypes.REMOVE_ALL_CHANGES_FILES, null, { root: true });
if (state.commitAction === consts.COMMIT_TO_NEW_BRANCH) {
const fileUrl = rootGetters.activeFile.url.replace(rootState.currentBranchId, branch);
router.push(`/project${fileUrl}`);
}
dispatch('updateCommitAction', consts.COMMIT_TO_CURRENT_BRANCH);
window.scrollTo(0, 0);
} }
}) })
.catch((err) => { .catch((err) => {
......
...@@ -630,3 +630,9 @@ table.table tr td.multi-file-table-name { ...@@ -630,3 +630,9 @@ table.table tr td.multi-file-table-name {
left: 0; left: 0;
} }
} }
.ide-commit-radios {
label {
font-weight: normal;
}
}
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