Skip to content

Commit 323a6a1

Browse files
committed
feat(es2): Add waffle flags; revert changes and use cedar editor
1 parent b86b57e commit 323a6a1

8 files changed

Lines changed: 41 additions & 22 deletions

File tree

src/app/features/collections/components/add-to-collection/add-to-collection.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import { LoaderService } from '@osf/shared/services/loader.service';
4343
import { ToastService } from '@osf/shared/services/toast.service';
4444
import { CollectionsSelectors, GetCollectionProvider } from '@osf/shared/stores/collections';
4545
import { ProjectsSelectors, SetSelectedProject } from '@osf/shared/stores/projects';
46+
import { COLLECTION_SUBMISSION_WITH_CEDAR } from '@shared/constants/feature-flags.const';
4647

4748
import { AddToCollectionSteps } from '../../enums';
4849
import { RemoveCollectionSubmissionPayload } from '../../models/remove-collection-submission-payload.model';
@@ -105,6 +106,7 @@ export class AddToCollectionComponent implements CanDeactivateComponent {
105106
requiredMetadataTemplate = select(CollectionsSelectors.getRequiredMetadataTemplate);
106107
selectedProject = select(ProjectsSelectors.getSelectedProject);
107108
currentUser = select(UserSelectors.getCurrentUser);
109+
activeFlags = select(UserSelectors.getActiveFlags);
108110
currentCollectionSubmission = select(AddToCollectionSelectors.getCurrentCollectionSubmission);
109111
cedarRecords = select(MetadataSelectors.getCedarRecords);
110112

@@ -123,7 +125,9 @@ export class AddToCollectionComponent implements CanDeactivateComponent {
123125
isCollectionMetadataDisabled = computed(
124126
() => !this.selectedProject() || !this.projectMetadataSaved() || !this.projectContributorsSaved()
125127
);
126-
isCedarMode = computed(() => this.environment.collectionSubmissionWithCedar && !!this.requiredMetadataTemplate());
128+
isCedarMode = computed(
129+
() => this.activeFlags().includes(COLLECTION_SUBMISSION_WITH_CEDAR) && !!this.requiredMetadataTemplate()
130+
);
127131
existingCedarRecord = computed<CedarMetadataRecordData | null>(() => {
128132
const records = this.cedarRecords();
129133
const templateId = this.requiredMetadataTemplate()?.id;

src/app/features/collections/components/collections-discover/collections-discover.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ <h1 class="collections-heading flex align-items-center">{{ collectionProvider()?
3737
</div>
3838

3939
<div class="content-container flex-1">
40-
@if (useShareTroveSearch) {
40+
@if (useShareTroveSearch()) {
4141
@if (defaultSearchFiltersInitialized()) {
4242
<osf-global-search [searchControlInput]="searchControl" />
4343
}

src/app/features/collections/components/collections-discover/collections-discover.component.spec.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
88
import { ActivatedRoute } from '@angular/router';
99

1010
import { ENVIRONMENT } from '@core/provider/environment.provider';
11+
import { UserSelectors } from '@core/store/user';
1112
import { GlobalSearchComponent } from '@osf/shared/components/global-search/global-search.component';
1213
import { LoadingSpinnerComponent } from '@osf/shared/components/loading-spinner/loading-spinner.component';
1314
import { SearchInputComponent } from '@osf/shared/components/search-input/search-input.component';
@@ -99,6 +100,10 @@ function setup(options: SetupOptions = {}) {
99100
{ selector: CollectionsSelectors.getSearchText, value: '' },
100101
{ selector: CollectionsSelectors.getPageNumber, value: '1' },
101102
{ selector: CollectionsSelectors.getCollectionProviderLoading, value: false },
103+
{
104+
selector: UserSelectors.getActiveFlags,
105+
value: collectionSubmissionWithCedar ? ['collection_submission_with_cedar'] : [],
106+
},
102107
],
103108
}),
104109
],
@@ -130,7 +135,7 @@ describe('CollectionsDiscoverComponent', () => {
130135
});
131136

132137
it('should set useShareTroveSearch to false', () => {
133-
expect(component.useShareTroveSearch).toBe(false);
138+
expect(component.useShareTroveSearch()).toBe(false);
134139
});
135140

136141
it('should initialize with default values', () => {
@@ -199,7 +204,7 @@ describe('CollectionsDiscoverComponent', () => {
199204
describe('shtrove mode (collectionSubmissionWithCedar = true)', () => {
200205
it('should set useShareTroveSearch to true', () => {
201206
const { component } = setup({ collectionSubmissionWithCedar: true });
202-
expect(component.useShareTroveSearch).toBe(true);
207+
expect(component.useShareTroveSearch()).toBe(true);
203208
});
204209

205210
it('should initialize default search filters', () => {

src/app/features/collections/components/collections-discover/collections-discover.component.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { FormControl } from '@angular/forms';
2222
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
2323

2424
import { ENVIRONMENT } from '@core/provider/environment.provider';
25+
import { UserSelectors } from '@core/store/user';
2526
import { GlobalSearchComponent } from '@osf/shared/components/global-search/global-search.component';
2627
import { LoadingSpinnerComponent } from '@osf/shared/components/loading-spinner/loading-spinner.component';
2728
import { SearchInputComponent } from '@osf/shared/components/search-input/search-input.component';
@@ -41,6 +42,7 @@ import {
4142
SetSearchValue,
4243
} from '@osf/shared/stores/collections';
4344
import { ResetSearchState, SetDefaultFilterValue, SetExtraFilters } from '@osf/shared/stores/global-search';
45+
import { COLLECTION_SUBMISSION_WITH_CEDAR } from '@shared/constants/feature-flags.const';
4446

4547
import { CollectionsQuerySyncService } from '../../services';
4648
import { CollectionsHelpDialogComponent } from '../collections-help-dialog/collections-help-dialog.component';
@@ -78,7 +80,8 @@ export class CollectionsDiscoverComponent {
7880
providerId = signal<string>('');
7981
defaultSearchFiltersInitialized = signal(false);
8082

81-
readonly useShareTroveSearch = this.environment.collectionSubmissionWithCedar;
83+
activeFlags = select(UserSelectors.getActiveFlags);
84+
readonly useShareTroveSearch = computed(() => this.activeFlags().includes(COLLECTION_SUBMISSION_WITH_CEDAR));
8285

8386
collectionProvider = select(CollectionsSelectors.getCollectionProvider);
8487
collectionDetails = select(CollectionsSelectors.getCollectionDetails);
@@ -106,20 +109,16 @@ export class CollectionsDiscoverComponent {
106109
constructor() {
107110
this.initializeProvider();
108111
this.setupBrandingEffect();
109-
110-
if (this.useShareTroveSearch) {
111-
this.setupShareTroveSearchEffect();
112-
} else {
113-
this.setupCollectionDetailsEffect();
114-
this.setupUrlSyncEffect();
115-
this.setupLegacySearchEffect();
116-
this.setupSearchBinding();
117-
}
112+
this.setupShareTroveSearchEffect();
113+
this.setupCollectionDetailsEffect();
114+
this.setupUrlSyncEffect();
115+
this.setupLegacySearchEffect();
116+
this.setupSearchBinding();
118117

119118
this.destroyRef.onDestroy(() => {
120119
if (this.isBrowser) {
121120
this.actions.clearCollections();
122-
if (this.useShareTroveSearch) {
121+
if (this.useShareTroveSearch()) {
123122
this.actions.resetSearchState();
124123
}
125124
this.headerStyleHelper.resetToDefaults();
@@ -133,7 +132,7 @@ export class CollectionsDiscoverComponent {
133132
}
134133

135134
onSearchTriggered(searchValue: string): void {
136-
if (!this.useShareTroveSearch) {
135+
if (!this.useShareTroveSearch()) {
137136
this.actions.setSearchValue(searchValue);
138137
this.actions.setPageNumber('1');
139138
}
@@ -166,7 +165,7 @@ export class CollectionsDiscoverComponent {
166165
const provider = this.collectionProvider();
167166
const collectionId = this.primaryCollectionId();
168167

169-
if (!provider || !collectionId || this.defaultSearchFiltersInitialized()) return;
168+
if (!this.useShareTroveSearch() || !provider || !collectionId || this.defaultSearchFiltersInitialized()) return;
170169

171170
const collectionIri = `${this.environment.apiDomainUrl}/v2/collections/${collectionId}/`;
172171
this.actions.setDefaultFilterValue('isContainedBy', collectionIri);
@@ -184,6 +183,8 @@ export class CollectionsDiscoverComponent {
184183

185184
private setupCollectionDetailsEffect(): void {
186185
effect(() => {
186+
if (this.useShareTroveSearch()) return;
187+
187188
const collectionId = this.primaryCollectionId();
188189
if (collectionId) {
189190
this.actions.getCollectionDetails(collectionId);
@@ -192,9 +193,10 @@ export class CollectionsDiscoverComponent {
192193
}
193194

194195
private setupUrlSyncEffect(): void {
195-
this.querySyncService.initializeFromUrl();
196-
197196
effect(() => {
197+
if (this.useShareTroveSearch()) return;
198+
this.querySyncService.initializeFromUrl();
199+
198200
const searchText = this.searchText();
199201
const sortBy = this.sortBy();
200202
const selectedFilters = this.selectedFilters();
@@ -208,6 +210,8 @@ export class CollectionsDiscoverComponent {
208210

209211
private setupLegacySearchEffect(): void {
210212
effect(() => {
213+
if (this.useShareTroveSearch()) return;
214+
211215
const searchText = this.searchText();
212216
const sortBy = this.sortBy();
213217
const selectedFilters = this.selectedFilters();

src/app/features/metadata/metadata.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
[isProjectSubmissionsLoading]="isProjectSubmissionsLoading()"
7474
[cedarRecords]="cedarRecords()"
7575
[cedarTemplates]="cedarTemplates()?.data ?? null"
76-
[isCedarMode]="collectionSubmissionWithCedar"
76+
[isCedarMode]="collectionSubmissionWithCedar()"
7777
/>
7878
}
7979
</div>

src/app/features/metadata/metadata.component.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
1919
import { ActivatedRoute, Router } from '@angular/router';
2020

2121
import { ENVIRONMENT } from '@core/provider/environment.provider';
22+
import { UserSelectors } from '@core/store/user';
2223
import { MetadataTabsComponent } from '@osf/shared/components/metadata-tabs/metadata-tabs.component';
2324
import { SubHeaderComponent } from '@osf/shared/components/sub-header/sub-header.component';
2425
import { MetadataResourceEnum } from '@osf/shared/enums/metadata-resource.enum';
@@ -47,6 +48,7 @@ import {
4748
SubjectsSelectors,
4849
UpdateResourceSubjects,
4950
} from '@osf/shared/stores/subjects';
51+
import { COLLECTION_SUBMISSION_WITH_CEDAR } from '@shared/constants/feature-flags.const';
5052
import { MetadataTabsModel } from '@shared/models/metadata-tabs.model';
5153
import { SubjectModel } from '@shared/models/subject/subject.model';
5254

@@ -128,7 +130,10 @@ export class MetadataComponent implements OnInit, OnDestroy {
128130
private readonly environment = inject(ENVIRONMENT);
129131
private readonly signpostingService = inject(SignpostingService);
130132

131-
readonly collectionSubmissionWithCedar = this.environment.collectionSubmissionWithCedar;
133+
activeFlags = select(UserSelectors.getActiveFlags);
134+
readonly collectionSubmissionWithCedar = computed(() =>
135+
this.activeFlags().includes(COLLECTION_SUBMISSION_WITH_CEDAR)
136+
);
132137

133138
private resourceId = '';
134139

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const COLLECTION_SUBMISSION_WITH_CEDAR = 'collection_submission_with_cedar';

src/app/shared/services/collections.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class CollectionsService {
5656
private actions = createDispatchMap({ setTotalSubmissions: SetTotalSubmissions });
5757

5858
getCollectionProvider(collectionName: string): Observable<CollectionProvider> {
59-
const url = `${this.apiUrl}/providers/collections/${collectionName}/?embed=brand,required_metadata_template`;
59+
const url = `${this.apiUrl}/providers/collections/${collectionName}/?embed=brand&embed=required_metadata_template`;
6060

6161
return this.jsonApiService
6262
.get<JsonApiResponse<CollectionProviderResponseJsonApi, null>>(url)

0 commit comments

Comments
 (0)