From 62f6923e7e2682e47ab8cb625b42b5c0e10bf1a5 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Thu, 6 Nov 2025 15:25:04 +0200 Subject: [PATCH] UI: Add function to hidden GitHub badge --- .../github-badge/github-badge.component.html | 17 ++++-- .../github-badge/github-badge.component.scss | 23 ++++++-- .../github-badge/github-badge.component.ts | 57 +++++++++++++++++-- ui-ngx/src/styles.scss | 3 - 4 files changed, 83 insertions(+), 17 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/github-badge/github-badge.component.html b/ui-ngx/src/app/modules/home/components/github-badge/github-badge.component.html index 6bcab29793..67ec4c7a7d 100644 --- a/ui-ngx/src/app/modules/home/components/github-badge/github-badge.component.html +++ b/ui-ngx/src/app/modules/home/components/github-badge/github-badge.component.html @@ -17,10 +17,19 @@ --> @if (githubStar > 0) {
- - mdi:github -
GitHubstar{{ githubStar | number }}
-
+
} diff --git a/ui-ngx/src/app/modules/home/components/github-badge/github-badge.component.scss b/ui-ngx/src/app/modules/home/components/github-badge/github-badge.component.scss index ee1d306f07..08e130f7ec 100644 --- a/ui-ngx/src/app/modules/home/components/github-badge/github-badge.component.scss +++ b/ui-ngx/src/app/modules/home/components/github-badge/github-badge.component.scss @@ -20,16 +20,31 @@ --mat-outlined-button-horizontal-padding: 8px; --mdc-outlined-button-container-height: 30px; --mdc-outlined-button-label-text-size: 12px; + --mat-outlined-button-hover-state-layer-opacity: 0; + --mat-icon-button-hover-state-layer-opacity: 0; - .mdc-button { - background-color: rgba(255, 255, 255, 0.12); + .group { + .mdc-button { + background-color: rgba(255, 255, 255, 0.12); + } &:hover { - background-color: rgba(255, 255, 255, 0.20); + .mdc-button { + background-color: rgba(255, 255, 255, 0.20); + } + } + + .mdc-icon-button { + background-color: #162C41; + + &:hover { + background-color: #DD2C00; + } } } .button-label { - margin-top: 1px; + height: 28px; + --mat-divider-color: var(--mdc-outlined-button-label-text-color); } } diff --git a/ui-ngx/src/app/modules/home/components/github-badge/github-badge.component.ts b/ui-ngx/src/app/modules/home/components/github-badge/github-badge.component.ts index da46d492c0..b561054d10 100644 --- a/ui-ngx/src/app/modules/home/components/github-badge/github-badge.component.ts +++ b/ui-ngx/src/app/modules/home/components/github-badge/github-badge.component.ts @@ -14,21 +14,66 @@ /// limitations under the License. /// -import { Component } from '@angular/core'; +import { Component, OnDestroy } from '@angular/core'; import { GitHubService } from '@core/http/git-hub.service'; +import { Store } from '@ngrx/store'; +import { selectAuthUser, selectIsAuthenticated } from '@core/auth/auth.selectors'; +import { distinctUntilChanged, filter, map, switchMap, take, takeUntil } from 'rxjs/operators'; +import { Authority } from '@shared/models/authority.enum'; +import { AppState } from '@core/core.state'; +import { LocalStorageService } from '@core/local-storage/local-storage.service'; +import { Subject } from 'rxjs'; + +const SETTINGS_KEY = 'HIDE_GITHUB_STAR_BUTTON'; @Component({ selector: 'tb-github-badge', templateUrl: './github-badge.component.html', styleUrl: './github-badge.component.scss' }) -export class GithubBadgeComponent { +export class GithubBadgeComponent implements OnDestroy { githubStar = 0; - constructor(private gitHubService: GitHubService) { - this.gitHubService.getGitHubStar().subscribe(star => { - this.githubStar = star; - }); + private stopWatch$ = new Subject(); + + constructor(private gitHubService: GitHubService, + private localStorageService: LocalStorageService, + private store: Store,) { + const hide = this.localStorageService.getItem(SETTINGS_KEY) ?? false; + + if (!hide) { + this.store.select(selectIsAuthenticated).pipe( + filter((data) => data), + switchMap(() => this.store.select(selectAuthUser).pipe(take(1))), + map((authUser) => { + return [Authority.TENANT_ADMIN, Authority.SYS_ADMIN].includes(authUser?.authority ?? Authority.ANONYMOUS) + }), + distinctUntilChanged(), + takeUntil(this.stopWatch$), + ).subscribe(value => { + if (value) { + this.gitHubService.getGitHubStar().subscribe(star => { + this.githubStar = star; + }); + } else { + this.githubStar = 0 + } + }); + } + } + + hideGithubStar($event: Event) { + $event?.stopPropagation(); + this.localStorageService.setItem(SETTINGS_KEY, true); + this.githubStar = 0; + + this.stopWatch$.next(); + this.stopWatch$.complete(); + } + + ngOnDestroy() { + this.stopWatch$.next(); + this.stopWatch$.complete(); } } diff --git a/ui-ngx/src/styles.scss b/ui-ngx/src/styles.scss index 638b89b623..a8cf53534e 100644 --- a/ui-ngx/src/styles.scss +++ b/ui-ngx/src/styles.scss @@ -902,9 +902,6 @@ pre.tb-highlight { &.tb-mat-12 { @include tb-mat-icon-size(12); } - &.tb-mat-14 { - @include tb-mat-icon-size(14); - } &.tb-mat-16 { @include tb-mat-icon-size(16); }