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
43eb9e4e
Commit
43eb9e4e
authored
May 10, 2021
by
Paul Kaplan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include if user projects are already in the studio
parent
968afdb4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
5 deletions
+13
-5
src/views/studio/lib/user-projects-actions.js
src/views/studio/lib/user-projects-actions.js
+7
-2
src/views/studio/modals/user-projects-modal.jsx
src/views/studio/modals/user-projects-modal.jsx
+3
-1
src/views/studio/modals/user-projects-tile.jsx
src/views/studio/modals/user-projects-tile.jsx
+3
-2
No files found.
src/views/studio/lib/user-projects-actions.js
View file @
43eb9e4e
import
keyMirror
from
'
keymirror
'
;
import
api
from
'
../../../lib/api
'
;
import
{
selectUsername
}
from
'
../../../redux/session
'
;
import
{
userProjects
}
from
'
./redux-modules
'
;
import
{
userProjects
,
projects
}
from
'
./redux-modules
'
;
const
Errors
=
keyMirror
({
NETWORK
:
null
,
...
...
@@ -40,7 +40,12 @@ const loadUserProjects = type => ((dispatch, getState) => {
},
(
err
,
body
,
res
)
=>
{
const
error
=
normalizeError
(
err
,
body
,
res
);
if
(
error
)
return
dispatch
(
userProjects
.
actions
.
error
(
error
));
dispatch
(
userProjects
.
actions
.
append
(
body
,
body
.
length
===
projectsPerPage
));
const
moreToLoad
=
body
.
length
===
projectsPerPage
;
const
studioProjectIds
=
projects
.
selector
(
getState
()).
items
.
map
(
item
=>
item
.
id
);
const
loadedProjects
=
body
.
map
(
item
=>
Object
.
assign
(
item
,
{
inStudio
:
studioProjectIds
.
indexOf
(
item
.
id
)
!==
-
1
}));
dispatch
(
userProjects
.
actions
.
append
(
loadedProjects
,
moreToLoad
));
});
});
...
...
src/views/studio/modals/user-projects-modal.jsx
View file @
43eb9e4e
...
...
@@ -69,6 +69,7 @@ const UserProjectsModal = ({
id=
{
project
.
id
}
title=
{
project
.
title
}
image=
{
project
.
image
}
inStudio=
{
project
.
inStudio
}
onAdd=
{
onAdd
}
onRemove=
{
onRemove
}
/>
...
...
@@ -92,7 +93,8 @@ UserProjectsModal.propTypes = {
items
:
PropTypes
.
arrayOf
(
PropTypes
.
shape
({
id
:
PropTypes
.
id
,
image
:
PropTypes
.
string
,
title
:
PropTypes
.
string
title
:
PropTypes
.
string
,
inStudio
:
PropTypes
.
bool
})),
loading
:
PropTypes
.
bool
,
error
:
PropTypes
.
object
,
// eslint-disable-line react/forbid-prop-types
...
...
src/views/studio/modals/user-projects-tile.jsx
View file @
43eb9e4e
...
...
@@ -3,9 +3,9 @@ import React, {useState} from 'react';
import
PropTypes
from
'
prop-types
'
;
import
classNames
from
'
classnames
'
;
const
UserProjectsTile
=
({
id
,
title
,
image
,
onAdd
,
onRemove
})
=>
{
const
UserProjectsTile
=
({
id
,
title
,
image
,
inStudio
,
onAdd
,
onRemove
})
=>
{
const
[
submitting
,
setSubmitting
]
=
useState
(
false
);
const
[
added
,
setAdded
]
=
useState
(
false
);
const
[
added
,
setAdded
]
=
useState
(
inStudio
);
const
[
error
,
setError
]
=
useState
(
null
);
const
toggle
=
()
=>
{
setSubmitting
(
true
);
...
...
@@ -50,6 +50,7 @@ UserProjectsTile.propTypes = {
id
:
PropTypes
.
number
.
isRequired
,
title
:
PropTypes
.
string
.
isRequired
,
image
:
PropTypes
.
string
.
isRequired
,
inStudio
:
PropTypes
.
bool
.
isRequired
,
onAdd
:
PropTypes
.
func
.
isRequired
,
onRemove
:
PropTypes
.
func
.
isRequired
};
...
...
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