Commit e384309c authored by Ben Hayward's avatar Ben Hayward

Disabled reminding and boosting from closed groups #2586

1 merge request!784Removed Remind and Boost buttons in closed groups #2586
Pipeline #118085694 passed with stages
in 90 minutes
......@@ -63,6 +63,8 @@
(delete)="delete(entity)"
[slot]="i + 1"
[attr.data-minds-activity-guid]="entity.guid"
[disableBoosting]="group['membership'] === 0"
[disableReminding]="group['membership'] === 0"
>
<!-- Menu Actions -->
......
///<reference path="../../../../../../../node_modules/@types/jasmine/index.d.ts"/>
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import {
async,
ComponentFixture,
TestBed,
fakeAsync,
tick,
} from '@angular/core/testing';
import {
Component,
DebugElement,
......@@ -569,5 +575,56 @@ describe('Activity', () => {
expect(views.nativeElement.textContent).toContain(100);
});
it('should default disableReminding to FALSE', () => {
expect(comp.disableReminding).toBeFalsy();
});
it('should not show remind button if disableReminding set to true', () => {
spyOn(comp, 'isScheduled').and.callFake(function() {
return false;
});
comp.disableReminding = true;
comp.activity.time_created = 999999999999999999999;
expect(comp.showRemindButton()).toBeFalsy();
});
it('should show remind button if disableReminding set to false', () => {
spyOn(comp, 'isScheduled').and.callFake(function() {
return false;
});
comp.disableReminding = false;
comp.activity.time_created = 999999999999999999999;
expect(comp.showRemindButton()).toBeTruthy();
});
it('should default disableBoosting to FALSE', () => {
expect(comp.disableBoosting).toBeFalsy();
});
it('should not show boost button if disableReminding set to true', () => {
spyOn(comp, 'isScheduled').and.callFake(function() {
return false;
});
spyOn(comp.session, 'getLoggedInUser').and.callFake(function() {
return { guid: '123' };
});
comp.disableBoosting = true;
comp.activity.time_created = 999999999999999999999;
comp.activity.owner_guid = '123';
expect(comp.showBoostButton()).toBeFalsy();
});
it('should show boost button if disableReminding set to false', () => {
spyOn(comp, 'isScheduled').and.callFake(function() {
return false;
});
spyOn(comp.session, 'getLoggedInUser').and.callFake(function() {
return { guid: '123' };
});
comp.disableBoosting = false;
comp.activity.time_created = 999999999999999999999;
comp.activity.owner_guid = '123';
expect(comp.showBoostButton()).toBeTruthy();
});
// TODO test the rest of the features
});
......@@ -400,8 +400,7 @@
></m-wire-button>
<button
class="m-btn m-btn--action m-btn--slim minds-boost-button"
*ngIf="session.getLoggedInUser().guid == activity.owner_guid
&& !isScheduled(activity.time_created)"
*ngIf="showBoostButton()"
id="boost-actions"
(click)="showBoost()"
>
......@@ -411,7 +410,10 @@
[object]="activity"
(click)="openComments()"
></minds-button-comment>
<minds-button-remind [object]="activity"></minds-button-remind>
<minds-button-remind
*ngIf="showRemindButton()"
[object]="activity"
></minds-button-remind>
</div>
<!-- Activity metrics -->
......
......@@ -70,6 +70,8 @@ export class Activity implements OnInit {
showBoostOptions: boolean = false;
allowComments = true;
@Input() boost: boolean = false;
@Input() disableBoosting: boolean = false;
@Input() disableReminding: boolean = false;
@Input('boost-toggle')
@Input()
showBoostMenuOptions: boolean = false;
......@@ -613,4 +615,26 @@ export class Activity implements OnInit {
? true
: false;
}
/**
* Determined whether boost button should be shown.
* @returns { boolean } true if boost button should be shown.
*/
showBoostButton(): boolean {
return (
this.session.getLoggedInUser().guid == this.activity.owner_guid &&
!this.isScheduled(this.activity.time_created) &&
!this.disableBoosting
);
}
/**
* Determined whether remind button should be shown.
* @returns { boolean } true if remind button should be shown.
*/
showRemindButton(): boolean {
return (
!this.isScheduled(this.activity.time_created) && !this.disableReminding
);
}
}
Please register or to comment