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
9 changes: 7 additions & 2 deletions src/app/core/guards/is-file.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export const isFileGuard: CanMatchFn = (route: Route, segments: UrlSegment[]) =>

const id = segments[0]?.path;
const isMetadataPath = segments[1]?.path === 'metadata';

const urlObj = new URL(window.location.href);
const viewOnly = urlObj.searchParams.get('view_only');
const extras = viewOnly ? { queryParams: { view_only: viewOnly } } : {};

if (!id) {
return false;
}
Expand All @@ -25,7 +30,7 @@ export const isFileGuard: CanMatchFn = (route: Route, segments: UrlSegment[]) =>
return true;
}
if (currentResource.parentId) {
router.navigate(['/', currentResource.parentId, 'files', id], { queryParamsHandling: 'preserve' });
router.navigate(['/', currentResource.parentId, 'files', id], extras);
return false;
}
}
Expand All @@ -45,7 +50,7 @@ export const isFileGuard: CanMatchFn = (route: Route, segments: UrlSegment[]) =>
return true;
}
if (resource.parentId) {
router.navigate(['/', resource.parentId, 'files', id], { queryParamsHandling: 'preserve' });
router.navigate(['/', resource.parentId, 'files', id], extras);
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ <h4>{{ 'files.detail.resourceMetadata.fields.dateModified' | translate }}</h4>
@if (isResourceContributorsLoading()) {
<p-skeleton width="100%" height="4rem" />
} @else {
@if (contributors().length && !hasViewOnly()) {
@if (hasViewOnly() || contributors().length) {
<div class="flex flex-column gap-2">
<h4>{{ 'common.labels.contributors' | translate }}</h4>

<osf-contributors-list [contributors]="contributors()"></osf-contributors-list>
<osf-contributors-list [contributors]="contributors()" [anonymous]="hasViewOnly()"></osf-contributors-list>
</div>
}
}
Expand Down
16 changes: 15 additions & 1 deletion src/app/features/metadata/services/metadata.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@ export class MetadataService {
'page[size]': 20,
};

// [NS] TODO: Check if it can be simplified
let cedarUrl = `${this.apiUrl}/${this.urlMap.get(resourceType)}/${resourceId}/cedar_metadata_records/`;

if (url) {
cedarUrl = `${url}cedar_metadata_records/`;
cedarUrl = this.getMetadataUrl(url);
}

return this.jsonApiService.get<CedarMetadataRecordJsonApi>(cedarUrl, params);
Expand Down Expand Up @@ -212,4 +214,16 @@ export class MetadataService {

return params;
}

private getMetadataUrl(url: string): string {
const parsedUrl = new URL(url);

if (!parsedUrl.pathname.endsWith('/')) {
parsedUrl.pathname += '/';
}

parsedUrl.pathname += 'cedar_metadata_records/';

return parsedUrl.toString();
}
}
2 changes: 1 addition & 1 deletion src/app/shared/constants/social-links.const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const SOCIAL_LINKS: SocialLinksModel[] = [
{
id: 2,
label: 'settings.profileSettings.social.labels.linkedIn',
address: 'https://linkedin.com/',
address: 'https://linkedin.com/in/',
placeholder: 'in/userID, profie/view?profileID, or pub/pubID',
key: 'linkedIn',
icon: 'linkedin.svg',
Expand Down
3 changes: 2 additions & 1 deletion src/app/shared/mappers/contributors/contributors.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export class ContributorsMapper {
}

static getContributor(response: ContributorDataJsonApi): ContributorModel {
const userEmbed = response.embeds.users;
const userEmbed = response.embeds?.users;

const errorMeta = userEmbed?.errors && userEmbed.errors.length > 0 ? userEmbed.errors[0]?.meta : null;
const userData = userEmbed?.data;

Expand Down
Loading