+
{batchError !== undefined && batchError ? (
diff --git a/src/pages/IDViews/IDViewsOverrideUsersTable.tsx b/src/pages/IDViews/IDViewsOverrideUsersTable.tsx
index ef97fb22..0cd9740d 100644
--- a/src/pages/IDViews/IDViewsOverrideUsersTable.tsx
+++ b/src/pages/IDViews/IDViewsOverrideUsersTable.tsx
@@ -14,7 +14,6 @@ interface IDViewsOverrideData {
isSelectable: (view: IDViewOverrideUser) => boolean;
selected: string[];
selectableTable: IDViewOverrideUser[];
- setSelected: (user: IDViewOverrideUser, isSelecting?: boolean) => void;
setSelectedUsers: (users: string[]) => void;
clearSelected: () => void;
}
diff --git a/src/pages/IDViews/IDViewsTabs.tsx b/src/pages/IDViews/IDViewsTabs.tsx
index 8fc604aa..889ecaa7 100644
--- a/src/pages/IDViews/IDViewsTabs.tsx
+++ b/src/pages/IDViews/IDViewsTabs.tsx
@@ -24,6 +24,7 @@ import { updateBreadCrumbPath } from "src/store/Global/routes-slice";
import { NotFound } from "src/components/errors/PageErrors";
import IDViewsSettings from "./IDViewsSettings";
import IDViewsOverrides from "./IDViewsOverrides";
+import IDViewsAppliedTo from "./IDViewsAppliedTo";
// eslint-disable-next-line react/prop-types
const IDViewsTabs = ({ section }) => {
@@ -49,8 +50,8 @@ const IDViewsTabs = ({ section }) => {
navigate("/id-views/" + cn);
} else if (tabName.startsWith("override")) {
navigate("/id-views/" + cn + "/override-users");
- } else if (tabName === "appliesto") {
- // navigate("/id-views/" + cn + "/appliesto_idview");
+ } else if (tabIndex === "appliedto") {
+ navigate("/id-views/" + cn + "/appliedto");
}
};
@@ -160,10 +161,15 @@ const IDViewsTabs = ({ section }) => {
/>
Applies to}
- >
+ eventKey={"appliedto"}
+ name="appliedto-details"
+ title={Applied to}
+ >
+
+
>
diff --git a/src/services/rpcIDViews.ts b/src/services/rpcIDViews.ts
index e769ed4c..840f97cc 100644
--- a/src/services/rpcIDViews.ts
+++ b/src/services/rpcIDViews.ts
@@ -41,6 +41,11 @@ export type ViewFullData = {
idView?: Partial;
};
+export interface ViewApplyPayload {
+ viewName: string;
+ items: string[];
+}
+
const extendedApi = api.injectEndpoints({
endpoints: (build) => ({
getIDViewsFullData: build.query({
@@ -121,7 +126,7 @@ const extendedApi = api.injectEndpoints({
},
}),
/**
- * Given a list of view names, show the full data of those grouviewsps
+ * Given a list of view names, show the full data of those views
* @param {string[]} groupNames - List of group names
* @param {boolean} noMembers - Whether to show members or not
* @returns {BatchRPCResponse} - Batch response
@@ -180,14 +185,32 @@ const extendedApi = api.injectEndpoints({
* @param {string[]} hostgroupNames - List of hostgroup names
*/
unapplyHostgroups: build.mutation({
- query: (hostgroups) => {
+ query: (hostGroups) => {
return getCommand({
method: "idview_unapply",
- params: [[], { hostgroup: hostgroups }],
+ params: [[], { hostgroup: hostGroups }],
});
},
invalidatesTags: ["FullIDViewHostgroups"],
}),
+ applyHosts: build.mutation({
+ query: (payload) => {
+ return getCommand({
+ method: "idview_apply",
+ params: [[payload.viewName], { host: payload.items }],
+ });
+ },
+ invalidatesTags: ["FullIDViewHosts"],
+ }),
+ applyHostGroups: build.mutation({
+ query: (payload) => {
+ return getCommand({
+ method: "idview_apply",
+ params: [[payload.viewName], { hostgroup: payload.items }],
+ });
+ },
+ invalidatesTags: ["FullIDViewHosts"],
+ }),
}),
overrideExisting: false,
});
@@ -207,4 +230,6 @@ export const {
useSaveIDViewMutation,
useUnapplyHostsMutation,
useUnapplyHostgroupsMutation,
+ useApplyHostsMutation,
+ useApplyHostGroupsMutation,
} = extendedApi;
diff --git a/src/utils/datatypes/globalDataTypes.ts b/src/utils/datatypes/globalDataTypes.ts
index d29ad349..80c0aca1 100644
--- a/src/utils/datatypes/globalDataTypes.ts
+++ b/src/utils/datatypes/globalDataTypes.ts
@@ -395,6 +395,7 @@ export interface IDView {
ipadomainresolutionorder: string;
useroverrides: string[];
groupoverrides: string[];
+ appliedtohosts: string[];
}
export interface IDViewOverrideUser {
@@ -424,6 +425,7 @@ export interface IDViewOverrideGroup {
description: string;
gidnumber: string;
ipaanchoruuid: string;
+ appliedtohosts: string[];
}
export interface Config {
diff --git a/src/utils/idOverrideUtils.tsx b/src/utils/idOverrideUtils.tsx
index 8e1bba9b..e12994be 100644
--- a/src/utils/idOverrideUtils.tsx
+++ b/src/utils/idOverrideUtils.tsx
@@ -108,6 +108,7 @@ export function createEmptyOverrideGroup(): IDViewOverrideGroup {
description: "",
gidnumber: "",
ipaanchoruuid: "",
+ appliedtohosts: [],
};
return override;
diff --git a/src/utils/idViewUtils.tsx b/src/utils/idViewUtils.tsx
index 6e3a256c..4977574c 100644
--- a/src/utils/idViewUtils.tsx
+++ b/src/utils/idViewUtils.tsx
@@ -36,6 +36,7 @@ export function createEmptyView(): IDView {
ipadomainresolutionorder: "",
useroverrides: [],
groupoverrides: [],
+ appliedtohosts: [],
};
return view;
diff --git a/tests/features/id_view_appliedto.feature b/tests/features/id_view_appliedto.feature
new file mode 100644
index 00000000..b9118f06
--- /dev/null
+++ b/tests/features/id_view_appliedto.feature
@@ -0,0 +1,185 @@
+Feature: ID View applied to manipulation
+ Apply and unapply hosts and hostgroups to an ID view
+
+ Background:
+ Given I am logged in as "Administrator"
+ Given I am on "id-views" page
+
+ #
+ # Create sample entries
+ #
+ Scenario: Add new hosts
+ Given I am on "hosts" page
+ When I click on "Add" button
+ Then I type in the field "Host name" text "idviewhost1"
+ * in the modal dialog I click on "Add" button
+ * I should see "success" alert with text "New host added"
+ Then I should see partial "idviewhost1" entry in the data table
+ When I click on "Add" button
+ Then I type in the field "Host name" text "idviewhost2"
+ * in the modal dialog I click on "Add" button
+ * I should see "success" alert with text "New host added"
+ Then I should see partial "idviewhost2" entry in the data table
+
+ Scenario: Add a new host group
+ Given I am on "host-groups" page
+ When I click on "Add" button
+ * I type in the field "Group name" text "idviewhostgroup1"
+ When in the modal dialog I click on "Add" button
+ * I should see "success" alert with text "New host group added"
+ * I close the alert
+ Then I should see "idviewhostgroup1" entry in the data table
+ When I click on "Add" button
+ * I type in the field "Group name" text "idviewhostgroup2"
+ When in the modal dialog I click on "Add" button
+ * I should see "success" alert with text "New host group added"
+ * I close the alert
+ Then I should see "idviewhostgroup2" entry in the data table
+
+ Scenario: Add a Host members into the host group 1
+ Given I am on "host-groups" page
+ And I click on "idviewhostgroup1" entry in the data table
+ And I click on "Members" page tab
+ And I am on "idviewhostgroup1" group > Members > "Hosts" section
+ When I click on "Add" button located in the toolbar
+ Then I should see the dialog with title "Assign hosts to host group: idviewhostgroup1"
+ When I move user "idviewhost1.dom-server.ipa.demo" from the available list and move it to the chosen options
+ And in the modal dialog I click on "Add" button
+ * I should see "success" alert with text "Assigned new hosts to host group 'idviewhostgroup1'"
+ * I close the alert
+ Then I should see the element "idviewhost1.dom-server.ipa.demo" in the table
+
+ Scenario: Add a Host members into the host group 2
+ Given I am on "host-groups" page
+ Given I click on "idviewhostgroup2" entry in the data table
+ And I click on "Members" page tab
+ And I am on "idviewhostgroup2" group > Members > "Hosts" section
+ When I click on "Add" button located in the toolbar
+ Then I should see the dialog with title "Assign hosts to host group: idviewhostgroup2"
+ When I move user "idviewhost2.dom-server.ipa.demo" from the available list and move it to the chosen options
+ And in the modal dialog I click on "Add" button
+ * I should see "success" alert with text "Assigned new hosts to host group 'idviewhostgroup2'"
+ * I close the alert
+ Then I should see the element "idviewhost2.dom-server.ipa.demo" in the table
+
+ Scenario: Add a new view
+ Given I am on "id-views" page
+ When I click on "Add" button
+ * I type in the field "ID view name" text "a_new_view"
+ When in the modal dialog I click on "Add" button
+ * I should see "success" alert with text "New ID view added"
+ * I close the alert
+ Then I should see "a_new_view" entry in the data table
+
+ #
+ # Start testing "applied to" hosts
+ #
+ Scenario: Apply ID view to the host
+ When I click on "a_new_view" entry in the data table
+ Then I click on "Applied to" page tab
+ * I click toolbar dropdown "Apply"
+ * I click toolbar dropdown item "Apply hosts"
+ * I click on the arrow icon to perform search
+ Then I click on the dual list item "idviewhost1"
+ And I click on the dual list item "idviewhost2"
+ * I click on the dual list add selected button
+ * in the modal dialog I click on "Apply" button
+ Then I should see "success" alert with text "ID view applied to 2 hosts"
+ * I close the alert
+
+ Scenario: Search for a host
+ When I type "idviewhost2" in the search field
+ Then I should see the "idviewhost2" text in the search input field
+ Then I should see the element "idviewhost2" in the table
+ Then I should not see the element "idviewhost1" in the table
+ * I click on the X icon to clear the search field
+ When I type "notthere" in the search field
+ Then I should see the "notthere" text in the search input field
+ Then I should not see the element "idviewhost1" in the table
+ Then I should not see the element "idviewhost2" in the table
+ * I click on the X icon to clear the search field
+ And I should see the element "idviewhost1" in the table
+ And I should see the element "idviewhost2" in the table
+
+ #
+ # Test unapply hosts
+ #
+ Scenario: Unapply a host from the ID view
+ Given I select partial entry "idviewhost1" in the data table
+ Given I select partial entry "idviewhost2" in the data table
+ When I click toolbar dropdown "Unapply"
+ Then I click toolbar dropdown item "Unapply hosts"
+ And I should see "success" alert with text "ID view unapplied from 2 hosts"
+ * I close the alert
+
+ #
+ # Test "applied to" hostgroups
+ #
+ Scenario: Apply ID view to a host group
+ When I click toolbar dropdown "Apply"
+ And I click toolbar dropdown item "Apply host groups"
+ * I click on the arrow icon to perform search
+ Then I click on the dual list item "idviewhostgroup1"
+ And I click on the dual list item "idviewhostgroup2"
+ * I click on the dual list add selected button
+ * in the modal dialog I click on "Apply" button
+ Then I should see "success" alert with text "ID view applied to 2 hosts"
+ * I close the alert
+
+ #
+ # Test unapply host groups
+ #
+ Scenario: Unapply host groups from the ID view
+ When I click toolbar dropdown "Unapply"
+ Then I click toolbar dropdown item "Unapply host groups"
+ * I click on the arrow icon to perform search
+ Then I click on the dual list item "idviewhostgroup1"
+ * I click on the dual list add selected button
+ * in the modal dialog I click on "Unapply" button
+ Then I should see "success" alert with text "ID view unapplied from 1 hosts"
+ * I close the alert
+
+ # Cleanup
+ Scenario: Delete the ID view
+ When I click on the breadcrump link "ID views"
+ Then I should see "a_new_view" entry in the data table
+ Then I select entry "a_new_view" in the data table
+ When I click on "Delete" button
+ * I see "Remove ID views" modal
+ * I should see "a_new_view" entry in the data table
+ When in the modal dialog I click on "Delete" button
+ * I should see "success" alert with text "ID views removed"
+ * I close the alert
+ Then I should not see "a_new_view" entry in the data table
+
+ Scenario: Delete hosts
+ Given I am on "hosts" page
+ And I should see partial "idviewhost1" entry in the data table
+ And I should see partial "idviewhost2" entry in the data table
+ When I select partial entry "idviewhost1" in the data table
+ And I select partial entry "idviewhost2" in the data table
+ And I click on "Delete" button
+ Then I see "Remove hosts" modal
+ * I should see partial "idviewhost1" entry in the data table
+ * I should see partial "idviewhost2" entry in the data table
+ When in the modal dialog I click on "Delete" button
+ * I should see "success" alert with text "Hosts removed"
+ * I close the alert
+ Then I should not see partial "idviewhost1" entry in the data table
+ Then I should not see partial "idviewhost2" entry in the data table
+
+ Scenario: Delete host groups
+ Given I am on "host-groups" page
+ And I should see "idviewhostgroup1" entry in the data table
+ And I should see "idviewhostgroup2" entry in the data table
+ Then I select entry "idviewhostgroup1" in the data table
+ And I select entry "idviewhostgroup2" in the data table
+ When I click on "Delete" button
+ * I see "Remove host groups" modal
+ * I should see "idviewhostgroup1" entry in the data table
+ * I should see "idviewhostgroup2" entry in the data table
+ When in the modal dialog I click on "Delete" button
+ * I should see "success" alert with text "Host groups removed"
+ * I close the alert
+ Then I should not see "idviewhostgroup1" entry in the data table
+ And I should not see "idviewhostgroup2" entry in the data table
diff --git a/tests/features/id_view_handling.feature b/tests/features/id_view_handling.feature
index 36351e26..51afa0c7 100644
--- a/tests/features/id_view_handling.feature
+++ b/tests/features/id_view_handling.feature
@@ -40,7 +40,7 @@ Feature: ID View manipulation
* I click on the first dual list item
* I click on the dual list add selected button
When in the modal dialog I click on "Unapply" button
- Then I should see "success" alert with text "ID views unapplied from hosts"
+ Then I should see "success" alert with text "ID views unapplied from 0 hosts"
* I close the alert
Scenario: Unapply views from host groups
@@ -49,7 +49,7 @@ Feature: ID View manipulation
* I click on the first dual list item
* I click on the dual list add selected button
When in the modal dialog I click on "Unapply" button
- Then I should see "success" alert with text "ID views unapplied from host groups"
+ Then I should see "success" alert with text "ID views unapplied from 0 hosts"
* I close the alert
Scenario: Delete a view
diff --git a/tests/features/idoverride_users_handling.feature b/tests/features/idoverride_users_handling.feature
index c6f4d14a..48d5e3af 100644
--- a/tests/features/idoverride_users_handling.feature
+++ b/tests/features/idoverride_users_handling.feature
@@ -93,7 +93,7 @@ Feature: ID Override user manipulation
Scenario: Delete users
Given I am on "active-users" page
Given I should see "overrideuser1" entry in the data table
- Given I should see "overrideuser1" entry in the data table
+ Given I should see "overrideuser2" entry in the data table
When I select entry "overrideuser1" in the data table
And I select entry "overrideuser2" in the data table
And I click on "Delete" button
diff --git a/tests/features/steps/common.ts b/tests/features/steps/common.ts
index bd3e184b..bac15f3d 100644
--- a/tests/features/steps/common.ts
+++ b/tests/features/steps/common.ts
@@ -375,6 +375,20 @@ When(
}
);
+When("I click toolbar dropdown {string}", (name: string) => {
+ cy.get("div.pf-v5-c-toolbar__item")
+ .find("button.pf-v5-c-menu-toggle")
+ .contains(name)
+ .click();
+});
+
+When("I click toolbar dropdown item {string}", (name: string) => {
+ cy.get("li.pf-v5-c-menu__list-item")
+ .find("button.pf-v5-c-menu__item")
+ .contains(name)
+ .click();
+});
+
Then(
"I should see the option {string} selected in the {string} selector",
(option: string, selectorName: string) => {
diff --git a/tests/features/steps/user_handling.ts b/tests/features/steps/user_handling.ts
index 34a55a83..1639a0b4 100644
--- a/tests/features/steps/user_handling.ts
+++ b/tests/features/steps/user_handling.ts
@@ -429,7 +429,7 @@ Then(
When(
"I click on {string} button located in the toolbar",
(buttonName: string) => {
- cy.wait(1000);
+ cy.wait(2000);
cy.get("div.pf-v5-c-toolbar").find("button").contains(buttonName).click();
}
);