Skip to content

Commit

Permalink
Merge branch 'release/23.03.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
adlius committed Feb 6, 2023
2 parents b087ac5 + b5e217f commit 69f9c11
Show file tree
Hide file tree
Showing 57 changed files with 1,027 additions and 168 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ module.exports = {
'no-empty': 'error',
'no-eval': 'error',
'no-multiple-empty-lines': 'error',
'no-nested-ternary': 'error',
'no-new-wrappers': 'error',
'no-throw-literal': 'error',
'no-trailing-spaces': 'error',
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [23.03.0] - 2023-02-06
### Changed
- Collections Moderation bug and improvements

## [23.02.1] - 2023-01-31
### Changed
- Hotfix the bug where metadata does not display for files on providers that have neither tags nor revisions
Expand Down Expand Up @@ -1897,6 +1901,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- Quick Files

[23.03.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.03.0
[23.02.1]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.02.1
[23.02.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.02.0
[23.01.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/23.01.0
[22.11.0]: https://github.com/CenterForOpenScience/ember-osf-web/releases/tag/22.11.0
Expand Down
11 changes: 11 additions & 0 deletions app/adapters/collection-subscription.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import OsfAdapter from './osf-adapter';

export default class CollectionSubscriptionAdapter extends OsfAdapter {
parentRelationship = 'collection-provider';
}

declare module 'ember-data/types/registries/adapter' {
export default interface AdapterRegistry {
'collection-subscription': CollectionSubscriptionAdapter;
} // eslint-disable-line semi
}
11 changes: 11 additions & 0 deletions app/adapters/registration-subscription.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import OsfAdapter from './osf-adapter';

export default class RegistrationSubscriptionAdapter extends OsfAdapter {
parentRelationship = 'registration-provider';
}

declare module 'ember-data/types/registries/adapter' {
export default interface AdapterRegistry {
'registration-subscription': RegistrationSubscriptionAdapter;
} // eslint-disable-line semi
}
2 changes: 1 addition & 1 deletion app/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const App = Application.extend({
},
},
},
analyticsPage: {
'analytics-page': {
dependencies: {
services: [
'intl',
Expand Down
8 changes: 0 additions & 8 deletions app/guid-file/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@ export default class GuidFile extends Controller {
return this.media.isTablet;
}

get nodeTypeTranslation() {
const { target } = this.model.fileModel;
const translationKeyBase = 'general';
const translationNode = target.get('isRegistration') ? 'registration'
: target.get('isRoot') ? 'project' : 'component';
return this.intl.t(`${translationKeyBase}.${translationNode}`);
}

@action
changeVersion(version: number) {
this.viewedVersion = version;
Expand Down
4 changes: 4 additions & 0 deletions app/guid-file/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
padding: 0 20px 20px;
}

.placeholder {
color: #555;
}

.slide-buttons {
background-color: $color-bg-white;
border: 0;
Expand Down
11 changes: 8 additions & 3 deletions app/guid-file/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,15 @@
@valuePath='languageObject'
@searchField='name'
@searchEnabled={{true}}
@placeholder={{t 'file_detail.choose_language'}}
as |option|
>
{{option.name}}
{{#if option.name}}
{{option.name}}
{{else}}
<span local-class='placeholder'>
{{t 'file_detail.choose_language'}}
</span>
{{/if}}
</form.select>
</FormControls>
</div>
Expand Down Expand Up @@ -194,7 +199,7 @@
<GuidFile::-Components::ResourceHelpDialog
@isOpen={{this.resourceHelpOpen}}
@userCanEdit={{manager.userCanEdit}}
@parentNodeType={{this.nodeTypeTranslation}}
@parentNodeType={{manager.target.nodeTypeTranslation}}
/>
</dt>
<dd data-test-file-resource-type>{{manager.metadataRecord.resourceTypeGeneral}}</dd>
Expand Down
6 changes: 5 additions & 1 deletion app/models/collection-provider.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { computed } from '@ember/object';
import { htmlSafe } from '@ember/string';
import { belongsTo, AsyncBelongsTo } from '@ember-data/model';
import { belongsTo, hasMany, AsyncBelongsTo, AsyncHasMany } from '@ember-data/model';

import CollectionModel from './collection';
import ProviderModel from './provider';
import CollectionSubscriptionModel from './collection-subscription';

export default class CollectionProviderModel extends ProviderModel {
@belongsTo('collection')
primaryCollection!: AsyncBelongsTo<CollectionModel> & CollectionModel;

@hasMany('collection-subscriptions', { inverse: 'provider' })
subscriptions!: AsyncHasMany<CollectionSubscriptionModel>;

@computed('description')
get htmlSafeDescription() {
if (this.description) {
Expand Down
16 changes: 16 additions & 0 deletions app/models/collection-subscription.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { AsyncBelongsTo, belongsTo } from '@ember-data/model';
import CollectionProviderModel from 'ember-osf-web/models/collection-provider';
import SubscriptionModel from './subscription';

// subscription model for collection-provider specific notifications to avoid ID conflicts with other provider types
// e.g. preprint_providers, registration_providers with the same ID
export default class CollectionSubscriptionModel extends SubscriptionModel {
@belongsTo('collection-provider', { inverse: 'subscriptions' })
provider!: AsyncBelongsTo<CollectionProviderModel> & CollectionProviderModel;
}

declare module 'ember-data/types/registries/model' {
export default interface ModelRegistry {
'collection-subscription': SubscriptionModel;
} // eslint-disable-line semi
}
15 changes: 15 additions & 0 deletions app/models/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import { attr, belongsTo, hasMany, AsyncBelongsTo, AsyncHasMany } from '@ember-d

import { computed } from '@ember/object';
import { alias, bool, equal, not } from '@ember/object/computed';
import { inject as service } from '@ember/service';
import { htmlSafe } from '@ember/string';
import { buildValidations, validator } from 'ember-cp-validations';
import Intl from 'ember-intl/services/intl';

import getRelatedHref from 'ember-osf-web/utils/get-related-href';

Expand Down Expand Up @@ -84,6 +86,8 @@ export interface NodeLicense {
}

export default class NodeModel extends AbstractNodeModel.extend(Validations, CollectableValidations) {
@service intl!: Intl;

@attr('fixstring') title!: string;
@attr('fixstring') description!: string;
@attr('node-category') category!: NodeCategory;
Expand Down Expand Up @@ -237,6 +241,17 @@ export default class NodeModel extends AbstractNodeModel.extend(Validations, Col
return NodeType.Generic;
}

/**
* The type of this node, as a string.
*/
get nodeTypeTranslation(): string {
let translationNode = this.isRoot ? 'project' : 'component';
if (this.isRegistration) {
translationNode = 'registration';
}
return this.intl.t(`general.${translationNode}`);
}

// This is for the title helper, which does its own encoding of unsafe characters
@computed('title')
get unsafeTitle() {
Expand Down
4 changes: 4 additions & 0 deletions app/models/registration-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import RegistrationSchemaModel from 'ember-osf-web/models/registration-schema';
import BrandModel from './brand';
import ProviderModel from './provider';
import RegistrationModel from './registration';
import RegistrationSubscriptionModel from './registration-subscription';

export default class RegistrationProviderModel extends ProviderModel {
@hasMany('registration', { inverse: 'provider' })
Expand All @@ -21,6 +22,9 @@ export default class RegistrationProviderModel extends ProviderModel {
@hasMany('review-action', { inverse: null })
actions!: AsyncHasMany<ReviewActionModel> | ReviewActionModel[];

@hasMany('registration-subscriptions', { inverse: 'provider' })
subscriptions!: AsyncHasMany<RegistrationSubscriptionModel>;

@attr('fixstring')
shareSource?: string;

Expand Down
16 changes: 16 additions & 0 deletions app/models/registration-subscription.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { AsyncBelongsTo, belongsTo } from '@ember-data/model';
import RegistrationProviderModel from 'ember-osf-web/models/registration-provider';
import SubscriptionModel from './subscription';

// subscription model for registration-provider specific notifications to avoid ID conflicts with other provider types
// e.g. preprint_providers, collection_providers with the same ID
export default class RegistrationSubscriptionModel extends SubscriptionModel {
@belongsTo('registration-provider', { inverse: 'subscriptions' })
provider!: AsyncBelongsTo<RegistrationProviderModel> & RegistrationProviderModel;
}

declare module 'ember-data/types/registries/model' {
export default interface ModelRegistry {
'registration-subscription': SubscriptionModel;
} // eslint-disable-line semi
}
10 changes: 10 additions & 0 deletions app/serializers/collection-subscription.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import OsfSerializer from './osf-serializer';

export default class CollectionSubscriptionSerializer extends OsfSerializer {
}

declare module 'ember-data/types/registries/serializer' {
export default interface SerializerRegistry {
'collection-subscription': CollectionSubscriptionSerializer;
} // eslint-disable-line semi
}
10 changes: 10 additions & 0 deletions app/serializers/registration-subscription.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import OsfSerializer from './osf-serializer';

export default class RegistrationSubscriptionSerializer extends OsfSerializer {
}

declare module 'ember-data/types/registries/serializer' {
export default interface SerializerRegistry {
'registration-subscription': RegistrationSubscriptionSerializer;
} // eslint-disable-line semi
}
1 change: 0 additions & 1 deletion config/deprecation-workflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ self.deprecationWorkflow.config = {
{ handler: 'silence', matchId: 'autotracking.mutation-after-consumption' },
{ handler: 'silence', matchId: 'computed-property.override' },
{ handler: 'silence', matchId: 'ember-utils.try-invoke' },
{ handler: 'silence', matchId: 'ember-engines.deprecation-camelized-engine-names' },
{ handler: 'silence', matchId: 'ember-data:legacy-test-helper-support' },
{ handler: 'silence', matchId: 'has-block-and-has-block-params' },
{ handler: 'silence', matchId: 'ember-simple-auth.initializer.setup-session-restoration' },
Expand Down
2 changes: 1 addition & 1 deletion config/environment.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ declare const config: {
keenSessionId: string;
analyticsDismissAdblock: string;
cookieConsent: string;
outputFeaturePopover: string;
newFeaturePopover: string;
maintenance: string;
csrf: string;
authSession: string;
Expand Down
2 changes: 1 addition & 1 deletion config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ module.exports = function(environment) {
keenSessionId: 'keenSessionId',
analyticsDismissAdblock: 'adBlockDismiss',
cookieConsent: 'osf_cookieconsent',
outputFeaturePopover: 'outputFeaturePopover',
newFeaturePopover: 'metadataFeaturePopover',
maintenance: 'maintenance',
csrf: 'api-csrf',
authSession: 'embosf-auth-session',
Expand Down
2 changes: 1 addition & 1 deletion ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports = function(defaults) {
bundleZxcvbn: !IS_PROD,
},
fingerprint: {
enabled: true,
enabled: IS_PROD,
extensions: broccoliAssetRevDefaults.extensions.concat(['svg']),
exclude: [
'zxcvbn.js',
Expand Down
22 changes: 19 additions & 3 deletions lib/collections/addon/provider/moderation/all/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@ import Controller from '@ember/controller';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
import IntlService from 'ember-intl/services/intl';
import Media from 'ember-responsive';

import { CollectionSubmissionReviewStates, SubmissionIconMap } from 'ember-osf-web/models/collection-submission';

interface SortOption {
label: string;
value: string;
}

export default class CollectionsModerationAllController extends Controller {
@service intl!: IntlService;
@service media!: Media;

queryParams = ['state'];

@tracked state?: CollectionSubmissionReviewStates;
@tracked sort = '-date_created';
@tracked sort = { label: this.intl.t('collections.moderation.all.sort.date_descending'), value: '-date_modified' };

states = [
CollectionSubmissionReviewStates.Pending,
Expand All @@ -22,6 +28,12 @@ export default class CollectionsModerationAllController extends Controller {
CollectionSubmissionReviewStates.Removed,
];
submissionIconMap = SubmissionIconMap;
sortOptions: SortOption[] = [
{ label: this.intl.t('collections.moderation.all.sort.date_descending'), value: '-date_modified' },
{ label: this.intl.t('collections.moderation.all.sort.date_ascending'), value: 'date_modified' },
{ label: this.intl.t('collections.moderation.all.sort.title_ascending'), value: 'title' },
{ label: this.intl.t('collections.moderation.all.sort.title_descending'), value: '-title' },
];
reloadSubmissionList?: (page?: number) => void; // bound by paginated-list

get isMobile() {
Expand All @@ -33,11 +45,15 @@ export default class CollectionsModerationAllController extends Controller {
filter: {
reviews_state: this.state,
},
// TBD: '-modified'?? Check if API has dateModified based on actions
sort: this.sort,
sort: this.sort.value,
};
}

@action
onSortChange(option: SortOption) {
this.sort = option;
}

@action
changeTab(tab: CollectionSubmissionReviewStates) {
this.state = tab;
Expand Down
10 changes: 8 additions & 2 deletions lib/collections/addon/provider/moderation/all/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@
}
}

.sort-button {
margin-right: 15px;
.sort-wrapper {
width: 155px;
float: right;

&.mobile {
float: none;
margin-top: 10px;
}
}

.list {
Expand Down
10 changes: 10 additions & 0 deletions lib/collections/addon/provider/moderation/all/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@
</a>
{{/let}}
{{/each}}
<div data-test-submission-sort local-class='sort-wrapper {{if this.isMobile 'mobile'}}'>
<PowerSelect
@options={{this.sortOptions}}
@selected={{this.sort}}
@onChange={{action this.onSortChange}}
as |sort|
>
{{sort.label}}
</PowerSelect>
</div>
</nav>
<PaginatedList::HasMany
@model={{this.model}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import Controller from '@ember/controller';
import { computed } from '@ember/object';
import { alias } from '@ember/object/computed';
import config from 'ember-get-config';
import pathJoin from 'ember-osf-web/utils/path-join';

export default class ModerationSettingsController extends Controller {
userSettingsLink = pathJoin(config.OSF.url, 'settings', 'notifications');
@alias('model.id') providerId?: string;

@computed('providerId')
get subscriptionIds() {
return [`${this.providerId}_new_pending_submissions`];
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Route from '@ember/routing/route';
// import { inject as service } from '@ember/service';

export default class ModerationSettings extends Route {
}
Loading

0 comments on commit 69f9c11

Please sign in to comment.