1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-12 14:34:02 +00:00

add unmark critical app button and service

This commit is contained in:
jaasen-livefront
2024-11-20 11:03:19 -08:00
parent 365c7dd65e
commit 1aea907f31
5 changed files with 77 additions and 2 deletions

View File

@@ -65,6 +65,7 @@
<th bitSortable="totalPasswords" bitCell>{{ "totalPasswords" | i18n }}</th>
<th bitSortable="atRiskMembers" bitCell>{{ "atRiskMembers" | i18n }}</th>
<th bitSortable="totalMembers" bitCell>{{ "totalMembers" | i18n }}</th>
<th></th>
</tr>
</ng-container>
<ng-template body let-rows$>
@@ -93,6 +94,21 @@
<td bitCell data-testid="total-membership">
{{ r.totalMembers }}
</td>
<td bitCell>
<button
[bitMenuTriggerFor]="rowMenu"
type="button"
bitIconButton="bwi-ellipsis-v"
size="small"
appA11yTitle="{{ 'options' | i18n }}"
></button>
<bit-menu #rowMenu>
<button type="button" bitMenuItem (click)="unmarkAsCriticalApp(r.name)">
<i aria-hidden="true" class="bwi bwi-star-f"></i> {{ "unmarkAsCriticalApp" | i18n }}
</button>
</bit-menu>
</td>
</tr>
</ng-template>
</bit-table>

View File

@@ -4,8 +4,16 @@ import { FormControl } from "@angular/forms";
import { ActivatedRoute, Router } from "@angular/router";
import { debounceTime, map } from "rxjs";
// eslint-disable-next-line no-restricted-imports
import { UnmarkCriticalApplicationApiService } from "@bitwarden/bit-common/tools/reports/risk-insights";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { SearchModule, TableDataSource, NoItemsModule, Icons } from "@bitwarden/components";
import {
SearchModule,
TableDataSource,
NoItemsModule,
Icons,
ToastService,
} from "@bitwarden/components";
import { CardComponent } from "@bitwarden/tools-card";
import { HeaderModule } from "../../layouts/header/header.module";
@@ -20,6 +28,7 @@ import { RiskInsightsTabType } from "./risk-insights.component";
selector: "tools-critical-applications",
templateUrl: "./critical-applications.component.html",
imports: [CardComponent, HeaderModule, SearchModule, NoItemsModule, PipesModule, SharedModule],
providers: [UnmarkCriticalApplicationApiService],
})
export class CriticalApplicationsComponent implements OnInit {
protected dataSource = new TableDataSource<any>();
@@ -55,12 +64,30 @@ export class CriticalApplicationsComponent implements OnInit {
});
};
unmarkAsCriticalApp = async (hostname: string) => {
await this.unmarkCriticalApplicationApiService.unmarkCriticalApplication(
this.organizationId,
hostname,
);
this.toastService.showToast({
// TODO uncomment when UnmarkCriticalApplicationApiService is properly implemented
// message: this.i18nService.t("criticalApplicationSuccessfullyUnmarked"),
// variant: "success",
// title: this.i18nService.t("Success"),
title: "API not yet implemented",
variant: "warning",
message: "API not yet implemented",
});
};
constructor(
protected i18nService: I18nService,
protected activatedRoute: ActivatedRoute,
protected router: Router,
private unmarkCriticalApplicationApiService: UnmarkCriticalApplicationApiService,
protected toastService: ToastService,
) {
this.dataSource.data = []; //applicationTableMockData;
this.dataSource.data = applicationTableMockData;
this.searchControl.valueChanges
.pipe(debounceTime(200), takeUntilDestroyed())
.subscribe((v) => (this.dataSource.filter = v));

View File

@@ -113,6 +113,12 @@
"totalApplications": {
"message": "Total applications"
},
"unmarkAsCriticalApp": {
"message": "Unmark as critical app"
},
"criticalApplicationSuccessfullyUnmarked": {
"message": "Critical application successfully unmarked"
},
"whatTypeOfItem": {
"message": "What type of item is this?"
},

View File

@@ -1,2 +1,3 @@
export * from "./member-cipher-details-api.service";
export * from "./password-health.service";
export * from "./unmark-critical-application-api.service";

View File

@@ -0,0 +1,25 @@
import { Injectable } from "@angular/core";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
@Injectable()
export class UnmarkCriticalApplicationApiService {
constructor(private apiService: ApiService) {}
/**
* Unmark a critical application for organization
* @param orgId OrganizationId to get member cipher details for
* @returns void
*/
async unmarkCriticalApplication(orgId: string, hostname: string): Promise<void> {
// TODO - Properly implement this method once the API is ready
// const response = await this.apiService.send(
// "GET",
// "/organizations/" + orgId + "/unmark-as-critical-application",
// null,
// true,
// true,
// );
// return response;
}
}