Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e5d42a0f
Commit
e5d42a0f
authored
Jun 14, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve branch 404 error in Web IDE
Part of #47323
parent
2452f1a7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
20 deletions
+75
-20
app/assets/javascripts/api.js
app/assets/javascripts/api.js
+9
-0
app/assets/javascripts/ide/ide_router.js
app/assets/javascripts/ide/ide_router.js
+0
-8
app/assets/javascripts/ide/stores/actions/project.js
app/assets/javascripts/ide/stores/actions/project.js
+54
-11
app/assets/javascripts/ide/stores/actions/tree.js
app/assets/javascripts/ide/stores/actions/tree.js
+12
-1
No files found.
app/assets/javascripts/api.js
View file @
e5d42a0f
...
...
@@ -243,6 +243,15 @@ const Api = {
});
},
createBranch
(
id
,
{
ref
,
branch
})
{
const
url
=
Api
.
buildUrl
(
this
.
createBranchPath
).
replace
(
'
:id
'
,
encodeURIComponent
(
id
));
return
axios
.
post
(
url
,
{
ref
,
branch
,
});
},
buildUrl
(
url
)
{
let
urlRoot
=
''
;
if
(
gon
.
relative_url_root
!=
null
)
{
...
...
app/assets/javascripts/ide/ide_router.js
View file @
e5d42a0f
...
...
@@ -95,14 +95,6 @@ router.beforeEach((to, from, next) => {
}
})
.
catch
(
e
=>
{
flash
(
'
Error while loading the branch files. Please try again.
'
,
'
alert
'
,
document
,
null
,
false
,
true
,
);
throw
e
;
});
}
else
if
(
to
.
params
.
mrid
)
{
...
...
app/assets/javascripts/ide/stores/actions/project.js
View file @
e5d42a0f
import
flash
from
'
~/flash
'
;
import
{
__
}
from
'
~/locale
'
;
import
{
__
,
sprintf
}
from
'
~/locale
'
;
import
service
from
'
../../services
'
;
import
api
from
'
../../../api
'
;
import
*
as
types
from
'
../mutation_types
'
;
export
const
getProjectData
=
({
commit
,
state
},
{
namespace
,
projectId
,
force
=
false
}
=
{})
=>
...
...
@@ -32,7 +33,10 @@ export const getProjectData = ({ commit, state }, { namespace, projectId, force
}
});
export
const
getBranchData
=
({
commit
,
state
},
{
projectId
,
branchId
,
force
=
false
}
=
{})
=>
export
const
getBranchData
=
(
{
commit
,
dispatch
,
state
},
{
projectId
,
branchId
,
force
=
false
}
=
{},
)
=>
new
Promise
((
resolve
,
reject
)
=>
{
if
(
typeof
state
.
projects
[
`
${
projectId
}
`
]
===
'
undefined
'
||
...
...
@@ -51,15 +55,21 @@ export const getBranchData = ({ commit, state }, { projectId, branchId, force =
commit
(
types
.
SET_BRANCH_WORKING_REFERENCE
,
{
projectId
,
branchId
,
reference
:
id
});
resolve
(
data
);
})
.
catch
(()
=>
{
flash
(
__
(
'
Error loading branch data. Please try again.
'
),
'
alert
'
,
document
,
null
,
false
,
true
,
);
.
catch
(
e
=>
{
let
flashMessage
=
__
(
'
Error loading branch data. Please try again.
'
);
if
(
e
.
response
.
status
===
404
)
{
dispatch
(
'
showBranchNotFoundError
'
,
branchId
);
}
else
{
flash
(
__
(
'
Error loading branch data. Please try again.
'
),
'
alert
'
,
document
,
null
,
false
,
true
,
);
}
reject
(
new
Error
(
`Branch not loaded -
${
projectId
}
/
${
branchId
}
`
));
});
}
else
{
...
...
@@ -80,3 +90,36 @@ export const refreshLastCommitData = ({ commit }, { projectId, branchId } = {})
.
catch
(()
=>
{
flash
(
__
(
'
Error loading last commit.
'
),
'
alert
'
,
document
,
null
,
false
,
true
);
});
export
const
createNewBranchFromDefault
=
({
state
,
getters
},
branch
)
=>
{
api
.
createBranch
(
state
.
currentProjectId
,
{
ref
:
getters
.
currentProject
.
default_branch
,
branch
,
})
.
then
(()
=>
{
location
.
reload
();
})
.
catch
(()
=>
{});
};
export
const
showBranchNotFoundError
=
({
dispatch
},
branchId
)
=>
{
flash
(
sprintf
(
__
(
'
Branch %{branchName} was not found in project.
'
),
{
branchName
:
branchId
,
}),
'
alert
'
,
document
,
{
href
:
'
#
'
,
title
:
'
Create branch
'
,
clickHandler
(
e
)
{
e
.
stopPropagation
();
e
.
preventDefault
();
dispatch
(
'
createNewBranchFromDefault
'
,
branchId
);
},
},
false
,
true
,
);
};
app/assets/javascripts/ide/stores/actions/tree.js
View file @
e5d42a0f
...
...
@@ -99,7 +99,18 @@ export const getFiles = ({ state, commit }, { projectId, branchId } = {}) =>
});
})
.
catch
(
e
=>
{
flash
(
'
Error loading tree data. Please try again.
'
,
'
alert
'
,
document
,
null
,
false
,
true
);
if
(
e
.
response
.
status
===
404
)
{
dispatch
(
'
showBranchNotFoundError
'
,
branchId
);
}
else
{
flash
(
'
Error loading tree data. Please try again.
'
,
'
alert
'
,
document
,
null
,
false
,
true
,
);
}
reject
(
e
);
});
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment