Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
231fba94
Commit
231fba94
authored
May 13, 2021
by
Paul Kaplan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for duplicates locally before trying to add the project to the studio
parent
4fcdf9b9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletion
+8
-1
src/views/studio/lib/studio-project-actions.js
src/views/studio/lib/studio-project-actions.js
+8
-1
No files found.
src/views/studio/lib/studio-project-actions.js
View file @
231fba94
...
@@ -11,13 +11,15 @@ const Errors = keyMirror({
...
@@ -11,13 +11,15 @@ const Errors = keyMirror({
SERVER
:
null
,
SERVER
:
null
,
PERMISSION
:
null
,
PERMISSION
:
null
,
UNKNOWN_PROJECT
:
null
,
UNKNOWN_PROJECT
:
null
,
RATE_LIMIT
:
null
RATE_LIMIT
:
null
,
DUPLICATE
:
null
});
});
const
normalizeError
=
(
err
,
body
,
res
)
=>
{
const
normalizeError
=
(
err
,
body
,
res
)
=>
{
if
(
err
)
return
Errors
.
NETWORK
;
if
(
err
)
return
Errors
.
NETWORK
;
if
(
res
.
statusCode
===
401
||
res
.
statusCode
===
403
)
return
Errors
.
PERMISSION
;
if
(
res
.
statusCode
===
401
||
res
.
statusCode
===
403
)
return
Errors
.
PERMISSION
;
if
(
res
.
statusCode
===
404
)
return
Errors
.
UNKNOWN_PROJECT
;
if
(
res
.
statusCode
===
404
)
return
Errors
.
UNKNOWN_PROJECT
;
if
(
res
.
statusCode
===
409
)
return
Errors
.
DUPLICATE
;
if
(
res
.
statusCode
===
429
)
return
Errors
.
RATE_LIMIT
;
if
(
res
.
statusCode
===
429
)
return
Errors
.
RATE_LIMIT
;
if
(
res
.
statusCode
!==
200
)
return
Errors
.
SERVER
;
if
(
res
.
statusCode
!==
200
)
return
Errors
.
SERVER
;
return
null
;
return
null
;
...
@@ -73,6 +75,11 @@ const addProject = projectIdOrUrl => ((dispatch, getState) => new Promise((resol
...
@@ -73,6 +75,11 @@ const addProject = projectIdOrUrl => ((dispatch, getState) => new Promise((resol
const
state
=
getState
();
const
state
=
getState
();
const
studioId
=
selectStudioId
(
state
);
const
studioId
=
selectStudioId
(
state
);
const
token
=
selectToken
(
state
);
const
token
=
selectToken
(
state
);
// Check for existing duplicates before going to the server
if
(
projects
.
selector
(
state
).
items
.
filter
(
p
=>
p
.
id
===
projectId
).
length
!==
0
)
{
return
reject
(
Errors
.
DUPLICATE
);
}
api
({
api
({
uri
:
`/studios/
${
studioId
}
/project/
${
projectId
}
`
,
uri
:
`/studios/
${
studioId
}
/project/
${
projectId
}
`
,
method
:
'
POST
'
,
method
:
'
POST
'
,
...
...
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