Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Validation for internal group's tenant collection permission should reference all internal users (#67177)

Phoomparin Mano2dd017d522c8
diff --git a/e2e/test/scenarios/admin-2/tenants.cy.spec.ts b/e2e/test/scenarios/admin-2/tenants.cy.spec.ts
index 8a7a8a5d202..9a350190ccb 100644
--- a/e2e/test/scenarios/admin-2/tenants.cy.spec.ts
+++ b/e2e/test/scenarios/admin-2/tenants.cy.spec.ts
@@ -431,6 +431,55 @@ describe("Tenants - management", () => {
});
});
+ it("should show 'All Internal Users' in permission warning modal for internal groups on tenant collections (EMB-1143)", () => {
+ cy.request("PUT", "/api/setting", { "use-tenants": true });
+
+ cy.request("POST", "/api/permissions/group", {
+ name: "Test Internal Group",
+ is_tenant_group: false,
+ });
+
+ cy.visit("/admin/permissions/tenant-collections/root");
+
+ cy.log("all internal users should have 'View' access");
+ cy.findAllByRole("row")
+ .contains("tr", "All Internal Users")
+ .findByText("View")
+ .should("be.visible");
+
+ cy.log("internal group should have no access");
+ cy.findAllByRole("row")
+ .contains("tr", "Test Internal Group")
+ .findByText("No access")
+ .click();
+
+ cy.log("change internal group to view-only");
+ H.popover().findByText("View").click();
+
+ cy.findAllByRole("row")
+ .contains("tr", "Test Internal Group")
+ .findByText("View")
+ .click();
+
+ cy.log("change internal group back to no access");
+ H.popover().findByText("No access").click();
+
+ H.modal().within(() => {
+ cy.log("title should mention internal users group");
+ cy.findByText(/Revoke access even though "All Internal Users"/).should(
+ "be.visible",
+ );
+
+ cy.log("description should mention internal users group");
+ cy.findByText(
+ /The "All Internal Users" group has a higher level of access/,
+ ).should("be.visible");
+
+ cy.log("should not mention tenant users");
+ cy.contains("Tenant users").should("not.exist");
+ });
+ });
+
it("should not show send email modal when creating tenant users when SMTP is configured", () => {
H.setupSMTP();
cy.request("PUT", "/api/setting", {
diff --git a/enterprise/frontend/src/metabase-enterprise/tenants/components/TenantCollectionPermissionsPage/selectors.tsx b/enterprise/frontend/src/metabase-enterprise/tenants/components/TenantCollectionPermissionsPage/selectors.tsx
index 1facb5598cd..49d6ebcbb4d 100644
--- a/enterprise/frontend/src/metabase-enterprise/tenants/components/TenantCollectionPermissionsPage/selectors.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/tenants/components/TenantCollectionPermissionsPage/selectors.tsx
@@ -19,7 +19,11 @@ import {
getCollectionIcon,
} from "metabase/entities/collections";
import { Groups } from "metabase/entities/groups";
-import { getGroupNameLocalized, isAdminGroup } from "metabase/lib/groups";
+import {
+ getGroupNameLocalized,
+ isAdminGroup,
+ isDefaultGroup,
+} from "metabase/lib/groups";
import { PLUGIN_TENANTS } from "metabase/plugins";
import type {
Collection,
@@ -172,7 +176,7 @@ export const getTenantCollectionsPermissionEditor = createSelector(
const defaultGroup = _.find(
groups,
- PLUGIN_TENANTS.isExternalUsersGroup,
+ isTenantGroup ? PLUGIN_TENANTS.isExternalUsersGroup : isDefaultGroup,
);
const defaultGroupPermission = defaultGroup