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 Frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
870
Issues
870
List
Boards
Labels
Service Desk
Milestones
Merge Requests
47
Merge Requests
47
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
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
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Frontend
Compare Revisions
d0fe65cd1a30189e3af959a78b96e83796e9569b...94f507a70aa2a9dad2b1e4f8d1325c2e37b835d2
Source
94f507a70aa2a9dad2b1e4f8d1325c2e37b835d2
Select Git revision
...
Target
d0fe65cd1a30189e3af959a78b96e83796e9569b
Select Git revision
Compare
Commits (2)
(feat): enforce vote permissions
· e4bd4e81
Marcelo Rivera
authored
1 day ago
e4bd4e81
(feat): enforce DELETE_CHANNEL permission
· 94f507a7
Marcelo Rivera
authored
1 day ago
94f507a7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
10 deletions
+77
-10
src/app/common/components/thumbs/thumbs-down.component.ts
src/app/common/components/thumbs/thumbs-down.component.ts
+23
-4
src/app/common/components/thumbs/thumbs-up.component.ts
src/app/common/components/thumbs/thumbs-up.component.ts
+26
-3
src/app/modules/settings/disable/disable.component.html
src/app/modules/settings/disable/disable.component.html
+2
-0
src/app/modules/settings/disable/disable.component.ts
src/app/modules/settings/disable/disable.component.ts
+26
-3
No files found.
src/app/common/components/thumbs/thumbs-down.component.ts
View file @
94f507a7
...
...
@@ -3,19 +3,22 @@ import {
ChangeDetectorRef
,
Component
,
DoCheck
,
Input
,
}
from
'
@angular/core
'
;
import
{
Session
}
from
'
../../../services/session
'
;
import
{
Client
}
from
'
../../../services/api
'
;
import
{
WalletService
}
from
'
../../../services/wallet
'
;
import
{
SignupModalService
}
from
'
../../../modules/modals/signup/service
'
;
import
{
Flags
}
from
'
../../services/permissions/flags
'
;
import
{
PermissionsService
}
from
'
../../services/permissions/permissions.service
'
;
import
{
FeaturesService
}
from
'
../../../services/features.service
'
;
@
Component
({
selector
:
'
minds-button-thumbs-down
'
,
inputs
:
[
'
_object: object
'
],
changeDetection
:
ChangeDetectionStrategy
.
OnPush
,
template
:
`
<a (click)="thumb()" [ngClass]="{ selected: has() }">
<a (click)="thumb()" [ngClass]="{ selected: has()
, disabled: !enabled
}">
<i class="material-icons">thumb_down</i>
<span class="minds-counter" *ngIf="object['thumbs:down:count'] > 0">{{
object['thumbs:down:count'] | number
...
...
@@ -34,19 +37,35 @@ export class ThumbsDownButton implements DoCheck {
changesDetected
:
boolean
=
false
;
object
;
showModal
:
boolean
=
false
;
enabled
:
boolean
=
true
;
constructor
(
private
cd
:
ChangeDetectorRef
,
public
session
:
Session
,
public
client
:
Client
,
public
wallet
:
WalletService
,
private
modal
:
SignupModalService
private
modal
:
SignupModalService
,
private
permissionsService
:
PermissionsService
,
private
featuresService
:
FeaturesService
)
{}
set
_object
(
value
:
any
)
{
@
Input
(
'
object
'
)
set
_object
(
value
:
any
)
{
this
.
object
=
value
;
if
(
!
this
.
object
[
'
thumbs:down:user_guids
'
])
this
.
object
[
'
thumbs:down:user_guids
'
]
=
[];
this
.
checkPermissions
();
}
private
checkPermissions
()
{
if
(
this
.
featuresService
.
has
(
'
permissions
'
))
{
this
.
enabled
=
this
.
permissionsService
.
canInteract
(
this
.
object
,
Flags
.
VOTE
);
}
else
{
this
.
enabled
=
true
;
}
}
thumb
()
{
...
...
This diff is collapsed.
Click to expand it.
src/app/common/components/thumbs/thumbs-up.component.ts
View file @
94f507a7
...
...
@@ -4,19 +4,22 @@ import {
Component
,
DoCheck
,
OnChanges
,
Input
,
}
from
'
@angular/core
'
;
import
{
Session
}
from
'
../../../services/session
'
;
import
{
Client
}
from
'
../../../services/api
'
;
import
{
WalletService
}
from
'
../../../services/wallet
'
;
import
{
SignupModalService
}
from
'
../../../modules/modals/signup/service
'
;
import
{
Flags
}
from
'
../../services/permissions/flags
'
;
import
{
PermissionsService
}
from
'
../../services/permissions/permissions.service
'
;
import
{
FeaturesService
}
from
'
../../../services/features.service
'
;
@
Component
({
selector
:
'
minds-button-thumbs-up
'
,
inputs
:
[
'
_object: object
'
],
changeDetection
:
ChangeDetectionStrategy
.
OnPush
,
template
:
`
<a (click)="thumb()" [ngClass]="{ selected: has() }">
<a (click)="thumb()" [ngClass]="{ selected: has()
, disabled: !enabled
}">
<i class="material-icons">thumb_up</i>
<span class="minds-counter" *ngIf="object['thumbs:up:count'] > 0">{{
object['thumbs:up:count'] | number
...
...
@@ -39,20 +42,36 @@ export class ThumbsUpButton implements DoCheck, OnChanges {
'
thumbs:up:user_guids
'
:
[],
};
showModal
:
boolean
=
false
;
enabled
:
boolean
=
true
;
constructor
(
public
session
:
Session
,
public
client
:
Client
,
public
wallet
:
WalletService
,
private
modal
:
SignupModalService
,
private
permissionsService
:
PermissionsService
,
private
featuresService
:
FeaturesService
,
private
cd
:
ChangeDetectorRef
)
{}
set
_object
(
value
:
any
)
{
@
Input
(
'
object
'
)
set
_object
(
value
:
any
)
{
if
(
!
value
)
return
;
this
.
object
=
value
;
if
(
!
this
.
object
[
'
thumbs:up:user_guids
'
])
this
.
object
[
'
thumbs:up:user_guids
'
]
=
[];
this
.
checkPermissions
();
}
private
checkPermissions
()
{
if
(
this
.
featuresService
.
has
(
'
permissions
'
))
{
this
.
enabled
=
this
.
permissionsService
.
canInteract
(
this
.
object
,
Flags
.
VOTE
);
}
else
{
this
.
enabled
=
true
;
}
}
thumb
()
{
...
...
@@ -62,6 +81,10 @@ export class ThumbsUpButton implements DoCheck, OnChanges {
return
false
;
}
if
(
!
this
.
enabled
)
{
return
;
}
this
.
client
.
put
(
'
api/v1/thumbs/
'
+
this
.
object
.
guid
+
'
/up
'
,
{});
if
(
!
this
.
has
())
{
//this.object['thumbs:up:user_guids'].push(this.session.getLoggedInUser().guid);
...
...
This diff is collapsed.
Click to expand it.
src/app/modules/settings/disable/disable.component.html
View file @
94f507a7
...
...
@@ -11,6 +11,7 @@
<button
class=
"mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-color--red"
(click)=
"disable()"
[disabled]=
"!enabled"
>
<ng-container
i18n=
"@@MINDS__SETTINGS__DISABLE_CONFIRM"
>
I'm sure - Disable
</ng-container
...
...
@@ -30,6 +31,7 @@
<button
class=
"mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-color--red"
(click)=
"delete()"
[disabled]=
"!enabled"
>
<ng-container
i18n=
"@@MINDS__SETTINGS__DELETE_CONFIRM"
>
I'm sure - Delete
</ng-container
...
...
This diff is collapsed.
Click to expand it.
src/app/modules/settings/disable/disable.component.ts
View file @
94f507a7
import
{
Component
}
from
'
@angular/core
'
;
import
{
Component
,
OnInit
}
from
'
@angular/core
'
;
import
{
Router
}
from
'
@angular/router
'
;
import
{
Client
}
from
'
../../../services/api
'
;
import
{
OverlayModalService
}
from
'
../../../services/ux/overlay-modal
'
;
import
{
ConfirmPasswordModalComponent
}
from
'
../../modals/confirm-password/modal.component
'
;
import
{
PermissionsService
}
from
'
../../../common/services/permissions/permissions.service
'
;
import
{
FeaturesService
}
from
'
../../../services/features.service
'
;
import
{
Flags
}
from
'
../../../common/services/permissions/flags
'
;
import
{
Session
}
from
'
../../../services/session
'
;
@
Component
({
moduleId
:
module
.
id
,
...
...
@@ -11,20 +15,28 @@ import { ConfirmPasswordModalComponent } from '../../modals/confirm-password/mod
inputs
:
[
'
object
'
],
templateUrl
:
'
disable.component.html
'
,
})
export
class
SettingsDisableChannelComponent
{
export
class
SettingsDisableChannelComponent
implements
OnInit
{
minds
:
Minds
;
user
:
any
;
settings
:
string
;
object
:
any
;
enabled
:
boolean
=
true
;
constructor
(
public
client
:
Client
,
public
router
:
Router
,
private
overlayModal
:
OverlayModalService
private
overlayModal
:
OverlayModalService
,
private
session
:
Session
,
private
permissionsService
:
PermissionsService
,
private
featuresService
:
FeaturesService
)
{
this
.
minds
=
window
.
Minds
;
}
ngOnInit
()
{
this
.
checkPermissions
();
}
disable
()
{
this
.
client
.
delete
(
'
api/v1/channel
'
)
...
...
@@ -63,4 +75,15 @@ export class SettingsDisableChannelComponent {
);
creator
.
present
();
}
private
checkPermissions
()
{
if
(
this
.
featuresService
.
has
(
'
permissions
'
))
{
this
.
enabled
=
this
.
permissionsService
.
canInteract
(
this
.
session
.
getLoggedInUser
(),
Flags
.
DELETE_CHANNEL
);
}
else
{
this
.
enabled
=
true
;
}
}
}
This diff is collapsed.
Click to expand it.