Skip to content
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

Update ui to fix some issues #19101

Merged
merged 1 commit into from
Aug 7, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
} from './security-hub.interface';
import { ProjectService } from '../../../../../../ng-swagger-gen/services/project.service';
import { VulnerabilityFilterComponent } from './vulnerability-filter/vulnerability-filter.component';
import { DangerousArtifact } from '../../../../../../ng-swagger-gen/models/dangerous-artifact';

@Component({
selector: 'app-security-hub',
Expand Down Expand Up @@ -174,8 +175,11 @@
this.currentPage = 1;
this.clrDgRefresh(this.state, [`${OptionType.CVE_ID}=${cveId}`]);
}
searchRepo(repoName: string) {
this.vulnerabilityFilterComponent.selectedOptions = [OptionType.REPO];
searchRepo(artifact: DangerousArtifact) {
this.vulnerabilityFilterComponent.selectedOptions = [

Check warning on line 179 in src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/security-hub.component.ts

View check run for this annotation

Codecov / codecov/patch

src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/security-hub.component.ts#L179

Added line #L179 was not covered by tests
OptionType.REPO,
OptionType.DIGEST,
];
this.vulnerabilityFilterComponent.candidates = [
OptionType.CVE_ID,
OptionType.SEVERITY,
Expand All @@ -185,8 +189,14 @@
OptionType.TAG,
];
this.vulnerabilityFilterComponent.valueMap = {};
this.vulnerabilityFilterComponent.valueMap[OptionType.REPO] = repoName;
this.vulnerabilityFilterComponent.valueMap[OptionType.REPO] =

Check warning on line 192 in src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/security-hub.component.ts

View check run for this annotation

Codecov / codecov/patch

src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/security-hub.component.ts#L192

Added line #L192 was not covered by tests
artifact?.repository_name;
this.vulnerabilityFilterComponent.valueMap[OptionType.DIGEST] =

Check warning on line 194 in src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/security-hub.component.ts

View check run for this annotation

Codecov / codecov/patch

src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/security-hub.component.ts#L194

Added line #L194 was not covered by tests
artifact?.digest;
this.currentPage = 1;
this.clrDgRefresh(this.state, [`${OptionType.REPO}=${repoName}`]);
this.clrDgRefresh(this.state, [

Check warning on line 197 in src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/security-hub.component.ts

View check run for this annotation

Codecov / codecov/patch

src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/security-hub.component.ts#L197

Added line #L197 was not covered by tests
`${OptionType.REPO}=${artifact?.repository_name}`,
`${OptionType.DIGEST}=${artifact?.digest}`,
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export enum OptionType {
PACKAGE = 'package',
TAG = 'tag',
PROJECT_ID = 'project_id',
DIGEST = 'digest',
}

export const OptionType_I18n_Map = {
Expand All @@ -32,6 +33,7 @@ export const OptionType_I18n_Map = {
[OptionType.PACKAGE]: 'VULNERABILITY.GRID.COLUMN_PACKAGE',
[OptionType.TAG]: 'REPLICATION.TAG',
[OptionType.PROJECT_ID]: 'SECURITY_HUB.OPTION_PROJECT_ID_NAME',
[OptionType.DIGEST]: 'P2P_PROVIDER.DIGEST',
};

export interface OptionTypeValueMap {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class VulnerabilityFilterComponent {
OptionType.REPO,
OptionType.PACKAGE,
OptionType.TAG,
OptionType.DIGEST,
];
allOptions: string[] = [
OptionType.CVE_ID,
Expand All @@ -33,6 +34,7 @@ export class VulnerabilityFilterComponent {
OptionType.REPO,
OptionType.PACKAGE,
OptionType.TAG,
OptionType.DIGEST,
];

valueMap: OptionTypeValueMap = {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ <h2>
{{ securitySummary?.none_cnt || 0 }}
</div>
</div>
<div class="clr-row">
<div class="clr-row" [hidden]="!securitySummary">
<div class="placeholder">
<div class="pie-chart" id="pie-chart"></div>
</div>
Expand Down Expand Up @@ -121,7 +121,7 @@ <h2>
class="search"
href="javascript:void(0)"
appScrollAnchor="{{ vulId }}"
(click)="searchRepoClick(item?.repository_name)"
(click)="searchRepoClick(item)"
title="{{ item.repository_name }}">
<span class="ellipsis">
<clr-icon shape="search"></clr-icon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
HarborEvent,
} from '../../../../../services/event-service/event.service';
import { TranslateService } from '@ngx-translate/core';
import { DangerousArtifact } from '../../../../../../../ng-swagger-gen/models/dangerous-artifact';
highchartsAccessibility(Highcharts);

@Component({
Expand All @@ -29,7 +30,7 @@
@Output()
searchCVE = new EventEmitter<string>();
@Output()
searchRepo = new EventEmitter<string>();
searchRepo = new EventEmitter<DangerousArtifact>();
securitySummary: SecuritySummary;
readonly vulId: string = VUL_ID;
readonly severityText = severityText;
Expand Down Expand Up @@ -175,8 +176,8 @@
this.searchCVE.emit(cveId);
}

searchRepoClick(repoName: string) {
this.searchRepo.emit(repoName);
searchRepoClick(artifact: DangerousArtifact) {
this.searchRepo.emit(artifact);

Check warning on line 180 in src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/vulnerability-summary/vulnerability-summary.component.ts

View check run for this annotation

Codecov / codecov/patch

src/portal/src/app/base/left-side-nav/interrogation-services/vulnerability-database/vulnerability-summary/vulnerability-summary.component.ts#L180

Added line #L180 was not covered by tests
}

getColorByTheme(): string {
Expand Down
10 changes: 10 additions & 0 deletions src/portal/src/app/services/app-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,18 @@
// Store the application configuration
configurations: AppConfig = new AppConfig();

private _bannerMessageClosed: boolean = false;

constructor(private http: HttpClient, private cookie: CookieService) {}

setBannerMessageClosed(v: boolean) {
this._bannerMessageClosed = v;

Check warning on line 45 in src/portal/src/app/services/app-config.service.ts

View check run for this annotation

Codecov / codecov/patch

src/portal/src/app/services/app-config.service.ts#L45

Added line #L45 was not covered by tests
}

getBannerMessageClosed(): boolean {
return this._bannerMessageClosed;

Check warning on line 49 in src/portal/src/app/services/app-config.service.ts

View check run for this annotation

Codecov / codecov/patch

src/portal/src/app/services/app-config.service.ts#L49

Added line #L49 was not covered by tests
}

public load(): Observable<AppConfig> {
return this.http.get(systemInfoEndpoint, HTTP_GET_OPTIONS).pipe(
map(response => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*ngIf="hasValidBannerMessage()"
[clrAlertType]="getBannerMessageType()"
[clrAlertAppLevel]="true"
[(clrAlertClosed)]="bannerMessageClosed"
[clrAlertClosable]="getBannerMessageClosable()">
<clr-alert-item>
<span class="alert-text banner-message">{{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@
private jobServiceDashboardHealthCheckService: JobServiceDashboardHealthCheckService,
private appConfigService: AppConfigService
) {}

get bannerMessageClosed(): boolean {
return this.appConfigService.getBannerMessageClosed();

Check warning on line 44 in src/portal/src/app/shared/components/app-level-alerts/app-level-alerts.component.ts

View check run for this annotation

Codecov / codecov/patch

src/portal/src/app/shared/components/app-level-alerts/app-level-alerts.component.ts#L44

Added line #L44 was not covered by tests
}

set bannerMessageClosed(v: boolean) {
this.appConfigService.setBannerMessageClosed(v);

Check warning on line 48 in src/portal/src/app/shared/components/app-level-alerts/app-level-alerts.component.ts

View check run for this annotation

Codecov / codecov/patch

src/portal/src/app/shared/components/app-level-alerts/app-level-alerts.component.ts#L48

Added line #L48 was not covered by tests
}

ngOnInit() {
if (
!(
Expand Down
Loading