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
Boxiang Sun
gitlab-ce
Commits
e33c4458
Commit
e33c4458
authored
May 09, 2018
by
Dennis Tang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor gke store actions
parent
b66aa624
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
65 deletions
+41
-65
app/assets/javascripts/projects/gke_cluster_dropdowns/stores/actions.js
...ascripts/projects/gke_cluster_dropdowns/stores/actions.js
+41
-65
No files found.
app/assets/javascripts/projects/gke_cluster_dropdowns/stores/actions.js
View file @
e33c4458
...
@@ -16,92 +16,68 @@ export const setMachineType = ({ commit }, selectedMachineType) => {
...
@@ -16,92 +16,68 @@ export const setMachineType = ({ commit }, selectedMachineType) => {
commit
(
types
.
SET_MACHINE_TYPE
,
selectedMachineType
);
commit
(
types
.
SET_MACHINE_TYPE
,
selectedMachineType
);
};
};
export
const
getProjects
=
({
commit
})
=>
const
displayError
=
(
resp
,
errorMessage
)
=>
{
if
(
resp
.
result
&&
resp
.
result
.
error
)
{
Flash
(
sprintf
(
s__
(
errorMessage
),
{
error
:
resp
.
result
.
error
.
message
}));
}
};
const
gapiRequest
=
({
service
,
params
,
commit
,
mutation
,
payloadKey
,
errorMessage
})
=>
new
Promise
((
resolve
,
reject
)
=>
{
new
Promise
((
resolve
,
reject
)
=>
{
const
request
=
gapi
.
client
.
cloudresourcemanager
.
projects
.
list
(
);
const
request
=
service
.
list
(
params
);
return
request
.
then
(
return
request
.
then
(
resp
=>
{
resp
=>
{
commit
(
types
.
SET_PROJECTS
,
resp
.
result
.
projects
);
const
{
result
}
=
resp
;
commit
(
mutation
,
result
[
payloadKey
]);
resolve
();
resolve
();
},
},
resp
=>
{
resp
=>
{
if
(
resp
.
result
.
error
)
{
displayError
(
resp
,
errorMessage
);
Flash
(
sprintf
(
s__
(
'
ClusterIntegration|An error occured while trying to fetch your projects: %{error}
'
,
),
{
error
:
resp
.
result
.
error
.
message
,
},
),
);
}
reject
();
reject
();
},
},
);
);
});
});
export
const
getProjects
=
({
commit
})
=>
gapiRequest
({
service
:
gapi
.
client
.
cloudresourcemanager
.
projects
,
params
:
{},
commit
,
mutation
:
types
.
SET_PROJECTS
,
payloadKey
:
'
projects
'
,
errorMessage
:
'
ClusterIntegration|An error occured while trying to fetch your projects: %{error}
'
,
});
export
const
getZones
=
({
commit
,
state
})
=>
export
const
getZones
=
({
commit
,
state
})
=>
new
Promise
((
resolve
,
reject
)
=>
{
gapiRequest
({
const
request
=
gapi
.
client
.
compute
.
zones
.
list
({
service
:
gapi
.
client
.
compute
.
zones
,
params
:
{
project
:
state
.
selectedProject
.
projectId
,
project
:
state
.
selectedProject
.
projectId
,
});
},
commit
,
return
request
.
then
(
mutation
:
types
.
SET_ZONES
,
resp
=>
{
payloadKey
:
'
items
'
,
commit
(
types
.
SET_ZONES
,
resp
.
result
.
items
);
errorMessage
:
'
ClusterIntegration|An error occured while trying to fetch project zones: %{error}
'
,
resolve
();
},
resp
=>
{
if
(
resp
.
result
.
error
)
{
Flash
(
sprintf
(
s__
(
'
ClusterIntegration|An error occured while trying to fetch project zones: %{error}
'
,
),
{
error
:
resp
.
result
.
error
.
message
},
),
);
}
reject
();
},
);
});
});
export
const
getMachineTypes
=
({
commit
,
state
})
=>
export
const
getMachineTypes
=
({
commit
,
state
})
=>
new
Promise
((
resolve
,
reject
)
=>
{
gapiRequest
({
const
request
=
gapi
.
client
.
compute
.
machineTypes
.
list
({
service
:
gapi
.
client
.
compute
.
machineTypes
,
params
:
{
project
:
state
.
selectedProject
.
projectId
,
project
:
state
.
selectedProject
.
projectId
,
zone
:
state
.
selectedZone
,
zone
:
state
.
selectedZone
,
});
},
commit
,
return
request
.
then
(
mutation
:
types
.
SET_MACHINE_TYPES
,
resp
=>
{
payloadKey
:
'
items
'
,
commit
(
types
.
SET_MACHINE_TYPES
,
resp
.
result
.
items
);
errorMessage
:
'
ClusterIntegration|An error occured while trying to fetch zone machine types: %{error}
'
,
resolve
();
},
resp
=>
{
if
(
resp
.
result
.
error
)
{
Flash
(
sprintf
(
s__
(
'
ClusterIntegration|An error occured while trying to fetch zone machine types: %{error}
'
,
),
{
error
:
resp
.
result
.
error
.
message
},
),
);
}
reject
();
},
);
});
});
// prevent babel-plugin-rewire from generating an invalid default during karma tests
// prevent babel-plugin-rewire from generating an invalid default during karma tests
...
...
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