summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/stores/actions/project.js
diff options
context:
space:
mode:
authorPaul Slaughter <pslaughter@gitlab.com>2018-08-13 08:12:21 +0000
committerPhil Hughes <me@iamphill.com>2018-08-13 08:12:21 +0000
commit0a3d18b0e2249863ec3700590bb6e974ab168f20 (patch)
treecea6f2b6cbef2f1e581051a7ef5ae53b08161080 /app/assets/javascripts/ide/stores/actions/project.js
parent00c474ae4efd296138598d9fb6609322beb43da9 (diff)
downloadgitlab-ce-0a3d18b0e2249863ec3700590bb6e974ab168f20.tar.gz
Backstage/ide router refactoring
Diffstat (limited to 'app/assets/javascripts/ide/stores/actions/project.js')
-rw-r--r--app/assets/javascripts/ide/stores/actions/project.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/app/assets/javascripts/ide/stores/actions/project.js b/app/assets/javascripts/ide/stores/actions/project.js
index 501e25d452b..543dc6c0461 100644
--- a/app/assets/javascripts/ide/stores/actions/project.js
+++ b/app/assets/javascripts/ide/stores/actions/project.js
@@ -124,3 +124,35 @@ export const showBranchNotFoundError = ({ dispatch }, branchId) => {
actionPayload: branchId,
});
};
+
+export const openBranch = (
+ { dispatch, state },
+ { projectId, branchId, basePath },
+) => {
+ dispatch('setCurrentBranchId', branchId);
+
+ dispatch('getBranchData', {
+ projectId,
+ branchId,
+ });
+
+ return (
+ dispatch('getFiles', {
+ projectId,
+ branchId,
+ })
+ .then(() => {
+ if (basePath) {
+ const path = basePath.slice(-1) === '/' ? basePath.slice(0, -1) : basePath;
+ const treeEntryKey = Object.keys(state.entries).find(
+ key => key === path && !state.entries[key].pending,
+ );
+ const treeEntry = state.entries[treeEntryKey];
+
+ if (treeEntry) {
+ dispatch('handleTreeEntryAction', treeEntry);
+ }
+ }
+ })
+ );
+};