Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Mobile
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
188
Issues
188
List
Boards
Labels
Service Desk
Milestones
Merge Requests
13
Merge Requests
13
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Minds
Minds Mobile
Compare Revisions
3d14508b54ee9fa2bf731adaf6d763de6a617ac3...28c29bf86a16f3ae51050b6098e51d1972e2f36b
Source
28c29bf86a16f3ae51050b6098e51d1972e2f36b
Select Git revision
...
Target
3d14508b54ee9fa2bf731adaf6d763de6a617ac3
Select Git revision
Compare
Commits (5)
(feat) add FLAG_VIEW check and code cleaning in group screen
· 50d4a8f3
Martin Santangelo
authored
7 hours ago
50d4a8f3
(feat) add FLAG_VIEW check to groups in the discovery screen
· f50f9a4d
Martin Santangelo
authored
7 hours ago
f50f9a4d
(feat) add FLAG_VIEW check in blog view screen
· 4212fd06
Martin Santangelo
authored
7 hours ago
4212fd06
(fix) gathering service FLAG_JOIN_GATHERING check
· 401ccd09
Martin Santangelo
authored
7 hours ago
401ccd09
(feat) permissions behind a feature flag
· 28c29bf8
Martin Santangelo
authored
20 minutes ago
28c29bf8
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
192 additions
and
71 deletions
+192
-71
src/auth/UserStore.js
src/auth/UserStore.js
+1
-1
src/blogs/BlogsViewScreen.js
src/blogs/BlogsViewScreen.js
+8
-1
src/channel/ChannelActions.js
src/channel/ChannelActions.js
+3
-2
src/channel/UserModel.js
src/channel/UserModel.js
+7
-0
src/comments/CommentActionSheet.js
src/comments/CommentActionSheet.js
+50
-16
src/common/BaseModel.js
src/common/BaseModel.js
+4
-0
src/common/services/gathering.service.js
src/common/services/gathering.service.js
+1
-1
src/discovery/DiscoveryScreen.js
src/discovery/DiscoveryScreen.js
+5
-0
src/groups/GroupViewScreen.js
src/groups/GroupViewScreen.js
+27
-17
src/newsfeed/activity/ActivityActionSheet.js
src/newsfeed/activity/ActivityActionSheet.js
+86
-33
No files found.
src/auth/UserStore.js
View file @
28c29bf8
...
...
@@ -73,7 +73,7 @@ class UserStore {
}
isAdmin
()
{
return
this
.
me
.
admin
;
return
this
.
me
.
isAdmin
()
;
}
@
action
...
...
This diff is collapsed.
Click to expand it.
src/blogs/BlogsViewScreen.js
View file @
28c29bf8
...
...
@@ -47,6 +47,7 @@ import CenteredLoading from '../common/components/CenteredLoading';
import
logService
from
'
../common/services/log.service
'
;
import
i18n
from
'
../common/services/i18n.service
'
;
import
featuresService
from
'
../common/services/features.service
'
;
import
{
FLAG_VIEW
}
from
'
../common/Permissions
'
;
/**
* Blog View Screen
...
...
@@ -100,7 +101,7 @@ export default class BlogsViewScreen extends Component {
this
.
props
.
blogsView
.
reset
();
let
guid
;
if
(
params
.
slug
)
{
guid
=
params
.
slug
.
substr
(
params
.
slug
.
lastIndexOf
(
'
-
'
)
+
1
);
guid
=
params
.
slug
.
substr
(
params
.
slug
.
lastIndexOf
(
'
-
'
)
+
1
);
}
else
{
guid
=
params
.
guid
;
}
...
...
@@ -108,6 +109,12 @@ export default class BlogsViewScreen extends Component {
await
this
.
props
.
blogsView
.
loadBlog
(
guid
);
}
// check permissions
if
(
!
this
.
props
.
blogsView
.
blog
.
can
(
FLAG_VIEW
,
true
))
{
this
.
props
.
navigation
.
goBack
();
return
;
}
if
(
this
.
props
.
blogsView
.
blog
&&
this
.
props
.
blogsView
.
blog
.
_list
)
{
this
.
props
.
blogsView
.
blog
.
_list
.
viewed
.
addViewed
(
this
.
props
.
blogsView
.
blog
,
...
...
This diff is collapsed.
Click to expand it.
src/channel/ChannelActions.js
View file @
28c29bf8
...
...
@@ -130,7 +130,8 @@ class ChannelActions extends Component {
const
showWire
=
!
channel
.
blocked
&&
!
isOwner
&&
featuresService
.
has
(
'
crypto
'
)
&&
channel
.
can
(
FLAG_WIRE
);
const
showScheduled
=
featuresService
.
has
(
'
post-scheduler
'
)
&&
!
this
.
state
.
edit
&&
isOwner
;
const
showSubscribe
=
!
isOwner
&&
!
channel
.
subscribed
&&
channel
.
can
(
FLAG_SUBSCRIBE
);
const
showMessage
=
!
isOwner
&&
channel
.
can
(
FLAG_MESSAGE
);
const
showMessage
=
!
isOwner
&&
channel
.
subscribed
&&
channel
.
can
(
FLAG_MESSAGE
);
const
showEdit
=
isOwner
&&
channel
.
can
(
FLAG_EDIT_CHANNEL
);
if
(
this
.
props
.
store
.
isUploading
)
{
return
(
...
...
@@ -165,7 +166,7 @@ class ChannelActions extends Component {
text
=
{
i18n
.
t
(
'
channel.message
'
)}
/
>
}
{
channel
.
can
(
FLAG_EDIT_CHANNEL
)
&&
{
showEdit
&&
<
ButtonCustom
onPress
=
{
this
.
onEditAction
}
containerStyle
=
{[
CS
.
rowJustifyCenter
,
CS
.
marginLeft0x
]}
...
...
This diff is collapsed.
Click to expand it.
src/channel/UserModel.js
View file @
28c29bf8
...
...
@@ -64,6 +64,13 @@ export default class UserModel extends BaseModel {
}
}
/**
* Is admin
*/
isAdmin
()
{
return
!!
this
.
admin
;
}
/**
* current user is owner of the channel
*/
...
...
This diff is collapsed.
Click to expand it.
src/comments/CommentActionSheet.js
View file @
28c29bf8
...
...
@@ -5,6 +5,8 @@ import React, {
import
ActionSheet
from
'
react-native-actionsheet
'
;
import
i18n
from
'
../common/services/i18n.service
'
;
import
{
FLAG_EDIT_COMMENT
,
FLAG_DELETE_COMMENT
,
FLAG_CREATE_COMMENT
}
from
'
../common/Permissions
'
;
import
featuresService
from
'
../common/services/features.service
'
;
import
sessionService
from
'
../common/services/session.service
'
;
/**
* Comment Component
...
...
@@ -44,28 +46,60 @@ export default class CommentActionSheet extends Component {
const
comment
=
this
.
props
.
comment
;
if
(
comment
.
can
(
FLAG_EDIT_COMMENT
))
{
actions
.
push
(
i18n
.
t
(
'
edit
'
)
);
if
(
!
comment
.
mature
)
{
actions
.
push
(
i18n
.
t
(
'
setExplicit
'
)
);
}
else
{
actions
.
push
(
i18n
.
t
(
'
removeExplicit
'
)
);
// TODO: clean up permissions feature flag
if
(
featuresService
.
has
(
'
permissions
'
))
{
if
(
comment
.
can
(
FLAG_EDIT_COMMENT
))
{
actions
.
push
(
i18n
.
t
(
'
edit
'
)
);
if
(
!
comment
.
mature
)
{
actions
.
push
(
i18n
.
t
(
'
setExplicit
'
)
);
}
else
{
actions
.
push
(
i18n
.
t
(
'
removeExplicit
'
)
);
}
}
}
if
(
comment
.
can
(
FLAG_DELETE_COMMENT
))
{
actions
.
push
(
i18n
.
t
(
'
delete
'
)
);
}
if
(
comment
.
can
(
FLAG_DELETE_COMMENT
))
{
actions
.
push
(
i18n
.
t
(
'
delete
'
)
);
}
if
(
comment
.
parent_guid_l2
==
0
&&
comment
.
can
(
FLAG_CREATE_COMMENT
))
{
actions
.
push
(
i18n
.
t
(
'
reply
'
)
);
}
if
(
!
comment
.
isOwner
(
))
{
actions
.
push
(
i18n
.
t
(
'
report
'
)
);
}
if
(
!
comment
.
isOwner
())
{
actions
.
push
(
i18n
.
t
(
'
report
'
)
);
actions
.
push
(
i18n
.
t
(
'
copy
'
)
);
if
(
comment
.
parent_guid_l2
==
0
&&
comment
.
can
(
FLAG_CREATE_COMMENT
))
{
actions
.
push
(
i18n
.
t
(
'
reply
'
)
);
}
}
else
{
if
(
comment
.
isOwner
())
{
actions
.
push
(
i18n
.
t
(
'
edit
'
)
);
actions
.
push
(
i18n
.
t
(
'
delete
'
)
);
if
(
!
comment
.
mature
)
{
actions
.
push
(
i18n
.
t
(
'
setExplicit
'
)
);
}
else
{
actions
.
push
(
i18n
.
t
(
'
removeExplicit
'
)
);
}
}
else
{
if
(
sessionService
.
getUser
().
isAdmin
())
{
actions
.
push
(
i18n
.
t
(
'
delete
'
)
);
if
(
!
comment
.
mature
)
{
actions
.
push
(
i18n
.
t
(
'
setExplicit
'
)
);
}
else
{
actions
.
push
(
i18n
.
t
(
'
removeExplicit
'
)
)
}
}
actions
.
push
(
i18n
.
t
(
'
report
'
)
);
actions
.
push
(
i18n
.
t
(
'
copy
'
)
);
}
if
(
comment
.
parent_guid_l2
==
0
)
{
actions
.
push
(
i18n
.
t
(
'
reply
'
)
);
}
}
actions
.
push
(
i18n
.
t
(
'
copy
'
)
);
return
actions
;
}
...
...
This diff is collapsed.
Click to expand it.
src/common/BaseModel.js
View file @
28c29bf8
...
...
@@ -15,6 +15,7 @@ import channelService from '../channel/ChannelService';
import
{
revokeBoost
,
acceptBoost
,
rejectBoost
}
from
'
../boost/BoostService
'
;
import
{
toggleAllowComments
as
toggleAllow
}
from
'
../comments/CommentsService
'
;
import
i18n
from
'
./services/i18n.service
'
;
import
featuresService
from
'
./services/features.service
'
;
/**
* Base model
...
...
@@ -302,6 +303,9 @@ export default class BaseModel {
*/
can
(
action
,
showAlert
=
false
)
{
// TODO: clean up permissions feature flag
if
(
!
featuresService
.
has
(
'
permissions
'
))
return
true
;
let
allowed
=
true
;
if
(
!
this
.
permissions
||
!
this
.
permissions
.
permissions
)
{
...
...
This diff is collapsed.
Click to expand it.
src/common/services/gathering.service.js
View file @
28c29bf8
...
...
@@ -22,7 +22,7 @@ class GatheringService {
*/
@
action
async
join
(
entity
)
{
if
(
this
.
isActive
||
entity
.
can
(
FLAG_JOIN_GATHERING
))
{
if
(
this
.
isActive
||
!
entity
.
can
(
FLAG_JOIN_GATHERING
))
{
return
;
}
try
{
...
...
This diff is collapsed.
Click to expand it.
src/discovery/DiscoveryScreen.js
View file @
28c29bf8
...
...
@@ -47,6 +47,7 @@ import DiscoveryFilters from './NewsfeedFilters';
import
ErrorBoundary
from
'
../common/components/ErrorBoundary
'
;
import
testID
from
'
../common/helpers/testID
'
;
import
i18n
from
'
../common/services/i18n.service
'
;
import
{
FLAG_VIEW
}
from
'
../common/Permissions
'
;
const
isIos
=
Platform
.
OS
===
'
ios
'
;
...
...
@@ -588,6 +589,10 @@ export default class DiscoveryScreen extends Component {
}
navigateToGroup
=
(
group
)
=>
{
if
(
!
group
.
can
(
FLAG_VIEW
,
true
))
{
return
;
}
this
.
props
.
navigation
.
push
(
'
GroupView
'
,
{
group
:
group
})
}
}
...
...
This diff is collapsed.
Click to expand it.
src/groups/GroupViewScreen.js
View file @
28c29bf8
...
...
@@ -38,7 +38,7 @@ import commentsStoreProvider from '../comments/CommentsStoreProvider';
import
i18n
from
'
../common/services/i18n.service
'
;
import
featuresService
from
'
../common/services/features.service
'
;
import
FeedList
from
'
../common/components/FeedList
'
;
import
{
FLAG_CREATE_POST
,
FLAG_APPOINT_MODERATOR
}
from
'
../common/Permissions
'
;
import
{
FLAG_CREATE_POST
,
FLAG_APPOINT_MODERATOR
,
FLAG_VIEW
}
from
'
../common/Permissions
'
;
/**
* Groups view screen
...
...
@@ -82,20 +82,11 @@ export default class GroupViewScreen extends Component {
}
/**
*
On component will mount
*
Load initial data
*/
async
componentWillMount
()
{
async
initialLoad
()
{
const
params
=
this
.
props
.
navigation
.
state
.
params
;
this
.
disposeEnter
=
this
.
props
.
navigation
.
addListener
(
'
didFocus
'
,
(
s
)
=>
{
const
params
=
this
.
props
.
navigation
.
state
.
params
;
if
(
params
&&
params
.
prepend
)
{
this
.
props
.
groupView
.
prepend
(
params
.
prepend
);
// we clear the parameter to prevent prepend it again on goBack
this
.
props
.
navigation
.
setParams
({
prepend
:
null
});
}
});
if
(
params
.
group
)
{
// load group and update async
await
this
.
props
.
groupView
.
loadGroup
(
params
.
group
);
...
...
@@ -111,18 +102,37 @@ export default class GroupViewScreen extends Component {
// load feed
this
.
props
.
groupView
.
loadFeed
();
}
// check permissions
if
(
!
this
.
props
.
groupView
.
group
.
can
(
FLAG_VIEW
,
true
))
{
this
.
props
.
navigation
.
goBack
();
return
;
}
this
.
props
.
groupView
.
loadTopMembers
();
}
componentDidMount
()
{
const
navParams
=
this
.
props
.
navigation
.
state
.
params
;
const
params
=
this
.
props
.
navigation
.
state
.
params
;
// load data async
this
.
initialLoad
();
this
.
disposeEnter
=
this
.
props
.
navigation
.
addListener
(
'
didFocus
'
,
(
s
)
=>
{
const
params
=
this
.
props
.
navigation
.
state
.
params
;
if
(
params
&&
params
.
prepend
)
{
this
.
props
.
groupView
.
prepend
(
params
.
prepend
);
// we clear the parameter to prevent prepend it again on goBack
this
.
props
.
navigation
.
setParams
({
prepend
:
null
});
}
});
if
(
navParams
&&
navP
arams
.
prepend
)
{
this
.
props
.
groupView
.
prepend
(
navP
arams
.
prepend
);
if
(
params
&&
p
arams
.
prepend
)
{
this
.
props
.
groupView
.
prepend
(
p
arams
.
prepend
);
}
if
(
navP
arams
.
tab
&&
this
.
headerRef
)
{
this
.
headerRef
.
wrappedInstance
.
onTabChange
(
navP
arams
.
tab
)
if
(
p
arams
.
tab
&&
this
.
headerRef
)
{
this
.
headerRef
.
wrappedInstance
.
onTabChange
(
p
arams
.
tab
)
}
}
...
...
This diff is collapsed.
Click to expand it.
src/newsfeed/activity/ActivityActionSheet.js
View file @
28c29bf8
...
...
@@ -20,6 +20,7 @@ import i18n from '../../common/services/i18n.service';
import
featuresService
from
'
../../common/services/features.service
'
;
import
translationService
from
'
../../common/services/translation.service
'
;
import
{
FLAG_EDIT_POST
,
FLAG_DELETE_POST
}
from
'
../../common/Permissions
'
;
import
sessionService
from
'
../../common/services/session.service
'
;
/**
* Activity Actions Component
...
...
@@ -60,56 +61,108 @@ export default class ActivityActionSheet extends Component {
let
options
=
[
i18n
.
t
(
'
cancel
'
)
];
const
entity
=
this
.
props
.
entity
;
// if can edit
if
(
entity
.
can
(
FLAG_EDIT_POST
))
{
options
.
push
(
i18n
.
t
(
'
edit
'
)
);
// TODO: remove feature flag
if
(
featuresService
.
has
(
'
permissions
'
))
{
// if can edit
if
(
entity
.
can
(
FLAG_EDIT_POST
))
{
options
.
push
(
i18n
.
t
(
'
edit
'
)
);
if
(
!
entity
.
mature
)
{
options
.
push
(
i18n
.
t
(
'
setExplicit
'
)
);
}
else
{
options
.
push
(
i18n
.
t
(
'
removeExplicit
'
)
);
if
(
!
entity
.
mature
)
{
options
.
push
(
i18n
.
t
(
'
setExplicit
'
)
);
}
else
{
options
.
push
(
i18n
.
t
(
'
removeExplicit
'
)
);
}
if
(
!
entity
.
dontPin
)
{
if
(
!
entity
.
pinned
)
{
options
.
push
(
i18n
.
t
(
'
pin
'
)
);
}
else
{
options
.
push
(
i18n
.
t
(
'
unpin
'
)
);
}
}
if
(
featuresService
.
has
(
'
allow-comments-toggle
'
))
{
options
.
push
(
entity
.
allow_comments
?
i18n
.
t
(
'
disableComments
'
)
:
i18n
.
t
(
'
enableComments
'
));
}
}
if
(
translationService
.
isTranslatable
(
entity
))
{
options
.
push
(
i18n
.
t
(
'
translate.translate
'
)
);
}
if
(
!
entity
.
dontPin
)
{
if
(
!
entity
.
pinned
)
{
options
.
push
(
i18n
.
t
(
'
pin
'
)
);
// if is not the owner
if
(
!
entity
.
isOwner
())
{
options
.
push
(
i18n
.
t
(
'
report
'
)
);
if
(
this
.
state
&&
this
.
state
.
userBlocked
)
{
options
.
push
(
i18n
.
t
(
'
channel.unblock
'
)
);
}
else
{
options
.
push
(
i18n
.
t
(
'
unpin
'
)
);
options
.
push
(
i18n
.
t
(
'
channel.block
'
)
);
}
}
if
(
featuresService
.
has
(
'
allow-comments-toggle
'
))
{
options
.
push
(
entity
.
allow_comments
?
i18n
.
t
(
'
disableComments
'
)
:
i18n
.
t
(
'
enableComments
'
));
options
.
push
(
i18n
.
t
(
'
share
'
)
);
if
(
!
entity
[
'
is:following
'
])
{
options
.
push
(
i18n
.
t
(
'
follow
'
)
);
}
else
{
options
.
push
(
i18n
.
t
(
'
unfollow
'
)
);
}
}
if
(
translationService
.
isTranslatable
(
entity
))
{
options
.
push
(
i18n
.
t
(
'
translate.translate
'
)
);
}
// if can delete
if
(
entity
.
can
(
FLAG_DELETE_POST
))
{
options
.
push
(
<
Text
style
=
{[
CS
.
colorDanger
,
CS
.
fontXL
]}
>
{
i18n
.
t
(
'
delete
'
)}
<
/Text>
)
;
}
}
else
{
// if can edit
if
(
entity
.
isOwner
())
{
options
.
push
(
i18n
.
t
(
'
edit
'
)
);
// if is not the owner
if
(
!
entity
.
isOwner
())
{
options
.
push
(
i18n
.
t
(
'
report
'
)
);
if
(
!
entity
.
mature
)
{
options
.
push
(
i18n
.
t
(
'
setExplicit
'
)
);
}
else
{
options
.
push
(
i18n
.
t
(
'
removeExplicit
'
)
);
}
if
(
this
.
state
&&
this
.
state
.
userBlocked
)
{
options
.
push
(
i18n
.
t
(
'
channel.unblock
'
)
);
}
else
{
options
.
push
(
i18n
.
t
(
'
channel.block
'
)
);
if
(
!
entity
.
dontPin
)
{
if
(
!
entity
.
pinned
)
{
options
.
push
(
i18n
.
t
(
'
pin
'
)
);
}
else
{
options
.
push
(
i18n
.
t
(
'
unpin
'
)
);
}
}
if
(
featuresService
.
has
(
'
allow-comments-toggle
'
))
{
options
.
push
(
entity
.
allow_comments
?
i18n
.
t
(
'
disableComments
'
)
:
i18n
.
t
(
'
enableComments
'
));
}
}
}
options
.
push
(
i18n
.
t
(
'
share
'
)
);
if
(
translationService
.
isTranslatable
(
entity
))
{
options
.
push
(
i18n
.
t
(
'
translate.translate
'
)
);
}
if
(
!
entity
[
'
is:following
'
])
{
options
.
push
(
i18n
.
t
(
'
follow
'
)
);
}
else
{
options
.
push
(
i18n
.
t
(
'
unfollow
'
)
);
}
// if is not the owner
if
(
!
entity
.
isOwner
())
{
options
.
push
(
i18n
.
t
(
'
report
'
)
);
if
(
this
.
state
&&
this
.
state
.
userBlocked
)
{
options
.
push
(
i18n
.
t
(
'
channel.unblock
'
)
);
}
else
{
options
.
push
(
i18n
.
t
(
'
channel.block
'
)
);
}
}
options
.
push
(
i18n
.
t
(
'
share
'
)
);
if
(
!
entity
[
'
is:following
'
])
{
options
.
push
(
i18n
.
t
(
'
follow
'
)
);
}
else
{
options
.
push
(
i18n
.
t
(
'
unfollow
'
)
);
}
// if can delete
if
(
entity
.
can
(
FLAG_DELETE_POST
))
{
if
(
entity
.
isOwner
()
||
sessionService
.
getUser
().
isAdmin
(
))
{
options
.
push
(
<
Text
style
=
{[
CS
.
colorDanger
,
CS
.
fontXL
]}
>
{
i18n
.
t
(
'
delete
'
)}
<
/Text>
)
;
}
}
return
options
;
}
...
...
This diff is collapsed.
Click to expand it.