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
10 changes: 3 additions & 7 deletions src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,14 @@ export const routes: Routes = [
loadChildren: () => import('./features/registries/registries.routes').then((mod) => mod.registriesRoutes),
},
{
path: 'my-profile',
loadComponent: () =>
import('./features/profile/pages/my-profile/my-profile.component').then((mod) => mod.MyProfileComponent),
path: 'profile',
loadComponent: () => import('./features/profile/profile.component').then((mod) => mod.ProfileComponent),
providers: [provideStates([ProfileState])],
canActivate: [authGuard],
},
{
path: 'user/:id',
loadComponent: () =>
import('./features/profile/pages/user-profile/user-profile.component').then(
(mod) => mod.UserProfileComponent
),
loadComponent: () => import('./features/profile/profile.component').then((mod) => mod.ProfileComponent),
providers: [provideStates([ProfileState])],
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/components/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class HeaderComponent {
items = [
{
label: 'navigation.myProfile',
command: () => this.router.navigate(['my-profile']),
command: () => this.router.navigate(['profile']),
},
{ label: 'navigation.settings', command: () => this.router.navigate(['settings']) },
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/constants/nav-items.constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ export const MENU_ITEMS: MenuItem[] = [
},
{
id: 'my-profile',
routerLink: '/my-profile',
routerLink: '/profile',
label: 'navigation.profile',
icon: 'fas fa-user',
visible: false,
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/store/user/user.actions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Education, Employment, Social, User, UserSettings } from '@osf/shared/models';
import { Education, Employment, SocialModel, User, UserSettings } from '@osf/shared/models';

export class GetCurrentUser {
static readonly type = '[User] Get Current User';
Expand Down Expand Up @@ -36,7 +36,7 @@ export class UpdateProfileSettingsEducation {
export class UpdateProfileSettingsSocialLinks {
static readonly type = '[Profile Settings] Update Social Links';

constructor(public payload: Partial<Social>[]) {}
constructor(public payload: Partial<SocialModel>[]) {}
}

export class UpdateProfileSettingsUser {
Expand Down
4 changes: 2 additions & 2 deletions src/app/core/store/user/user.selectors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Selector } from '@ngxs/store';

import { Education, Employment, Social, User, UserSettings } from '@osf/shared/models';
import { Education, Employment, SocialModel, User, UserSettings } from '@osf/shared/models';

import { UserStateModel } from './user.model';
import { UserState } from './user.state';
Expand Down Expand Up @@ -54,7 +54,7 @@ export class UserSelectors {
}

@Selector([UserState])
static getSocialLinks(state: UserStateModel): Social | undefined {
static getSocialLinks(state: UserStateModel): SocialModel | undefined {
return state.currentUser.data?.social;
}

Expand Down
4 changes: 2 additions & 2 deletions src/app/core/store/user/user.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { inject, Injectable } from '@angular/core';
import { ProfileSettingsKey } from '@osf/shared/enums';
import { removeNullable } from '@osf/shared/helpers';
import { UserMapper } from '@osf/shared/mappers';
import { Social, User } from '@osf/shared/models';
import { SocialModel, User } from '@osf/shared/models';

import { UserService } from '../../services';

Expand Down Expand Up @@ -210,7 +210,7 @@ export class UserState {
return;
}

let social = {} as Partial<Social>;
let social = {} as Partial<SocialModel>;

payload.forEach((item) => {
social = {
Expand Down
15 changes: 2 additions & 13 deletions src/app/features/moderation/models/registry-json-api.model.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
import { RegistrationReviewStates, RevisionReviewStates } from '@osf/shared/enums';
import { ResponseJsonApi } from '@osf/shared/models';
import { RegistrationNodeAttributesJsonApi, ResponseJsonApi } from '@osf/shared/models';

export type RegistryResponseJsonApi = ResponseJsonApi<RegistryDataJsonApi[]>;

export interface RegistryDataJsonApi {
id: string;
attributes: RegistryAttributesJsonApi;
attributes: RegistrationNodeAttributesJsonApi;
embeds: RegistryEmbedsJsonApi;
}

export interface RegistryAttributesJsonApi {
id: string;
title: string;
revision_state: RevisionReviewStates;
reviews_state: RegistrationReviewStates;
public: boolean;
embargoed: boolean;
embargo_end_date: string;
}

export interface RegistryEmbedsJsonApi {
schema_responses: {
data: { id: string }[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface RegistryModeration {
reviewsState: RegistrationReviewStates;
public: boolean;
embargoed: boolean;
embargoEndDate?: string;
embargoEndDate: string | null;
actions: ReviewAction[];
revisionId?: string | null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h1>{{ currentUser()?.fullName }}</h1>
</p>
</div>

<div class="flex flex-column gap-4">
<div class="flex flex-column gap-4 xl:align-items-end">
<div class="flex flex-column gap-3 md:flex-row xl:gap-4">
@if (currentUser()?.social?.orcid) {
<div class="flex flex-row align-items-center gap-2">
Expand Down Expand Up @@ -61,54 +61,9 @@ <h3 class="font-bold">
}

<div class="flex flex-wrap align-items-center gap-3">
@if (currentUser()?.social?.github) {
<a class="cursor-pointer custom-light-hover" [href]="currentUser()?.social?.github">
<img ngSrc="assets/icons/socials/github.svg" width="24" height="24" alt="github" />
</a>
}
@if (currentUser()?.social?.scholar) {
<a class="cursor-pointer custom-light-hover" [href]="currentUser()?.social?.scholar">
<img ngSrc="assets/icons/socials/scholar.svg" width="24" height="24" alt="scholar" />
</a>
}
@if (currentUser()?.social?.twitter) {
<a class="cursor-pointer custom-light-hover" [href]="currentUser()?.social?.twitter">
<img ngSrc="assets/icons/socials/x.svg" width="24" height="24" alt="x(twitter)" />
</a>
}
@if (currentUser()?.social?.linkedIn) {
<a class="cursor-pointer custom-light-hover" [href]="currentUser()?.social?.linkedIn">
<img ngSrc="assets/icons/socials/linkedin.svg" width="24" height="24" alt="linkedin" />
</a>
}
@if (currentUser()?.social?.impactStory) {
<a class="cursor-pointer custom-light-hover" [href]="currentUser()?.social?.impactStory">
<img ngSrc="assets/icons/socials/impactstory.png" width="24" height="24" alt="impactstory" />
</a>
}
@if (currentUser()?.social?.baiduScholar) {
<a class="cursor-pointer custom-light-hover" [href]="currentUser()?.social?.baiduScholar">
<img ngSrc="assets/icons/socials/baidu.png" width="24" height="24" alt="baidu" />
</a>
}
@if (currentUser()?.social?.researchGate) {
<a class="cursor-pointer custom-light-hover" [href]="currentUser()?.social?.researchGate">
<img ngSrc="assets/icons/socials/researchGate.svg" width="24" height="24" alt="researchGate" />
</a>
}
@if (currentUser()?.social?.researcherId) {
<a class="cursor-pointer custom-light-hover" [href]="currentUser()?.social?.researcherId">
<img ngSrc="assets/icons/socials/researcherID.png" width="24" height="24" alt="researchId" />
</a>
}
@if (currentUser()?.social?.ssrn) {
<a class="cursor-pointer custom-light-hover" [href]="currentUser()?.social?.researcherId">
<img ngSrc="assets/icons/socials/ssrn.svg" width="24" height="24" alt="ssrn" />
</a>
}
@if (currentUser()?.social?.academiaProfileID) {
<a class="cursor-pointer custom-light-hover" [href]="currentUser()?.social?.academiaProfileID">
<img ngSrc="assets/icons/socials/academia.svg" width="24" height="24" alt="academia" />
@for (social of userSocials(); track social.alt) {
<a class="cursor-pointer custom-light-hover" [href]="social.url" target="_blank" rel="noopener noreferrer">
<img [ngSrc]="social.icon" width="24" height="24" [alt]="social.alt | translate" />
</a>
}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import { ChangeDetectionStrategy, Component, computed, inject, input, output } f
import { toSignal } from '@angular/core/rxjs-interop';

import { EducationHistoryComponent, EmploymentHistoryComponent } from '@osf/shared/components';
import { SOCIAL_LINKS } from '@osf/shared/constants';
import { IS_MEDIUM } from '@osf/shared/helpers';
import { User } from '@osf/shared/models';

import { mapUserSocials } from '../../helpers';

@Component({
selector: 'osf-profile-information',
imports: [Button, EmploymentHistoryComponent, EducationHistoryComponent, TranslatePipe, DatePipe, NgOptimizedImage],
Expand All @@ -28,6 +31,8 @@ export class ProfileInformationComponent {
() => this.currentUser()?.employment?.length || this.currentUser()?.education?.length
);

userSocials = computed(() => mapUserSocials(this.currentUser()?.social, SOCIAL_LINKS));

toProfileSettings() {
this.editProfile.emit();
}
Expand Down
1 change: 1 addition & 0 deletions src/app/features/profile/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './user-socials.helper';
39 changes: 39 additions & 0 deletions src/app/features/profile/helpers/user-socials.helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { SocialLinksModel, SocialLinkViewModel, SocialModel } from '@osf/shared/models';

export function mapUserSocials(
socialData: SocialModel | undefined,
socialLinks: SocialLinksModel[]
): SocialLinkViewModel[] {
if (!socialData) {
return [];
}

return socialLinks.reduce<SocialLinkViewModel[]>((acc, social) => {
const socialValue = socialData[social.key];

if (!socialValue || (Array.isArray(socialValue) && socialValue.length === 0)) {
return acc;
}

let url;
if (social.linkedField) {
const linkedValue = socialData[social.linkedField.key];
if (linkedValue) {
url = `${social.address}${socialValue}${social.linkedField.address}${linkedValue}`;
}
} else {
const value = Array.isArray(socialValue) ? socialValue[0] : socialValue;
url = social.address + value;
}

if (url && social.key !== 'profileWebsites') {
acc.push({
url,
icon: `assets/icons/socials/${social.icon}`,
alt: social.label,
});
}

return acc;
}, []);
}

This file was deleted.

This file was deleted.

44 changes: 0 additions & 44 deletions src/app/features/profile/pages/my-profile/my-profile.component.ts

This file was deleted.

This file was deleted.

Empty file.

This file was deleted.

Loading
Loading