Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
laboite
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Daniel Dehennin
laboite
Commits
c53719c1
Commit
c53719c1
authored
3 years ago
by
Lionel Morin
Browse files
Options
Downloads
Patches
Plain Diff
fix(ui): retrieve add to favorite button on mobile services page
parent
e00ff38b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/imports/ui/components/services/ServiceDetailsList.jsx
+56
-1
56 additions, 1 deletion
app/imports/ui/components/services/ServiceDetailsList.jsx
app/imports/ui/pages/services/ServicesPage.jsx
+1
-2
1 addition, 2 deletions
app/imports/ui/pages/services/ServicesPage.jsx
with
57 additions
and
3 deletions
app/imports/ui/components/services/ServiceDetailsList.jsx
+
56
−
1
View file @
c53719c1
...
...
@@ -6,6 +6,13 @@ import Card from '@material-ui/core/Card';
import
CardHeader
from
'
@material-ui/core/CardHeader
'
;
import
CardMedia
from
'
@material-ui/core/CardMedia
'
;
import
CardActionArea
from
'
@material-ui/core/CardActionArea
'
;
import
AddIcon
from
'
@material-ui/icons/Add
'
;
import
RemoveIcon
from
'
@material-ui/icons/Remove
'
;
// import OpenWithIcon from '@material-ui/icons/OpenWith';
import
Tooltip
from
'
@material-ui/core/Tooltip
'
;
import
Button
from
'
@material-ui/core/Button
'
;
import
i18n
from
'
meteor/universe:i18n
'
;
import
{
isUrlExternal
}
from
'
../../utils/utilsFuncs
'
;
const
useStyles
=
makeStyles
((
theme
)
=>
({
...
...
@@ -36,9 +43,35 @@ const useStyles = makeStyles((theme) => ({
},
},
}));
export
default
function
ServiceDetails
({
service
})
{
export
default
function
ServiceDetails
({
service
,
favAction
})
{
const
classes
=
useStyles
();
const
history
=
useHistory
();
const
favorite
=
favAction
===
'
fav
'
;
const
handleFavorite
=
(
e
)
=>
{
e
.
stopPropagation
();
// To prevent the CardActionArea onClick to launch
if
(
!
favorite
)
{
Meteor
.
call
(
'
services.unfavService
'
,
{
serviceId
:
service
.
_id
},
(
err
)
=>
{
if
(
err
)
{
msg
.
error
(
err
.
reason
);
}
else
{
msg
.
success
(
i18n
.
__
(
'
components.ServiceDetails.unfavSuccessMsg
'
));
}
});
}
else
{
Meteor
.
call
(
'
services.favService
'
,
{
serviceId
:
service
.
_id
},
(
err
)
=>
{
if
(
err
)
{
msg
.
error
(
err
.
reason
);
}
else
{
msg
.
success
(
i18n
.
__
(
'
components.ServiceDetails.favSuccessMsg
'
));
}
});
}
};
const
favButtonLabel
=
!
favorite
?
i18n
.
__
(
'
components.ServiceDetails.favButtonLabelNoFav
'
)
:
i18n
.
__
(
'
components.ServiceDetails.favButtonLabelFav
'
);
const
isExternal
=
isUrlExternal
(
service
.
url
);
const
launchService
=
()
=>
{
...
...
@@ -62,12 +95,34 @@ export default function ServiceDetails({ service }) {
}
}
subheader
=
{
service
.
usage
}
subheaderTypographyProps
=
{
{
variant
:
'
body2
'
,
color
:
service
.
state
===
5
?
'
textSecondary
'
:
'
primary
'
}
}
action
=
{
!!
favAction
&&
(
<
Tooltip
title
=
{
favButtonLabel
}
aria-label
=
{
favButtonLabel
}
>
<
Button
// startIcon={favorite ? <BookmarkBorderIcon /> : <BookmarkIcon />}
variant
=
"outlined"
color
=
"primary"
size
=
"large"
className
=
{
classes
.
fab
}
onClick
=
{
handleFavorite
}
>
{
favorite
?
<
AddIcon
/>
:
<
RemoveIcon
/>
}
{
/* {i18n.__(`components.ServiceDetails.${favorite ? '' : 'un'}pin`)} */
}
</
Button
>
</
Tooltip
>
)
}
/>
</
CardActionArea
>
</
Card
>
);
}
ServiceDetails
.
defaultProps
=
{
favAction
:
null
,
};
ServiceDetails
.
propTypes
=
{
service
:
PropTypes
.
objectOf
(
PropTypes
.
any
).
isRequired
,
favAction
:
PropTypes
.
string
,
};
This diff is collapsed.
Click to expand it.
app/imports/ui/pages/services/ServicesPage.jsx
+
1
−
2
View file @
c53719c1
...
...
@@ -287,8 +287,7 @@ function ServicesPage({ services, categories, ready, structureMode }) {
)
:
viewMode
===
'
list
'
&&
isMobile
?
(
mapList
((
service
)
=>
(
<
Grid
className
=
{
classes
.
gridItem
}
item
xs
=
{
12
}
md
=
{
6
}
key
=
{
service
.
_id
}
>
<
ServiceDetailsList
service
=
{
service
}
/>
{
/* favAction={favAction(service._id)} // PROPS FOR SERVICEDETAILSLIST */
}
<
ServiceDetailsList
service
=
{
service
}
favAction
=
{
favAction
(
service
.
_id
)
}
/>
</
Grid
>
))
)
:
(
...
...
This diff is collapsed.
Click to expand it.
Ghost User
@ghost
mentioned in commit
ef042216
·
3 years ago
mentioned in commit
ef042216
mentioned in commit ef042216e1dc8a8945d24352efa1c537ca6a58ec
Toggle commit list
Ghost User
@ghost
mentioned in commit
ca25b7cd
·
3 years ago
mentioned in commit
ca25b7cd
mentioned in commit ca25b7cd93051f518036b2acc36545e76cebb3e0
Toggle commit list
Ghost User
@ghost
mentioned in commit
3fcb051f
·
3 years ago
mentioned in commit
3fcb051f
mentioned in commit 3fcb051f783dc4384f9de82303ad1e986497fa73
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment