Skip to content

Commit f74b035

Browse files
chore(intranet-header-workspace): remove user image logic (#4667) (#4821)
Co-authored-by: Alizé Debray <[email protected]>
1 parent 65af17b commit f74b035

File tree

4 files changed

+33
-31
lines changed

4 files changed

+33
-31
lines changed

.changeset/gentle-shoes-joke.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@swisspost/design-system-intranet-header': patch
3+
'@swisspost/design-system-documentation': patch
4+
---
5+
6+
Removed the user profile image from the intranet header due to loading issues from SharePoint, which were causing missing image errors. The header now displays a default user avatar.

packages/documentation/src/stories/components/intranet-header/intranet-header.docs.mdx

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,26 @@ import PostComponentDemoLink from '@/shared/post-component-demo-link.mdx';
2020

2121
<div className="alert alert-info alert-md">
2222
<h2 className="alert-heading">Angular only component</h2>
23-
<p>The intranet header is an <a href="//Angular.io">Angular</a> component, as such it only works
24-
within Angular projects.</p>
23+
<p>
24+
The intranet header is an <a href="//Angular.io">Angular</a> component, as such it only works
25+
within Angular projects.
26+
</p>
2527
</div>
2628

2729
The Header Angular component for internal usage.
2830

2931
For installation and usage see the <a href="/?path=/docs/7068be42-1a20-4a34-9e79-7fb7f9f2940f--docs">intranet-header package getting started page</a>
3032

33+
<div className="alert alert-warning mb-4">
34+
<h2 className="alert-heading">User profile image removed</h2>
35+
<p>
36+
With the new profile image URL now pointing to SharePoint, the image would not load unless the
37+
user had already authenticated against SharePoint in the browser. To address this issue, the
38+
logic for individual user profile images was temporarily removed, and the default avatar image
39+
is displayed instead.
40+
</p>
41+
</div>
42+
3143
## Examples
3244

3345
<PostTabs>
@@ -36,15 +48,15 @@ For installation and usage see the <a href="/?path=/docs/7068be42-1a20-4a34-9e79
3648
<Source code={SampleNavigationBar} language="html" />
3749
</PostTabPanel>
3850

39-
<PostTabHeader panel="headerWithCustomUserMenu">Header with a custom user menu</PostTabHeader>
40-
<PostTabPanel name="headerWithCustomUserMenu">
41-
<Source code={SampleSideUserMenuDropdown} language="html" />
42-
</PostTabPanel>
51+
<PostTabHeader panel="headerWithCustomUserMenu">Header with a custom user menu</PostTabHeader>
52+
<PostTabPanel name="headerWithCustomUserMenu">
53+
<Source code={SampleSideUserMenuDropdown} language="html" />
54+
</PostTabPanel>
4355

44-
<PostTabHeader panel="headerSideNavigation">Header with a side navigation</PostTabHeader>
45-
<PostTabPanel name="headerSideNavigation">
46-
<Source code={SampleSideNavigation} language="html" />
47-
</PostTabPanel>
56+
<PostTabHeader panel="headerSideNavigation">Header with a side navigation</PostTabHeader>
57+
<PostTabPanel name="headerSideNavigation">
58+
<Source code={SampleSideNavigation} language="html" />
59+
</PostTabPanel>
4860

4961
<PostTabHeader panel="headerPostweb">"Postweb" intranet header</PostTabHeader>
5062
<PostTabPanel name="headerPostweb">

packages/documentation/src/stories/components/intranet-header/intranet-header.stories.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ const meta: MetaComponent = {
3333
"The email address of the currently logged on user, used to display the user's profile picture." +
3434
'<p class="alert alert-info alert-sm">By default, a fallback image is displayed.</p>' +
3535
'<div class="mt-3 alert alert-warning alert-sm">' +
36-
'<div class="alert-heading">The required input value has recently changed</div>' +
37-
'<p>Due to the technical conversion of the intranet backend from Sitecore to Sharepoint, the value required for the property to display a user image has changed. Previously the user ID was required, now this property expects the user-specific e-mail address.</p>' +
36+
'<div class="alert-heading">Temporary removal of user specific profile image</div>' +
37+
'<p>Due to the technical conversion of the intranet backend from Sitecore to Sharepoint, this property has been changed to use the user-specific email address instead of a user ID to display the user image. However, the image would only load if the user had already authenticated against SharePoint in the browser. To address this issue, the logic for individual user profile images has been temporarily removed and thus the `currentUserId` is not currently used.</p>' +
3838
'</div>',
3939
control: 'text',
4040
table: {

packages/intranet-header-workspace/projects/intranet-header/src/lib/swisspost-intranet-header.component.ts

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ import {
66
Input,
77
LOCALE_ID,
88
NgZone,
9-
OnChanges,
109
OnInit,
1110
SecurityContext,
12-
SimpleChanges,
1311
TemplateRef,
1412
ViewChild,
1513
} from '@angular/core';
16-
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
14+
import { DomSanitizer } from '@angular/platform-browser';
1715
import { NavigationStart, Router } from '@angular/router';
1816
import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap';
1917
import { fromEvent, Subject } from 'rxjs';
@@ -25,7 +23,7 @@ import { userImage } from './user';
2523
templateUrl: './swisspost-intranet-header.component.html',
2624
styleUrls: ['./swisspost-intranet-header.component.scss'],
2725
})
28-
export class SwissPostIntranetHeaderComponent implements OnInit, OnChanges, AfterViewInit {
26+
export class SwissPostIntranetHeaderComponent implements OnInit, AfterViewInit {
2927
@Input() siteTitle: string = '';
3028
@Input() languages = 'de,fr,it,en';
3129
@Input() currentUserId: string = '';
@@ -45,7 +43,7 @@ export class SwissPostIntranetHeaderComponent implements OnInit, OnChanges, Afte
4543
optionDropdownElement!: ElementRef<HTMLElement>;
4644

4745
appLangs!: string[];
48-
avatarUrl = this.createSafeAvatarUrl();
46+
avatarUrl = userImage;
4947
openedMenu = false;
5048
openedLangChooser = false;
5149
openedMenuOverflow = false;
@@ -127,12 +125,6 @@ export class SwissPostIntranetHeaderComponent implements OnInit, OnChanges, Afte
127125
}
128126
}
129127

130-
ngOnChanges(changes: SimpleChanges) {
131-
if (changes['currentUserId']) {
132-
this.avatarUrl = this.createSafeAvatarUrl();
133-
}
134-
}
135-
136128
ngAfterViewInit(): void {
137129
// this check is needed, because it would add another element when a link from within "#overflow" is clicked
138130
if (this.dom.nativeElement.querySelector('#more') == null) {
@@ -333,14 +325,6 @@ export class SwissPostIntranetHeaderComponent implements OnInit, OnChanges, Afte
333325
return this.lang.toLowerCase() === lang.toLowerCase();
334326
}
335327

336-
private createSafeAvatarUrl(): SafeUrl {
337-
return this.currentUserId === ''
338-
? userImage
339-
: `https://postchag.sharepoint.com/_layouts/15/userphoto.aspx?size=S&username=${encodeURIComponent(
340-
this.currentUserId,
341-
)}`;
342-
}
343-
344328
private updateMoreElementText() {
345329
const languageField = this.dom.nativeElement.querySelector('#more > span');
346330

0 commit comments

Comments
 (0)