diff --git a/changes/16500-policy-pass-fail-percentage b/changes/16500-policy-pass-fail-percentage
new file mode 100644
index 0000000000..bc93d8227f
--- /dev/null
+++ b/changes/16500-policy-pass-fail-percentage
@@ -0,0 +1 @@
+* When a live policy run finishes, display the percentages of passing and failing hosts to the user.
diff --git a/frontend/interfaces/host.ts b/frontend/interfaces/host.ts
index f0d1ae2b3d..29afed9537 100644
--- a/frontend/interfaces/host.ts
+++ b/frontend/interfaces/host.ts
@@ -206,7 +206,7 @@ export interface IPackStats {
type: string;
}
-export interface IHostPolicyQuery {
+export interface IPolicyHostResponse {
id: number;
display_name: string;
query_results?: unknown[];
diff --git a/frontend/pages/policies/PolicyPage/components/PolicyQueriesErrorsTable/PolicyQueriesErrorsTable.tsx b/frontend/pages/policies/PolicyPage/components/PolicyErrorsTable/PolicyErrorsTable.tsx
similarity index 69%
rename from frontend/pages/policies/PolicyPage/components/PolicyQueriesErrorsTable/PolicyQueriesErrorsTable.tsx
rename to frontend/pages/policies/PolicyPage/components/PolicyErrorsTable/PolicyErrorsTable.tsx
index 3b1fb9e1be..7948d73c66 100644
--- a/frontend/pages/policies/PolicyPage/components/PolicyQueriesErrorsTable/PolicyQueriesErrorsTable.tsx
+++ b/frontend/pages/policies/PolicyPage/components/PolicyErrorsTable/PolicyErrorsTable.tsx
@@ -6,32 +6,25 @@ import { ICampaignError } from "interfaces/campaign";
import {
generateTableHeaders,
generateDataSet,
-} from "./PolicyQueriesErrorsTableConfig";
+} from "./PolicyErrorsTableConfig";
-const baseClass = "policies-queries-table";
-const noPolicyQueries = "no-policy-queries";
+// TODO - this class is duplicated and styles are overlapping with PolicyResultsTable. Differentiate
+// them clearly and encapsulate common styles.
+const baseClass = "policy-results-table";
-interface IPoliciesTableProps {
+interface IPolicyErrorsTableProps {
errorsList: ICampaignError[];
isLoading: boolean;
resultsTitle?: string;
canAddOrDeletePolicy?: boolean;
}
-const PoliciesTable = ({
+const PolicyErrorsTable = ({
errorsList,
isLoading,
resultsTitle,
canAddOrDeletePolicy,
-}: IPoliciesTableProps): JSX.Element => {
- const NoPolicyQueries = () => {
- return (
-
(
+
+ )}
onQueryChange={noop}
disableCount
/>
@@ -63,4 +60,4 @@ const PoliciesTable = ({
);
};
-export default PoliciesTable;
+export default PolicyErrorsTable;
diff --git a/frontend/pages/policies/PolicyPage/components/PolicyQueriesErrorsTable/PolicyQueriesErrorsTableConfig.tsx b/frontend/pages/policies/PolicyPage/components/PolicyErrorsTable/PolicyErrorsTableConfig.tsx
similarity index 100%
rename from frontend/pages/policies/PolicyPage/components/PolicyQueriesErrorsTable/PolicyQueriesErrorsTableConfig.tsx
rename to frontend/pages/policies/PolicyPage/components/PolicyErrorsTable/PolicyErrorsTableConfig.tsx
diff --git a/frontend/pages/policies/PolicyPage/components/PolicyQueriesErrorsTable/_styles.scss b/frontend/pages/policies/PolicyPage/components/PolicyErrorsTable/_styles.scss
similarity index 98%
rename from frontend/pages/policies/PolicyPage/components/PolicyQueriesErrorsTable/_styles.scss
rename to frontend/pages/policies/PolicyPage/components/PolicyErrorsTable/_styles.scss
index 24618c22f9..44aaf3d222 100644
--- a/frontend/pages/policies/PolicyPage/components/PolicyQueriesErrorsTable/_styles.scss
+++ b/frontend/pages/policies/PolicyPage/components/PolicyErrorsTable/_styles.scss
@@ -1,4 +1,4 @@
-.policies-queries-table {
+.policy-results-table {
border-collapse: collapse;
&__wrapper {
diff --git a/frontend/pages/policies/PolicyPage/components/PolicyErrorsTable/index.ts b/frontend/pages/policies/PolicyPage/components/PolicyErrorsTable/index.ts
new file mode 100644
index 0000000000..1167b6f858
--- /dev/null
+++ b/frontend/pages/policies/PolicyPage/components/PolicyErrorsTable/index.ts
@@ -0,0 +1 @@
+export { default } from "./PolicyErrorsTable";
diff --git a/frontend/pages/policies/PolicyPage/components/PolicyQueriesErrorsTable/index.ts b/frontend/pages/policies/PolicyPage/components/PolicyQueriesErrorsTable/index.ts
deleted file mode 100644
index 9b51be9010..0000000000
--- a/frontend/pages/policies/PolicyPage/components/PolicyQueriesErrorsTable/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from "./PolicyQueriesErrorsTable";
diff --git a/frontend/pages/policies/PolicyPage/components/PolicyQueriesTable/index.ts b/frontend/pages/policies/PolicyPage/components/PolicyQueriesTable/index.ts
deleted file mode 100644
index 87b478a29f..0000000000
--- a/frontend/pages/policies/PolicyPage/components/PolicyQueriesTable/index.ts
+++ /dev/null
@@ -1 +0,0 @@
-export { default } from "./PolicyQueriesTable";
diff --git a/frontend/pages/policies/PolicyPage/components/QueryResults/QueryResults.tsx b/frontend/pages/policies/PolicyPage/components/PolicyResults/PolicyResults.tsx
similarity index 76%
rename from frontend/pages/policies/PolicyPage/components/QueryResults/QueryResults.tsx
rename to frontend/pages/policies/PolicyPage/components/PolicyResults/PolicyResults.tsx
index d31de5d0d8..b78ffbb171 100644
--- a/frontend/pages/policies/PolicyPage/components/QueryResults/QueryResults.tsx
+++ b/frontend/pages/policies/PolicyPage/components/PolicyResults/PolicyResults.tsx
@@ -18,14 +18,16 @@ import Icon from "components/Icon/Icon";
import TabsWrapper from "components/TabsWrapper";
import InfoBanner from "components/InfoBanner";
import ShowQueryModal from "components/modals/ShowQueryModal";
+import TooltipWrapper from "components/TooltipWrapper";
-import QueryResultsHeading from "components/queries/queryResults/QueryResultsHeading";
+import ResultsHeading from "components/queries/queryResults/QueryResultsHeading";
import AwaitingResults from "components/queries/queryResults/AwaitingResults";
-import PolicyQueryTable from "../PolicyQueriesTable/PolicyQueriesTable";
-import PolicyQueriesErrorsTable from "../PolicyQueriesErrorsTable/PolicyQueriesErrorsTable";
+import PolicyResultsTable from "../PolicyResultsTable/PolicyResultsTable";
+import PolicyQueriesErrorsTable from "../PolicyErrorsTable/PolicyErrorsTable";
+import { getYesNoCounts } from "./helpers";
-interface IQueryResultsProps {
+interface IPolicyResultsProps {
campaign: ICampaign;
isQueryFinished: boolean;
policyName?: string;
@@ -43,7 +45,7 @@ const NAV_TITLES = {
ERRORS: "Errors",
};
-const QueryResults = ({
+const PolicyResults = ({
campaign,
isQueryFinished,
policyName,
@@ -52,10 +54,10 @@ const QueryResults = ({
setSelectedTargets,
goToQueryEditor,
targetsTotalCount,
-}: IQueryResultsProps): JSX.Element => {
+}: IPolicyResultsProps): JSX.Element => {
const { lastEditedQueryBody } = useContext(PolicyContext);
- const { hosts: hostsOnline, hosts_count: hostsCount, errors } =
+ const { hosts: hostResponses, hosts_count: hostsCount, errors } =
campaign || {};
const totalRowsCount = get(campaign, ["hosts_count", "successful"], 0);
@@ -63,11 +65,11 @@ const QueryResults = ({
const [navTabIndex, setNavTabIndex] = useState(0);
const [showQueryModal, setShowQueryModal] = useState(false);
- const onExportQueryResults = (evt: React.MouseEvent
) => {
+ const onExportResults = (evt: React.MouseEvent) => {
evt.preventDefault();
- if (hostsOnline) {
- const hostsExport = hostsOnline.map((host) => {
+ if (hostResponses) {
+ const hostsExport = hostResponses.map((host) => {
return {
host: host.display_name,
status:
@@ -121,9 +123,7 @@ const QueryResults = ({
@@ -211,7 +232,7 @@ const QueryResults = ({
return (