diff --git a/CHANGELOG.md b/CHANGELOG.md index f32252f295..135ef482b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,17 @@ 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). -## [18.2.1] - 2018-12-06 +## [18.2.2] - 2018-12-18 +### Added: +- Flags: + - `enable_inactive_schemas` + +### Changed: +- Components: + - regisitries: + - `registries-registration-type-facet` - only add ERPC schema when `enable_inactive_schemas` flag is off + +## [18.2.1] - 2018-12-18 ### Added - Mirage: - `queryParamIsTruthy` util diff --git a/config/environment.d.ts b/config/environment.d.ts index de348df2ce..464ea0f54a 100644 --- a/config/environment.d.ts +++ b/config/environment.d.ts @@ -145,6 +145,7 @@ declare const config: { institutions: string; }; storageI18n: string; + enableInactiveSchemas: string; }; gReCaptcha: { siteKey: string; diff --git a/config/environment.js b/config/environment.js index b299e1968f..f237aba442 100644 --- a/config/environment.js +++ b/config/environment.js @@ -227,6 +227,7 @@ module.exports = function(environment) { institutions: 'institutions_nav_bar', }, storageI18n: 'storage_i18n', + enableInactiveSchemas: 'enable_inactive_schemas', }, gReCaptcha: { siteKey: RECAPTCHA_SITE_KEY, diff --git a/lib/registries/addon/components/registries-registration-type-facet/component.ts b/lib/registries/addon/components/registries-registration-type-facet/component.ts index 193c749401..417b2cfb2b 100644 --- a/lib/registries/addon/components/registries-registration-type-facet/component.ts +++ b/lib/registries/addon/components/registries-registration-type-facet/component.ts @@ -4,32 +4,49 @@ import EmberArray, { A } from '@ember/array'; import Component from '@ember/component'; import { task } from 'ember-concurrency'; import DS from 'ember-data'; +import Features from 'ember-feature-flags/services/features'; +import appConfig from 'ember-get-config'; import I18N from 'ember-i18n/services/i18n'; +import Toast from 'ember-toastr/services/toast'; + import RegistrationSchema from 'ember-osf-web/adapters/registration-schema'; import requiredAction from 'ember-osf-web/decorators/required-action'; import Analytics from 'ember-osf-web/services/analytics'; import defaultTo from 'ember-osf-web/utils/default-to'; -import Toast from 'ember-toastr/services/toast'; -import config from 'registries/config/environment'; + +import engineConfig from 'registries/config/environment'; import { SearchOptions } from 'registries/services/search'; import { ShareTermsFilter } from 'registries/services/share-search'; import layout from './template'; +const { + sourcesWhitelist, +} = engineConfig; + +const { + featureFlagNames: { + enableInactiveSchemas, + }, +} = appConfig; + export default class RegistriesRegistrationTypeFacet extends Component.extend({ fetchRegistrationTypes: task(function *(this: RegistriesRegistrationTypeFacet): any { try { const metaschemas: RegistrationSchema[] = yield this.store.findAll('registration-schema'); - this.set('registrationTypes', A( - metaschemas.mapBy('name').concat([ + const metaschemaNames = metaschemas.mapBy('name'); + if (!this.features.isEnabled(enableInactiveSchemas)) { + metaschemaNames.push( // Manually add 'Election Research Preacceptance Competition' to the list of possible // facets. Metaschema was removed from the API as a possible registration type // but should still be searchable 'Election Research Preacceptance Competition', - ]).sort(), - )); + ); + } + this.set('registrationTypes', A(metaschemaNames.sort())); } catch (e) { this.toast.error(this.i18n.t('registries.facets.registration_type.registration_schema_error')); + throw e; } }).on('init'), }) { @@ -39,6 +56,7 @@ export default class RegistriesRegistrationTypeFacet extends Component.extend({ @service toast!: Toast; @service store!: DS.Store; @service analytics!: Analytics; + @service features!: Features; searchOptions!: SearchOptions; @requiredAction onSearchOptionsUpdated!: (options: SearchOptions) => void; @@ -53,7 +71,7 @@ export default class RegistriesRegistrationTypeFacet extends Component.extend({ get onlyOSF() { return this.searchOptions.filters.filter(filter => filter.key === 'sources').size === 1 && this.searchOptions.filters.contains( - new ShareTermsFilter('sources', 'OSF', config.sourcesWhitelist.find(x => x.name === 'OSF')!.display!), + new ShareTermsFilter('sources', 'OSF', sourcesWhitelist.find(x => x.name === 'OSF')!.display!), ); } diff --git a/package.json b/package.json index 2c212b9328..fa088f8161 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ember-osf-web", - "version": "18.2.1", + "version": "18.2.2", "description": "Ember front-end for the Open Science Framework", "license": "Apache-2.0", "author": "Center for Open Science ",