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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
6a89ce29
Commit
6a89ce29
authored
Jan 26, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converted create_merge_request_dropdown to axios
parent
797f29d1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
80 deletions
+67
-80
app/assets/javascripts/create_merge_request_dropdown.js
app/assets/javascripts/create_merge_request_dropdown.js
+67
-80
No files found.
app/assets/javascripts/create_merge_request_dropdown.js
View file @
6a89ce29
/* eslint-disable no-new */
/* eslint-disable no-new */
import
_
from
'
underscore
'
;
import
_
from
'
underscore
'
;
import
axios
from
'
./lib/utils/axios_utils
'
;
import
Flash
from
'
./flash
'
;
import
Flash
from
'
./flash
'
;
import
DropLab
from
'
./droplab/drop_lab
'
;
import
DropLab
from
'
./droplab/drop_lab
'
;
import
ISetter
from
'
./droplab/plugins/input_setter
'
;
import
ISetter
from
'
./droplab/plugins/input_setter
'
;
...
@@ -74,13 +75,10 @@ export default class CreateMergeRequestDropdown {
...
@@ -74,13 +75,10 @@ export default class CreateMergeRequestDropdown {
}
}
checkAbilityToCreateBranch
()
{
checkAbilityToCreateBranch
()
{
return
$
.
ajax
({
this
.
setUnavailableButtonState
();
type
:
'
GET
'
,
dataType
:
'
json
'
,
axios
.
get
(
this
.
canCreatePath
)
url
:
this
.
canCreatePath
,
.
then
(({
data
})
=>
{
beforeSend
:
()
=>
this
.
setUnavailableButtonState
(),
})
.
done
((
data
)
=>
{
this
.
setUnavailableButtonState
(
false
);
this
.
setUnavailableButtonState
(
false
);
if
(
data
.
can_create_branch
)
{
if
(
data
.
can_create_branch
)
{
...
@@ -95,39 +93,34 @@ export default class CreateMergeRequestDropdown {
...
@@ -95,39 +93,34 @@ export default class CreateMergeRequestDropdown {
}
else
if
(
data
.
has_related_branch
)
{
}
else
if
(
data
.
has_related_branch
)
{
this
.
hide
();
this
.
hide
();
}
}
}).
fail
(()
=>
{
})
.
catch
(()
=>
{
this
.
unavailable
();
this
.
unavailable
();
this
.
disable
();
this
.
disable
();
new
Flash
(
'
Failed to check if a new branch can be created.
'
);
Flash
(
'
Failed to check if a new branch can be created.
'
);
});
});
}
}
createBranch
()
{
createBranch
()
{
return
$
.
ajax
({
this
.
isCreatingBranch
=
true
;
method
:
'
POST
'
,
dataType
:
'
json
'
,
return
axios
.
post
(
this
.
createBranchPath
)
url
:
this
.
createBranchPath
,
.
then
(({
data
})
=>
{
beforeSend
:
()
=>
(
this
.
isCreatingBranch
=
true
),
})
.
done
((
data
)
=>
{
this
.
branchCreated
=
true
;
this
.
branchCreated
=
true
;
window
.
location
.
href
=
data
.
url
;
window
.
location
.
href
=
data
.
url
;
})
})
.
fail
(()
=>
new
Flash
(
'
Failed to create a branch for this issue. Please try again.
'
));
.
catch
(()
=>
Flash
(
'
Failed to create a branch for this issue. Please try again.
'
));
}
}
createMergeRequest
()
{
createMergeRequest
()
{
return
$
.
ajax
({
this
.
isCreatingMergeRequest
=
true
;
method
:
'
POST
'
,
dataType
:
'
json
'
,
return
axios
.
post
(
this
.
createMrPath
)
url
:
this
.
createMrPath
,
.
then
(({
data
})
=>
{
beforeSend
:
()
=>
(
this
.
isCreatingMergeRequest
=
true
),
})
.
done
((
data
)
=>
{
this
.
mergeRequestCreated
=
true
;
this
.
mergeRequestCreated
=
true
;
window
.
location
.
href
=
data
.
url
;
window
.
location
.
href
=
data
.
url
;
})
})
.
fail
(()
=>
new
Flash
(
'
Failed to create Merge Request. Please try again.
'
));
.
catch
(()
=>
Flash
(
'
Failed to create Merge Request. Please try again.
'
));
}
}
disable
()
{
disable
()
{
...
@@ -200,18 +193,8 @@ export default class CreateMergeRequestDropdown {
...
@@ -200,18 +193,8 @@ export default class CreateMergeRequestDropdown {
getRef
(
ref
,
target
=
'
all
'
)
{
getRef
(
ref
,
target
=
'
all
'
)
{
if
(
!
ref
)
return
false
;
if
(
!
ref
)
return
false
;
return
$
.
ajax
({
return
axios
.
get
(
this
.
refsPath
+
ref
)
method
:
'
GET
'
,
.
then
(({
data
})
=>
{
dataType
:
'
json
'
,
url
:
this
.
refsPath
+
ref
,
beforeSend
:
()
=>
{
this
.
isGettingRef
=
true
;
},
})
.
always
(()
=>
{
this
.
isGettingRef
=
false
;
})
.
done
((
data
)
=>
{
const
branches
=
data
[
Object
.
keys
(
data
)[
0
]];
const
branches
=
data
[
Object
.
keys
(
data
)[
0
]];
const
tags
=
data
[
Object
.
keys
(
data
)[
1
]];
const
tags
=
data
[
Object
.
keys
(
data
)[
1
]];
let
result
;
let
result
;
...
@@ -224,13 +207,17 @@ export default class CreateMergeRequestDropdown {
...
@@ -224,13 +207,17 @@ export default class CreateMergeRequestDropdown {
this
.
suggestedRef
=
result
;
this
.
suggestedRef
=
result
;
}
}
this
.
isGettingRef
=
false
;
return
this
.
updateInputState
(
target
,
ref
,
result
);
return
this
.
updateInputState
(
target
,
ref
,
result
);
})
})
.
fail
(()
=>
{
.
catch
(()
=>
{
this
.
unavailable
();
this
.
unavailable
();
this
.
disable
();
this
.
disable
();
new
Flash
(
'
Failed to get ref.
'
);
new
Flash
(
'
Failed to get ref.
'
);
this
.
isGettingRef
=
false
;
return
false
;
return
false
;
});
});
}
}
...
@@ -332,12 +319,12 @@ export default class CreateMergeRequestDropdown {
...
@@ -332,12 +319,12 @@ export default class CreateMergeRequestDropdown {
xhr
=
this
.
createBranch
();
xhr
=
this
.
createBranch
();
}
}
xhr
.
fail
(()
=>
{
xhr
.
catch
(()
=>
{
this
.
isCreatingMergeRequest
=
false
;
this
.
isCreatingMergeRequest
=
false
;
this
.
isCreatingBranch
=
false
;
this
.
isCreatingBranch
=
false
;
});
xhr
.
always
(()
=>
this
.
enable
());
this
.
enable
();
});
this
.
disable
();
this
.
disable
();
}
}
...
...
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