-
Notifications
You must be signed in to change notification settings - Fork 394
Punchout Close Session button #20155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
927e59b
add button
FollowTheFlo c285f65
fix unit tests
FollowTheFlo 0371cb9
deps and checks fix
FollowTheFlo 6d5035b
deps and checks fix
FollowTheFlo af886ff
fix and checks
FollowTheFlo 82a3989
new logic
FollowTheFlo c14f032
fix typos
FollowTheFlo 360fd9f
fixes
FollowTheFlo 7934be8
remove empty lines
FollowTheFlo a8c1538
revert condition
FollowTheFlo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
@import '@spartacus/styles/scss/core'; | ||
@import 'styles/punchout-close-session'; | ||
@import 'styles/punchout-buttons'; | ||
|
||
$punchout-components-allowlist: cx-punchout-close-session, cx-punchout-buttons !default; | ||
|
||
$skipComponentStyles: () !default; | ||
|
||
@each $selector in $punchout-components-allowlist { | ||
#{$selector} { | ||
// skip selectors if they're added to the $skipComponentStyles list | ||
@if (index($skipComponentStyles, $selector) == null) { | ||
@extend %#{$selector} !optional; | ||
} | ||
} | ||
} | ||
|
||
// add body specific selectors | ||
body { | ||
@each $selector in $punchout-components-allowlist { | ||
@if (index($skipComponentStyles, $selector) == null) { | ||
@extend %#{$selector}__body !optional; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...ion-libs/punchout/components/punchout-close-session/punchout-close-session.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<ng-container *ngIf="(isPunchoutSessionActive$ | async) === true"> | ||
<div class="cx-punchout-close-session" (click)="clickCloseSessionButton()"> | ||
{{ 'punchout.closeSession' | cxTranslate }} | ||
</div> | ||
</ng-container> |
39 changes: 39 additions & 0 deletions
39
...ation-libs/punchout/components/punchout-close-session/punchout-close-session.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2025 SAP Spartacus team <[email protected]> | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { ChangeDetectionStrategy, Component, inject } from '@angular/core'; | ||
import { AuthService } from '@spartacus/core'; | ||
import { PunchoutFacade, PunchoutStoreService } from '@spartacus/punchout/root'; | ||
import { map, Observable, of, switchMap } from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'cx-punchout-close-session', | ||
templateUrl: './punchout-close-session.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: false, | ||
}) | ||
export class PunchoutCloseSessionComponent { | ||
protected punchoutStoreService = inject(PunchoutStoreService); | ||
protected authService = inject(AuthService); | ||
protected punchoutFacade = inject(PunchoutFacade); | ||
|
||
isPunchoutSessionActive$: Observable<boolean> = this.authService | ||
.isUserLoggedIn() | ||
.pipe( | ||
switchMap((isLoggedIn) => { | ||
return isLoggedIn | ||
? this.punchoutStoreService.getPunchoutState() | ||
: of({ punchoutSessionId: undefined }); | ||
}), | ||
map((punchoutState) => { | ||
return !!punchoutState.punchoutSessionId; | ||
}) | ||
); | ||
|
||
clickCloseSessionButton(): void { | ||
this.punchoutFacade.closePunchoutSession().subscribe(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this obs runs only once, no need to unsubscribe afterwards.