Commit 95ca222a authored by Brian Hatchet's avatar Brian Hatchet :speech_balloon:

Adding 'allow-comments-toggle' feature. Setting featuresservice assumption to false

1 merge request!426(Feat) disable comments 526
Pipeline #70361159 passed with stages
in 31 minutes and 24 seconds
......@@ -39,7 +39,7 @@
<li class="mdl-menu__item" *ngIf="!asyncBlockInProgress && asyncBlock" (click)="unBlock()" i18n="@@COMMON__POST_MENU__UNBLOCK">Unblock user</li>
</ng-container>
<!-- ALLOW COMMENTS -->
<ng-container *ngIf="options.indexOf('allow-comments') !== -1 && entity.ownerObj.guid == session.getLoggedInUser().guid ">
<ng-container *ngIf="featuresService.has('allow-comments-toggle') && options.indexOf('allow-comments') !== -1 && entity.ownerObj.guid == session.getLoggedInUser().guid ">
<li class="mdl-menu__item" *ngIf="!entity.allow_comments" (click)="allowComments(true)" i18n="@@COMMON__POST_MENU__ALLOW_COMMENTS">Allow Comments</li>
<li class="mdl-menu__item" *ngIf="entity.allow_comments" (click)="allowComments(false)" i18n="@@COMMON__POST_MENU__DISABLE_COMMENTS">Disable Comments</li>
</ng-container>
......
......@@ -16,7 +16,9 @@ import { FormsModule } from '@angular/forms';
import { RouterTestingModule } from '@angular/router/testing';
import { BlockListService } from '../../services/block-list.service';
import { ActivityService } from '../../services/activity.service';
import { FeaturesService } from '../../../services/features.service';
import { activityServiceMock } from '../../../../tests/activity-service-mock.spec';
import { featuresServiceMock } from '../../../../tests/features-service-mock.spec';
/* tslint:disable */
/* Mock section */
......@@ -97,6 +99,7 @@ describe('PostMenuComponent', () => {
{ provide: Session, useValue: sessionMock },
{ provide: OverlayModalService, useValue: overlayModalServiceMock },
{ provide: ActivityService, useValue: activityServiceMock },
{ provide: FeaturesService, useValue: featuresServiceMock },
BlockListService,
],
schemas: [
......@@ -108,6 +111,7 @@ describe('PostMenuComponent', () => {
// synchronous beforeEach
beforeEach(() => {
featuresServiceMock.mock('allow-comments-toggle', true);
fixture = TestBed.createComponent(PostMenuComponent);
comp = fixture.componentInstance;
......@@ -115,8 +119,9 @@ describe('PostMenuComponent', () => {
comp.entity = {};
// comp.opened = true;
comp.entity.ownerObj = { guid: '1' };
comp.cardMenuHandler();
comp.cardMenuHandler();
fixture.detectChanges();
});
it('should have dropdown', () => {
......
......@@ -7,7 +7,7 @@ import { MindsUser } from '../../../interfaces/entities';
import { SignupModalService } from '../../../modules/modals/signup/service';
import { BlockListService } from '../../services/block-list.service';
import { ActivityService } from '../../../common/services/activity.service';
import { FeaturesService } from '../../../services/features.service';
type Option =
'edit'
......@@ -70,7 +70,7 @@ export class PostMenuComponent implements OnInit {
public signupModal: SignupModalService,
protected blockListService: BlockListService,
protected activityService: ActivityService,
) {
public featuresService: FeaturesService) {
this.initCategories();
}
......@@ -83,6 +83,7 @@ export class PostMenuComponent implements OnInit {
label: window.Minds.categories[category],
});
}
console.log("Working!");
}
cardMenuHandler() {
......
......@@ -22,11 +22,11 @@ export class FeaturesService {
if (typeof this._features[feature] === 'undefined') {
if (isDevMode() && !this._hasWarned(feature)) {
console.warn(`[FeaturedService] Feature '${feature}' is not declared. Assuming true.`);
console.warn(`[FeaturedService] Feature '${feature}' is not declared. Assuming false.`);
this._warnedCache[feature] = Date.now();
}
return true;
return false;
}
if (this._features[feature] === 'admin' && this.session.isAdmin()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment