Skip to content

Commit d739b46

Browse files
authored
Feat/175 - Project Overview Linked Projects (#196)
* feat(project-overview-link-project): added link node functionality * feat(project-overview-link-project): changed action menu to trash icon button * feat(project-overview-link-project): fixed comments
1 parent f7e95ae commit d739b46

File tree

78 files changed

+1427
-529
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1427
-529
lines changed

src/app/core/constants/ngxs-states.constant.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { AuthState } from '@core/store/auth';
22
import { UserState } from '@core/store/user';
33
import { MeetingsState } from '@osf/features/meetings/store';
4-
import { MyProjectsState } from '@osf/features/my-projects/store';
54
import { ProjectMetadataState } from '@osf/features/project/metadata/store';
65
import { ProjectOverviewState } from '@osf/features/project/overview/store';
76
import { RegistrationsState } from '@osf/features/project/registrations/store';
@@ -13,11 +12,13 @@ import { AddonsState, InstitutionsState } from '@shared/stores';
1312
import { LicensesState } from '@shared/stores/licenses';
1413
import { RegionsState } from '@shared/stores/regions';
1514

15+
import { MyResourcesState } from 'src/app/shared/stores/my-resources';
16+
1617
export const STATES = [
1718
AuthState,
1819
AddonsState,
1920
UserState,
20-
MyProjectsState,
21+
MyResourcesState,
2122
InstitutionsState,
2223
DeveloperAppsState,
2324
AccountSettingsState,

src/app/features/home/home.component.spec.ts

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

10-
import { MyProjectsState } from '@osf/features/my-projects/store/my-projects.state';
10+
import { MyResourcesState } from '@shared/stores/my-resources/my-resources.state';
1111

1212
import { HomeComponent } from './home.component';
1313

@@ -22,7 +22,7 @@ describe('HomeComponent', () => {
2222
provideRouter([]),
2323
provideHttpClient(withFetch()),
2424
provideHttpClientTesting(),
25-
provideStore([MyProjectsState]),
25+
provideStore([MyResourcesState]),
2626
],
2727
}).compileComponents();
2828

src/app/features/home/home.component.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,19 @@ import { FormControl } from '@angular/forms';
1515
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
1616

1717
import { MY_PROJECTS_TABLE_PARAMS } from '@osf/core/constants';
18-
import { MyProjectsItem } from '@osf/features/my-projects/models';
1918
import { MyProjectsTableComponent, SubHeaderComponent } from '@osf/shared/components';
2019
import { SortOrder } from '@osf/shared/enums';
21-
import { TableParameters } from '@osf/shared/models';
20+
import { MyResourcesItem, MyResourcesSearchFilters, TableParameters } from '@osf/shared/models';
2221
import { IS_MEDIUM } from '@osf/shared/utils';
2322
import { FetchUserInstitutions } from '@shared/stores';
2423

2524
import { CreateProjectDialogComponent } from '../my-projects/components';
26-
import { MyProjectsSearchFilters } from '../my-projects/models';
27-
import { ClearMyProjects, GetMyProjects, MyProjectsSelectors } from '../my-projects/store';
2825
import { AccountSettingsService } from '../settings/account-settings/services';
2926

3027
import { ConfirmEmailComponent } from './components';
3128

29+
import { ClearMyResources, GetMyProjects, MyResourcesSelectors } from 'src/app/shared/stores/my-resources';
30+
3231
@Component({
3332
selector: 'osf-home',
3433
imports: [RouterLink, Button, SubHeaderComponent, MyProjectsTableComponent, TranslatePipe],
@@ -51,15 +50,15 @@ export class HomeComponent implements OnInit {
5150
protected readonly isMedium = toSignal(inject(IS_MEDIUM));
5251

5352
protected readonly searchControl = new FormControl<string>('');
54-
protected readonly activeProject = signal<MyProjectsItem | null>(null);
53+
protected readonly activeProject = signal<MyResourcesItem | null>(null);
5554
protected readonly sortColumn = signal<string | undefined>(undefined);
5655
protected readonly sortOrder = signal<SortOrder>(SortOrder.Asc);
5756
protected readonly tableParams = signal<TableParameters>({
5857
...MY_PROJECTS_TABLE_PARAMS,
5958
});
6059

61-
protected readonly projects = select(MyProjectsSelectors.getProjects);
62-
protected readonly totalProjectsCount = select(MyProjectsSelectors.getTotalProjects);
60+
protected readonly projects = select(MyResourcesSelectors.getProjects);
61+
protected readonly totalProjectsCount = select(MyResourcesSelectors.getTotalProjects);
6362

6463
protected readonly filteredProjects = computed(() => {
6564
const search = this.searchControl.value?.toLowerCase() ?? '';
@@ -159,7 +158,7 @@ export class HomeComponent implements OnInit {
159158

160159
setupCleanup(): void {
161160
this.destroyRef.onDestroy(() => {
162-
this.store.dispatch(new ClearMyProjects());
161+
this.store.dispatch(new ClearMyResources());
163162
});
164163
}
165164

@@ -180,7 +179,7 @@ export class HomeComponent implements OnInit {
180179
});
181180
}
182181

183-
createFilters(): MyProjectsSearchFilters {
182+
createFilters(): MyResourcesSearchFilters {
184183
return {
185184
searchValue: this.searchControl.value ?? '',
186185
searchFields: ['title'],
@@ -224,7 +223,7 @@ export class HomeComponent implements OnInit {
224223
}
225224
}
226225

227-
protected navigateToProject(project: MyProjectsItem): void {
226+
protected navigateToProject(project: MyResourcesItem): void {
228227
this.activeProject.set(project);
229228
this.router.navigate(['/my-projects', project.id]);
230229
}

src/app/features/my-projects/components/create-project-dialog/create-project-dialog.component.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ import { ChangeDetectionStrategy, Component, computed, inject, OnInit } from '@a
99
import { FormControl, FormGroup, Validators } from '@angular/forms';
1010

1111
import { MY_PROJECTS_TABLE_PARAMS } from '@core/constants';
12-
import { CreateProject, GetMyProjects, MyProjectsSelectors } from '@osf/features/my-projects/store';
1312
import { AddProjectFormComponent } from '@shared/components';
1413
import { ProjectFormControls } from '@shared/enums';
1514
import { IdName, ProjectForm } from '@shared/models';
1615
import { CustomValidators } from '@shared/utils';
1716

17+
import { CreateProject, GetMyProjects, MyResourcesSelectors } from 'src/app/shared/stores/my-resources';
18+
1819
@Component({
1920
selector: 'osf-create-project-dialog',
2021
imports: [AddProjectFormComponent, Button, TranslatePipe],
@@ -30,7 +31,7 @@ export class CreateProjectDialogComponent implements OnInit {
3031
createProject: CreateProject,
3132
});
3233

33-
private projects = select(MyProjectsSelectors.getProjects);
34+
private projects = select(MyResourcesSelectors.getProjects);
3435

3536
readonly templates = computed(() => {
3637
return this.projects().map(
@@ -41,7 +42,7 @@ export class CreateProjectDialogComponent implements OnInit {
4142
}) as IdName
4243
);
4344
});
44-
readonly isProjectSubmitting = select(MyProjectsSelectors.isProjectSubmitting);
45+
readonly isProjectSubmitting = select(MyResourcesSelectors.isProjectSubmitting);
4546

4647
readonly projectForm = new FormGroup<ProjectForm>({
4748
[ProjectFormControls.Title]: new FormControl('', {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { MyProjectsMapper } from './my-projects.mapper';
1+
export { MyResourcesMapper } from './my-resources.mapper';

src/app/features/my-projects/mappers/my-projects.mapper.ts renamed to src/app/features/my-projects/mappers/my-resources.mapper.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { MyProjectsItem, MyProjectsItemGetResponseJsonApi } from '../models';
1+
import { MyResourcesItem, MyResourcesItemGetResponseJsonApi } from 'src/app/shared/models/my-resources';
22

3-
export class MyProjectsMapper {
4-
static fromResponse(response: MyProjectsItemGetResponseJsonApi): MyProjectsItem {
3+
export class MyResourcesMapper {
4+
static fromResponse(response: MyResourcesItemGetResponseJsonApi): MyResourcesItem {
55
return {
66
id: response.id,
77
type: response.type,
88
title: response.attributes.title,
9+
dateCreated: response.attributes.date_created,
910
dateModified: response.attributes.date_modified,
1011
isPublic: response.attributes.public,
1112
contributors: response.embeds.bibliographic_contributors.data.map((contributor) => ({

src/app/features/my-projects/models/index.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/app/features/my-projects/models/my-projects-endpoint.type.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/app/features/my-projects/my-projects.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import { provideHttpClientTesting } from '@angular/common/http/testing';
1212
import { ComponentFixture, TestBed } from '@angular/core/testing';
1313
import { ActivatedRoute } from '@angular/router';
1414

15+
import { MyResourcesState } from '@shared/stores/my-resources/my-resources.state';
1516
import { IS_MEDIUM } from '@shared/utils';
1617

1718
import { InstitutionsState } from '../../shared/stores/institutions';
1819

19-
import { MyProjectsState } from './store/my-projects.state';
2020
import { MyProjectsComponent } from './my-projects.component';
2121

2222
describe('MyProjectsComponent', () => {
@@ -30,7 +30,7 @@ describe('MyProjectsComponent', () => {
3030
await TestBed.configureTestingModule({
3131
imports: [MyProjectsComponent, TranslateModule.forRoot()],
3232
providers: [
33-
provideStore([MyProjectsState, InstitutionsState]),
33+
provideStore([MyResourcesState, InstitutionsState]),
3434
provideHttpClient(),
3535
provideHttpClientTesting(),
3636
MockProvider(DialogService),

src/app/features/my-projects/my-projects.component.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@ import { IS_MEDIUM } from '@osf/shared/utils';
3434

3535
import { MY_PROJECTS_TABS } from './constants';
3636
import { MyProjectsTab } from './enums';
37-
import { MyProjectsItem, MyProjectsSearchFilters } from './models';
37+
38+
import { MyResourcesItem, MyResourcesSearchFilters } from 'src/app/shared/models/my-resources';
3839
import {
39-
ClearMyProjects,
40+
ClearMyResources,
4041
GetMyBookmarks,
4142
GetMyPreprints,
4243
GetMyProjects,
4344
GetMyRegistrations,
44-
MyProjectsSelectors,
45-
} from './store';
45+
MyResourcesSelectors,
46+
} from 'src/app/shared/stores/my-resources';
4647

4748
@Component({
4849
selector: 'osf-my-projects',
@@ -81,28 +82,28 @@ export class MyProjectsComponent implements OnInit {
8182
protected readonly currentPage = signal(1);
8283
protected readonly currentPageSize = signal(MY_PROJECTS_TABLE_PARAMS.rows);
8384
protected readonly selectedTab = signal(MyProjectsTab.Projects);
84-
protected readonly activeProject = signal<MyProjectsItem | null>(null);
85+
protected readonly activeProject = signal<MyResourcesItem | null>(null);
8586
protected readonly sortColumn = signal<string | undefined>(undefined);
8687
protected readonly sortOrder = signal<SortOrder>(SortOrder.Asc);
8788
protected readonly tableParams = signal<TableParameters>({
8889
...MY_PROJECTS_TABLE_PARAMS,
8990
firstRowIndex: 0,
9091
});
9192

92-
protected readonly projects = select(MyProjectsSelectors.getProjects);
93-
protected readonly registrations = select(MyProjectsSelectors.getRegistrations);
94-
protected readonly preprints = select(MyProjectsSelectors.getPreprints);
95-
protected readonly bookmarks = select(MyProjectsSelectors.getBookmarks);
96-
protected readonly totalProjectsCount = select(MyProjectsSelectors.getTotalProjects);
97-
protected readonly totalRegistrationsCount = select(MyProjectsSelectors.getTotalRegistrations);
98-
protected readonly totalPreprintsCount = select(MyProjectsSelectors.getTotalPreprints);
99-
protected readonly totalBookmarksCount = select(MyProjectsSelectors.getTotalBookmarks);
93+
protected readonly projects = select(MyResourcesSelectors.getProjects);
94+
protected readonly registrations = select(MyResourcesSelectors.getRegistrations);
95+
protected readonly preprints = select(MyResourcesSelectors.getPreprints);
96+
protected readonly bookmarks = select(MyResourcesSelectors.getBookmarks);
97+
protected readonly totalProjectsCount = select(MyResourcesSelectors.getTotalProjects);
98+
protected readonly totalRegistrationsCount = select(MyResourcesSelectors.getTotalRegistrations);
99+
protected readonly totalPreprintsCount = select(MyResourcesSelectors.getTotalPreprints);
100+
protected readonly totalBookmarksCount = select(MyResourcesSelectors.getTotalBookmarks);
100101

101102
protected readonly bookmarksCollectionId = select(BookmarksSelectors.getBookmarksCollectionId);
102103

103104
protected readonly actions = createDispatchMap({
104105
getBookmarksCollectionId: GetBookmarksCollectionId,
105-
clearMyProjects: ClearMyProjects,
106+
clearMyProjects: ClearMyResources,
106107
getMyProjects: GetMyProjects,
107108
getMyRegistrations: GetMyRegistrations,
108109
getMyPreprints: GetMyPreprints,
@@ -240,7 +241,7 @@ export class MyProjectsComponent implements OnInit {
240241
});
241242
}
242243

243-
createFilters(params: QueryParams): MyProjectsSearchFilters {
244+
createFilters(params: QueryParams): MyResourcesSearchFilters {
244245
return {
245246
searchValue: params.search || '',
246247
searchFields: ['title', 'tags', 'description'],
@@ -341,12 +342,12 @@ export class MyProjectsComponent implements OnInit {
341342
});
342343
}
343344

344-
protected navigateToProject(project: MyProjectsItem): void {
345+
protected navigateToProject(project: MyResourcesItem): void {
345346
this.activeProject.set(project);
346347
this.router.navigate(['/my-projects', project.id]);
347348
}
348349

349-
protected navigateToRegistry(registry: MyProjectsItem): void {
350+
protected navigateToRegistry(registry: MyResourcesItem): void {
350351
this.activeProject.set(registry);
351352
this.router.navigate(['/registries', registry.id]);
352353
}

0 commit comments

Comments
 (0)