...
 
Commits (9)
// import 'cypress-file-upload';
context('Blogs', () => {
const closeButton = '[data-cy=data-minds-conversation-close]';
before(() => {
cy.getCookie('minds_sess')
.then((sessionCookie) => {
......@@ -8,6 +11,14 @@ context('Blogs', () => {
return cy.login(true);
}
});
// ensure no messenger windows are open.
cy.get('body').then(($body) => {
if ($body.find(closeButton).length) {
cy.get(closeButton)
.click({multiple: true});
}
});
});
beforeEach(() => {
......@@ -98,8 +109,19 @@ context('Blogs', () => {
);
if (nsfw) {
cy.get('.m-mature-info a').click();
cy.get('.m-mature-info a span').contains('Mature content');
// click on nsfw dropdown
cy.get(
'm-nsfw-selector .m-dropdown--label-container'
).click();
// select Nudity
cy.get('m-nsfw-selector .m-dropdownList__item')
.contains('Nudity')
.click();
// click away
cy.get('m-nsfw-selector .minds-bg-overlay').click({force: true});
}
if (schedule) {
......@@ -197,7 +219,7 @@ context('Blogs', () => {
cy.get('.m-blog--title').contains(title);
cy.get('.minds-blog-body p').contains(body);
};
it('should not be able to create a new blog if no title or banner are specified', () => {
cy.visit('/blog/edit/new');
cy.get('.m-button--submit').click();
......
<m-dropdown class="m-nsfwSelector__dropdown" [expanded]="expanded" #dropdown>
<m-dropdown
class="m-nsfwSelector__dropdown"
[expanded]="expanded"
#dropdown
data-cy="data-minds-nsfw-selector"
>
<label
class="m-nsfwSelector__label m-posterActionBar__IconAndLabel"
[class.selected]="hasSelections()"
......
......@@ -44,6 +44,10 @@ export class NSFWSelectorCreatorService extends NSFWSelectorService {
export class NSFWSelectorConsumerService extends NSFWSelectorService {
cacheKey: string = 'consumer';
}
/**
* Editing service, overrides build to allow pre-setting of values.
*/
export class NSFWSelectorEditingService extends NSFWSelectorService {
cacheKey: string = 'editing';
......
......@@ -154,23 +154,14 @@
<option *ngFor="let a of access" [value]="a.value">{{a.text}}</option>
</select>
</div>
<div class="m-mature-info">
<a
class="mdl-color-text--blue-grey-300 m-capture-mature"
(click)="blog.mature = blog.mature ? 0 : 1; checkMonetized()"
>
<i
class="material-icons"
[ngClass]="{ 'mdl-color-text--red-500': blog.mature }"
title="Mature content"
i18n-title="@@M__COMMON__MATURE_CONTENT"
>explicit</i
>
<span [ngClass]="{ 'mdl-color-text--red-500': blog.mature }"
>{{ blog.mature ? 'Mature content' : 'Anyone' }}</span
>
</a>
</div>
<m-nsfw-selector
service="editing"
(selectedChange)="onNSFWSelections($event)"
[selected]="editing && blog.nsfw != [] ? blog.nsfw : []"
>
</m-nsfw-selector>
<m-wire-threshold-input
[(threshold)]="blog.wire_threshold"
[(enabled)]="blog.paywall"
......
......@@ -245,6 +245,11 @@ describe('BlogEdit', () => {
inputs: ['date', 'dateFormat'],
outputs: ['dateChange'],
}),
MockComponent({
selector: 'm-nsfw-selector',
outputs: ['selectedChanged'],
inputs: ['selected'],
}),
MockDirective({
selector: '[mIfFeature]',
inputs: ['mIfFeature'],
......
......@@ -33,6 +33,7 @@ export class BlogEdit {
time_created: Math.floor(Date.now() / 1000),
access_id: 2,
tags: [],
nsfw: [],
license: 'attribution-sharealike-cc',
fileKey: 'header',
mature: 0,
......@@ -123,6 +124,7 @@ export class BlogEdit {
license: '',
fileKey: 'header',
mature: 0,
nsfw: [],
monetized: 0,
published: 0,
wire_threshold: null,
......@@ -143,8 +145,10 @@ export class BlogEdit {
this.existingBanner = false;
if (this.guid !== 'new') {
this.editing = true;
this.load();
} else {
this.editing = false;
const description: string = this.inMemoryStorageService.once(
'newBlogContent'
);
......@@ -254,6 +258,7 @@ export class BlogEdit {
const blog = Object.assign({}, this.blog);
// only allowed props
blog.nsfw = this.blog.nsfw;
blog.mature = blog.mature ? 1 : 0;
blog.monetization = blog.monetization ? 1 : 0;
blog.monetized = blog.monetized ? 1 : 0;
......@@ -358,4 +363,12 @@ export class BlogEdit {
this.blog.time_published > Math.floor(Date.now() / 1000)
);
}
/**
* Sets this blog NSFW
* @param { array } nsfw - Numerical indexes for reasons in an array e.g. [1, 2].
*/
onNSFWSelections(nsfw) {
this.blog.nsfw = nsfw.map(reason => reason.value);
}
}
......@@ -37,8 +37,6 @@ export class SidebarSelectorComponent implements OnInit {
showExtendedList: boolean = false;
showTrending: boolean = false;
protected lastPreferredEmission: boolean;
constructor(
protected topbarHashtagsService: TopbarHashtagsService,
protected changeDetectorRef: ChangeDetectorRef,
......@@ -46,7 +44,9 @@ export class SidebarSelectorComponent implements OnInit {
) {}
ngOnInit() {
this.lastPreferredEmission = this.preferred;
this.preferred = this.storage.get('preferred_hashtag_state')
? this.storage.get('preferred_hashtag_state') === '1'
: false;
this.init();
}
......@@ -131,15 +131,11 @@ export class SidebarSelectorComponent implements OnInit {
});
} else {
this.currentHashtag = null;
this.preferred = this.lastPreferredEmission;
this.preferredChange();
}
}
preferredChange() {
this.lastPreferredEmission = this.preferred;
this.storage.set('preferred_hashtag_state', this.preferred ? '1' : '0');
this.filterChange.emit({
type: this.preferred ? 'preferred' : 'all',
});
......
......@@ -71,30 +71,11 @@
<option *ngFor="let a of access" [value]="a.value">{{ a.text }}</option>
</select>
</div>
<div class="m-mature-info">
<a
class="mdl-color-text--blue-grey-300 m-capture-mature"
(click)="entity.mature = entity.mature ? 0 : 1"
>
<i
class="material-icons"
[ngClass]="{ 'mdl-color-text--red-500': entity.mature }"
title="Mature content"
i18n-title="@@M__COMMON__MATURE_CONTENT"
>explicit</i
>
<span [ngClass]="{ 'mdl-color-text--red-500': entity.mature }">
<ng-container *ngIf="entity.mature" i18n="@@M__COMMON__MATURE_CONTENT"
>Mature Content</ng-container
>
<ng-container
*ngIf="!entity.mature"
i18n="@@MINDS__MEDIA__ANYONE_LABEL"
>Anyone</ng-container
>
</span>
</a>
</div>
<m-nsfw-selector
service="editing"
(selectedChange)="onNSFWSelections($event)"
[selected]="entity.nsfw"
>
</m-nsfw-selector>
</div>
</form>
......@@ -30,7 +30,7 @@ export class MediaEditComponent {
description: '',
subtype: '',
license: 'all-rights-reserved',
mature: false,
nsfw: [],
};
inProgress: boolean;
error: string;
......@@ -82,6 +82,7 @@ export class MediaEditComponent {
response.entity.mature =
response.entity.flags && response.entity.flags.mature ? 1 : 0;
this.entity.nsfw = response.entity.nsfw;
this.entity = response.entity;
}
});
......@@ -106,4 +107,12 @@ export class MediaEditComponent {
this.entity.file = file.source;
this.entity.thumbnail = file.seconds;
}
/**
* Sets this blog NSFW.
* @param { array } nsfw - Numerical indexes for reasons in an array e.g. [1, 2].
*/
onNSFWSelections(nsfw) {
this.entity.nsfw = nsfw.map(reason => reason.value);
}
}
......@@ -113,7 +113,10 @@ export class NewsfeedSortedComponent implements OnInit, OnDestroy {
if (typeof params['hashtag'] !== 'undefined') {
this.hashtag = params['hashtag'] || null;
this.all = false;
} else if (typeof params['all'] !== 'undefined') {
} else if (
typeof params['all'] !== 'undefined' ||
this.storage.get('preferred_hashtag_state') !== '1'
) {
this.hashtag = null;
this.all = true;
} else if (params['query']) {
......
......@@ -95,7 +95,6 @@
<m-hashtags--sidebar-selector
[disabled]="!isSorted"
[currentHashtag]="hashtag"
[preferred]="!all && !hashtag"
(filterChange)="hashtagFilterChange($event)"
(switchAttempt)="navigateToGlobal()"
></m-hashtags--sidebar-selector>
......@@ -211,7 +210,6 @@
[compact]="true"
[disabled]="!isSorted"
[currentHashtag]="hashtag"
[preferred]="!all && !hashtag"
(filterChange)="hashtagFilterChange($event)"
(switchAttempt)="navigateToGlobal()"
></m-hashtags--sidebar-selector>
......
......@@ -551,7 +551,7 @@
</div>
<div
class="m-proSettings__row--input"
*ngIf="form.value.hashtags.length > 0"
*ngIf="form.value.hashtags.length > -1"
>
<m-draggableList
[headers]="['Label', '#Hashtag']"
......