Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ export const routes: Routes = [
},
{
path: 'addons',
loadComponent: () =>
import('./features/project/addons/addons.component').then((mod) => mod.AddonsComponent),
loadChildren: () =>
import('./features/project/addons/constants/addons.routes').then((mod) => mod.addonsRoutes),
},
],
},
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/constants/ngxs-states.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import { RegistrationsState } from '@osf/features/project/registrations/store';
import { SettingsState } from '@osf/features/project/settings/store';
import { WikiState } from '@osf/features/project/wiki/store/wiki.state';
import { AccountSettingsState } from '@osf/features/settings/account-settings/store/account-settings.state';
import { AddonsState } from '@osf/features/settings/addons/store';
import { DeveloperAppsState } from '@osf/features/settings/developer-apps/store';
import { NotificationSubscriptionState } from '@osf/features/settings/notifications/store';
import { ProfileSettingsState } from '@osf/features/settings/profile-settings/store/profile-settings.state';
import { TokensState } from '@osf/features/settings/tokens/store';
import { AddonsState } from '@shared/stores/addons';

export const STATES = [
AuthState,
Expand Down
1 change: 0 additions & 1 deletion src/app/core/interceptors/auth.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export const authInterceptor: HttpInterceptorFn = (
next: HttpHandlerFn
): Observable<HttpEvent<unknown>> => {
const authToken = 'UlO9O9GNKgVzJD7pUeY53jiQTKJ4U2znXVWNvh0KZQruoENuILx0IIYf9LoDz7Duq72EIm';
// OBJoUomBgbUuDgQo5JoaSKNya6XaYcd0ojAX1XOLmWi6J2arQPzByxyEi81fHE60drQUWv
// UlO9O9GNKgVzJD7pUeY53jiQTKJ4U2znXVWNvh0KZQruoENuILx0IIYf9LoDz7Duq72EIm kyrylo
// 2rjFZwmdDG4rtKj7hGkEMO6XyHBM2lN7XBbsA1e8OqcFhOWu6Z7fQZiheu9RXtzSeVrgOt roman nastyuk

Expand Down
2 changes: 1 addition & 1 deletion src/app/core/store/user/user.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { AsyncStateModel } from '@shared/models/store';
import { User, UserSettings } from '../../models';

export interface UserStateModel {
currentUser: User | null;
currentUser: AsyncStateModel<User | null>;
currentUserSettings: AsyncStateModel<UserSettings | null>;
}
27 changes: 16 additions & 11 deletions src/app/core/store/user/user.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,28 @@ import { Social } from '@osf/shared/models';
export class UserSelectors {
@Selector([UserState])
static getCurrentUser(state: UserStateModel): User | null {
return state.currentUser;
return state.currentUser.data;
}

@Selector([UserState])
static getCurrentUserLoading(state: UserStateModel): boolean {
return state.currentUser.isLoading;
}

@Selector([UserState])
static getProfileSettings(state: UserStateModel): ProfileSettingsStateModel {
return {
education: state.currentUser?.education ?? [],
employment: state.currentUser?.employment ?? [],
social: state.currentUser?.social ?? ({} as Social),
education: state.currentUser.data?.education ?? [],
employment: state.currentUser.data?.employment ?? [],
social: state.currentUser.data?.social ?? ({} as Social),
user: {
middleNames: state.currentUser?.middleNames ?? '',
suffix: state.currentUser?.suffix ?? '',
id: state.currentUser?.id ?? '',
fullName: state.currentUser?.fullName ?? '',
email: state.currentUser?.email ?? '',
givenName: state.currentUser?.givenName ?? '',
familyName: state.currentUser?.familyName ?? '',
middleNames: state.currentUser.data?.middleNames ?? '',
suffix: state.currentUser.data?.suffix ?? '',
id: state.currentUser.data?.id ?? '',
fullName: state.currentUser.data?.fullName ?? '',
email: state.currentUser.data?.email ?? '',
givenName: state.currentUser.data?.givenName ?? '',
familyName: state.currentUser.data?.familyName ?? '',
},
} satisfies ProfileSettingsStateModel;
}
Expand Down
25 changes: 22 additions & 3 deletions src/app/core/store/user/user.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import { UserStateModel } from './user.model';
@State<UserStateModel>({
name: 'user',
defaults: {
currentUser: null,
currentUser: {
data: null,
isLoading: false,
error: null,
},
currentUserSettings: {
data: null,
isLoading: false,
Expand All @@ -30,10 +34,21 @@ export class UserState {

@Action(GetCurrentUser)
getCurrentUser(ctx: StateContext<UserStateModel>) {
ctx.patchState({
currentUser: {
...ctx.getState().currentUser,
isLoading: true,
},
});

return this.userService.getCurrentUser().pipe(
tap((user) => {
ctx.patchState({
currentUser: user,
currentUser: {
data: user,
isLoading: false,
error: null,
},
});
ctx.dispatch(new SetupProfileSettings());
})
Expand All @@ -43,7 +58,11 @@ export class UserState {
@Action(SetCurrentUser)
setCurrentUser(ctx: StateContext<UserStateModel>, action: SetCurrentUser) {
ctx.patchState({
currentUser: action.user,
currentUser: {
data: action.user,
isLoading: false,
error: null,
},
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>add-to-collection-form works!</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { AddToCollectionFormComponent } from './add-to-collection-form.component';

describe('AddToCollectionFormComponent', () => {
let component: AddToCollectionFormComponent;
let fixture: ComponentFixture<AddToCollectionFormComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AddToCollectionFormComponent],
}).compileComponents();

fixture = TestBed.createComponent(AddToCollectionFormComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';

@Component({
selector: 'osf-add-to-collection-form',
imports: [],
templateUrl: './add-to-collection-form.component.html',
styleUrl: './add-to-collection-form.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AddToCollectionFormComponent {}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { CollectionsMainContentComponent } from './collections-main-content.component';
4 changes: 2 additions & 2 deletions src/app/features/my-projects/mappers/my-projects.mapper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MyProjectsItem, MyProjectsItemGetResponse } from '../models';
import { MyProjectsItem, MyProjectsItemGetResponseJsonApi } from '../models';

export class MyProjectsMapper {
static fromResponse(response: MyProjectsItemGetResponse): MyProjectsItem {
static fromResponse(response: MyProjectsItemGetResponseJsonApi): MyProjectsItem {
return {
id: response.id,
type: response.type,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface CreateProjectPayload {
export interface CreateProjectPayloadJsoApi {
data: {
type: 'nodes';
attributes: {
Expand Down
6 changes: 3 additions & 3 deletions src/app/features/my-projects/models/my-projects.models.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { JsonApiResponse } from '@osf/core/models';

export interface MyProjectsItemGetResponse {
export interface MyProjectsItemGetResponseJsonApi {
id: string;
type: string;
attributes: {
Expand Down Expand Up @@ -50,7 +50,7 @@ export interface MyProjectsItem {
contributors: MyProjectsContributor[];
}

export interface MyProjectsItemResponse {
export interface MyProjectsItemResponseJsonApi {
data: MyProjectsItem[];
links: {
meta: {
Expand All @@ -60,7 +60,7 @@ export interface MyProjectsItemResponse {
};
}

export interface MyProjectsJsonApiResponse extends JsonApiResponse<MyProjectsItemGetResponse[], null> {
export interface MyProjectsResponseJsonApi extends JsonApiResponse<MyProjectsItemGetResponseJsonApi[], null> {
links: {
meta: {
total: number;
Expand Down
28 changes: 14 additions & 14 deletions src/app/features/my-projects/services/my-projects.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import { NodeResponseModel, UpdateNodeRequestModel } from '@shared/models';

import { MyProjectsMapper } from '../mappers';
import {
CreateProjectPayload,
CreateProjectPayloadJsoApi,
EndpointType,
MyProjectsItem,
MyProjectsItemGetResponse,
MyProjectsItemResponse,
MyProjectsJsonApiResponse,
MyProjectsItemGetResponseJsonApi,
MyProjectsItemResponseJsonApi,
MyProjectsResponseJsonApi,
MyProjectsSearchFilters,
} from '../models';

Expand All @@ -38,7 +38,7 @@ export class MyProjectsService {
filters?: MyProjectsSearchFilters,
pageNumber?: number,
pageSize?: number
): Observable<MyProjectsItemResponse> {
): Observable<MyProjectsItemResponseJsonApi> {
const params: Record<string, unknown> = {
'embed[]': ['bibliographic_contributors'],
[`fields[${endpoint}]`]: 'title,date_modified,public,bibliographic_contributors',
Expand Down Expand Up @@ -69,9 +69,9 @@ export class MyProjectsService {
? environment.apiUrl + '/' + endpoint
: environment.apiUrl + '/users/me/' + endpoint;

return this.jsonApiService.get<MyProjectsJsonApiResponse>(url, params).pipe(
map((response: MyProjectsJsonApiResponse) => ({
data: response.data.map((item: MyProjectsItemGetResponse) => MyProjectsMapper.fromResponse(item)),
return this.jsonApiService.get<MyProjectsResponseJsonApi>(url, params).pipe(
map((response: MyProjectsResponseJsonApi) => ({
data: response.data.map((item: MyProjectsItemGetResponseJsonApi) => MyProjectsMapper.fromResponse(item)),
links: response.links,
}))
);
Expand All @@ -81,7 +81,7 @@ export class MyProjectsService {
filters?: MyProjectsSearchFilters,
pageNumber?: number,
pageSize?: number
): Observable<MyProjectsItemResponse> {
): Observable<MyProjectsItemResponseJsonApi> {
return this.getMyItems('nodes', filters, pageNumber, pageSize);
}

Expand All @@ -104,15 +104,15 @@ export class MyProjectsService {
filters?: MyProjectsSearchFilters,
pageNumber?: number,
pageSize?: number
): Observable<MyProjectsItemResponse> {
): Observable<MyProjectsItemResponseJsonApi> {
return this.getMyItems('registrations', filters, pageNumber, pageSize);
}

getMyPreprints(
filters?: MyProjectsSearchFilters,
pageNumber?: number,
pageSize?: number
): Observable<MyProjectsItemResponse> {
): Observable<MyProjectsItemResponseJsonApi> {
return this.getMyItems('preprints', filters, pageNumber, pageSize);
}

Expand All @@ -121,7 +121,7 @@ export class MyProjectsService {
filters?: MyProjectsSearchFilters,
pageNumber?: number,
pageSize?: number
): Observable<MyProjectsItemResponse> {
): Observable<MyProjectsItemResponseJsonApi> {
return this.getMyItems(`collections/${collectionId}/linked_nodes/`, filters, pageNumber, pageSize);
}

Expand All @@ -132,7 +132,7 @@ export class MyProjectsService {
region: string,
affiliations: string[]
): Observable<MyProjectsItem> {
const payload: CreateProjectPayload = {
const payload: CreateProjectPayloadJsoApi = {
data: {
type: 'nodes',
attributes: {
Expand Down Expand Up @@ -167,7 +167,7 @@ export class MyProjectsService {
};

return this.jsonApiService
.post<MyProjectsItemGetResponse>(`${environment.apiUrl}/nodes/`, payload, params)
.post<MyProjectsItemGetResponseJsonApi>(`${environment.apiUrl}/nodes/`, payload, params)
.pipe(map((response) => MyProjectsMapper.fromResponse(response)));
}

Expand Down
Loading