diff --git a/src/portal/lib/src/service/interface.ts b/src/portal/lib/src/service/interface.ts index dfbd94a03..448e8e0e5 100644 --- a/src/portal/lib/src/service/interface.ts +++ b/src/portal/lib/src/service/interface.ts @@ -434,3 +434,8 @@ export interface HttpOptionTextInterface { withCredentials?: boolean; } +export interface ProjectRootInterface { + NAME: string; + VALUE: number; + LABEL: string; +} diff --git a/src/portal/lib/src/shared/shared.const.ts b/src/portal/lib/src/shared/shared.const.ts index 83d599368..506b40257 100644 --- a/src/portal/lib/src/shared/shared.const.ts +++ b/src/portal/lib/src/shared/shared.const.ts @@ -84,3 +84,35 @@ export const LabelColor = [ { 'color': '#F52F52', 'textColor': 'black' }, { 'color': '#FF5501', 'textColor': 'black' }, { 'color': '#F57600', 'textColor': 'black' }, { 'color': '#FFDC0B', 'textColor': 'black' }, ]; + +export const CONFIG_AUTH_MODE = { + HTTP_AUTH: "http_auth", + LDAP_AUTH: "ldap_auth" +}; +export const PROJECT_ROOTS = [ + { + NAME: "admin", + VALUE: 1, + LABEL: "GROUP.PROJECT_ADMIN" + }, + { + NAME: "master", + VALUE: 4, + LABEL: "GROUP.PROJECT_MASTER" + }, + { + NAME: "developer", + VALUE: 2, + LABEL: "GROUP.DEVELOPER" + }, + { + NAME: "guest", + VALUE: 3, + LABEL: "GROUP.GUEST" + } +]; + +export enum GroupType { + LDAP_TYPE = 1, + HTTP_TYPE = 2 +} diff --git a/src/portal/src/app/app-config.service.ts b/src/portal/src/app/app-config.service.ts index e75944290..7ee3639aa 100644 --- a/src/portal/src/app/app-config.service.ts +++ b/src/portal/src/app/app-config.service.ts @@ -19,7 +19,7 @@ import { CookieService } from 'ngx-cookie'; import { AppConfig } from './app-config'; import { CookieKeyOfAdmiral, HarborQueryParamKey } from './shared/shared.const'; import { maintainUrlQueryParmas } from './shared/shared.utils'; -import { HTTP_GET_OPTIONS} from '@harbor/ui'; +import { HTTP_GET_OPTIONS , CONFIG_AUTH_MODE} from '@harbor/ui'; import { map, catchError } from "rxjs/operators"; import { Observable, throwError as observableThrowError } from "rxjs"; export const systemInfoEndpoint = "/api/systeminfo"; @@ -67,7 +67,10 @@ export class AppConfigService { } public isLdapMode(): boolean { - return this.configurations && this.configurations.auth_mode === 'ldap_auth'; + return this.configurations && this.configurations.auth_mode === CONFIG_AUTH_MODE.LDAP_AUTH; + } + public isHttpAuthMode(): boolean { + return this.configurations && this.configurations.auth_mode === CONFIG_AUTH_MODE.HTTP_AUTH; } // Return the reconstructed admiral url diff --git a/src/portal/src/app/base/harbor-shell/harbor-shell.component.html b/src/portal/src/app/base/harbor-shell/harbor-shell.component.html index eb3810d11..637fab370 100644 --- a/src/portal/src/app/base/harbor-shell/harbor-shell.component.html +++ b/src/portal/src/app/base/harbor-shell/harbor-shell.component.html @@ -28,7 +28,7 @@ {{'SIDE_NAV.SYSTEM_MGMT.USER' | translate}} - + {{'SIDE_NAV.SYSTEM_MGMT.GROUP' | translate}} diff --git a/src/portal/src/app/base/harbor-shell/harbor-shell.component.ts b/src/portal/src/app/base/harbor-shell/harbor-shell.component.ts index 6a818b51c..f65a0f291 100644 --- a/src/portal/src/app/base/harbor-shell/harbor-shell.component.ts +++ b/src/portal/src/app/base/harbor-shell/harbor-shell.component.ts @@ -54,6 +54,8 @@ export class HarborShellComponent implements OnInit, OnDestroy { searchSub: Subscription; searchCloseSub: Subscription; + isLdapMode: boolean; + isHttpAuthMode: boolean; constructor( private route: ActivatedRoute, @@ -63,6 +65,11 @@ export class HarborShellComponent implements OnInit, OnDestroy { private appConfigService: AppConfigService) { } ngOnInit() { + if (this.appConfigService.isLdapMode()) { + this.isLdapMode = true; + } else if (this.appConfigService.isHttpAuthMode()) { + this.isHttpAuthMode = true; + } this.searchSub = this.searchTrigger.searchTriggerChan$.subscribe(searchEvt => { if (searchEvt && searchEvt.trim() !== "") { this.isSearchResultsOpened = true; @@ -70,7 +77,7 @@ export class HarborShellComponent implements OnInit, OnDestroy { }); this.searchCloseSub = this.searchTrigger.searchCloseChan$.subscribe(close => { - this.isSearchResultsOpened = false; + this.isSearchResultsOpened = false; }); } @@ -97,11 +104,6 @@ export class HarborShellComponent implements OnInit, OnDestroy { return account != null && account.has_admin_role; } - public get isLdapMode(): boolean { - let appConfig = this.appConfigService.getConfig(); - return appConfig.auth_mode === 'ldap_auth'; - } - public get isUserExisting(): boolean { let account = this.session.getCurrentUser(); return account != null; diff --git a/src/portal/src/app/group/add-group-modal/add-group-modal.component.html b/src/portal/src/app/group/add-group-modal/add-group-modal.component.html index 3f3c778c8..b3dca6233 100644 --- a/src/portal/src/app/group/add-group-modal/add-group-modal.component.html +++ b/src/portal/src/app/group/add-group-modal/add-group-modal.component.html @@ -1,11 +1,12 @@ - + +