From 898c70a3a88a32f30884992232d30a0e08f45ebc Mon Sep 17 00:00:00 2001 From: Brian Geiger Date: Fri, 24 Sep 2021 13:11:06 -0400 Subject: [PATCH 1/2] Get provider types instead of all types --- .../component.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) 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 f1b09e5f014..69f92a5cf53 100644 --- a/lib/registries/addon/components/registries-registration-type-facet/component.ts +++ b/lib/registries/addon/components/registries-registration-type-facet/component.ts @@ -6,12 +6,11 @@ import { inject as service } from '@ember/service'; import { waitFor } from '@ember/test-waiters'; import { task } from 'ember-concurrency'; import Features from 'ember-feature-flags/services/features'; -import appConfig from 'ember-get-config'; import Intl from 'ember-intl/services/intl'; import Toast from 'ember-toastr/services/toast'; import { layout, requiredAction } from 'ember-osf-web/decorators/component'; -import ProviderModel from 'ember-osf-web/models/provider'; +import RegistrationProviderModel from 'ember-osf-web/models/registration-provider'; import Analytics from 'ember-osf-web/services/analytics'; import captureException, { getApiErrorMessage } from 'ember-osf-web/utils/capture-exception'; @@ -19,12 +18,6 @@ import { SearchOptions } from 'registries/services/search'; import { ShareTermsFilter } from 'registries/services/share-search'; import template from './template'; -const { - featureFlagNames: { - enableInactiveSchemas, - }, -} = appConfig; - @layout(template) export default class RegistriesRegistrationTypeFacet extends Component { @service intl!: Intl; @@ -34,7 +27,7 @@ export default class RegistriesRegistrationTypeFacet extends Component { @service features!: Features; searchOptions!: SearchOptions; - provider?: ProviderModel; + provider?: RegistrationProviderModel; @requiredAction onSearchOptionsUpdated!: (options: SearchOptions) => void; registrationTypes: EmberArray = A([]); @@ -43,11 +36,14 @@ export default class RegistriesRegistrationTypeFacet extends Component { @waitFor async fetchRegistrationTypes() { try { - const metaschemas = await this.store.query('registration-schema', { + if (!this.provider){ + this.provider = await this.store.findRecord('registration-provider', 'osf'); + } + const metaschemas = await this.provider.queryHasMany('schemas', { 'page[size]': 100, }); const metaschemaNames = metaschemas.mapBy('name'); - if (!this.features.isEnabled(enableInactiveSchemas)) { + if (this.provider.id === 'osf') { 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 From bee84e1f9b2dd39b0afa03c29f8458afe7b3e9d7 Mon Sep 17 00:00:00 2001 From: Brian Geiger Date: Mon, 1 Nov 2021 10:49:23 -0400 Subject: [PATCH 2/2] Use defaultProvideId instead of bare string --- .../registries-registration-type-facet/component.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 69f92a5cf53..937e51c85f5 100644 --- a/lib/registries/addon/components/registries-registration-type-facet/component.ts +++ b/lib/registries/addon/components/registries-registration-type-facet/component.ts @@ -14,6 +14,7 @@ import RegistrationProviderModel from 'ember-osf-web/models/registration-provide import Analytics from 'ember-osf-web/services/analytics'; import captureException, { getApiErrorMessage } from 'ember-osf-web/utils/capture-exception'; +import registriesConfig from 'registries/config/environment'; import { SearchOptions } from 'registries/services/search'; import { ShareTermsFilter } from 'registries/services/share-search'; import template from './template'; @@ -35,15 +36,17 @@ export default class RegistriesRegistrationTypeFacet extends Component { @task({ on: 'init' }) @waitFor async fetchRegistrationTypes() { + const { defaultProviderId } = registriesConfig; + try { if (!this.provider){ - this.provider = await this.store.findRecord('registration-provider', 'osf'); + this.provider = await this.store.findRecord('registration-provider', defaultProviderId); } const metaschemas = await this.provider.queryHasMany('schemas', { 'page[size]': 100, }); const metaschemaNames = metaschemas.mapBy('name'); - if (this.provider.id === 'osf') { + if (this.provider.id === defaultProviderId) { 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