Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: show org summary page if not entitled#14336

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
code-asher merged 1 commit intomainfromasher/org-summary-if-not-entitled
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes fromall 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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,6 +10,7 @@ const meta: Meta<typeof OrganizationSettingsPage> = {
decorators: [withAuthProvider, withDashboardProvider],
parameters: {
user: MockUser,
features: ["multiple_organizations"],
permissions: { viewDeploymentValues: true },
queries: [
{
Expand DownExpand Up@@ -61,3 +62,23 @@ export const CanEditOrganization: Story = {
],
},
};

export const CanEditOrganizationNotEntitled: Story = {
parameters: {
reactRouter: reactRouterParameters({
location: { pathParams: { organization: MockDefaultOrganization.name } },
routing: { path: "/organizations/:organization" },
}),
features: [],
queries: [
{
key: ["organizations", [MockDefaultOrganization.id], "permissions"],
data: {
[MockDefaultOrganization.id]: {
editOrganization: true,
},
},
},
],
},
};
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@ import { screen, within } from "@testing-library/react";
import { http, HttpResponse } from "msw";
import {
MockDefaultOrganization,
MockEntitlementsWithMultiOrg,
MockOrganization2,
} from "testHelpers/entities";
import {
Expand All@@ -24,6 +25,9 @@ const renderPage = async () => {
describe("OrganizationSettingsPage", () => {
it("has no editable organizations", async () => {
server.use(
http.get("/api/v2/entitlements", () => {
return HttpResponse.json(MockEntitlementsWithMultiOrg);
}),
http.get("/api/v2/organizations", () => {
return HttpResponse.json([MockDefaultOrganization, MockOrganization2]);
}),
Expand All@@ -39,6 +43,9 @@ describe("OrganizationSettingsPage", () => {

it("redirects to default organization", async () => {
server.use(
http.get("/api/v2/entitlements", () => {
return HttpResponse.json(MockEntitlementsWithMultiOrg);
}),
http.get("/api/v2/organizations", () => {
// Default always preferred regardless of order.
return HttpResponse.json([MockOrganization2, MockDefaultOrganization]);
Expand All@@ -60,6 +67,9 @@ describe("OrganizationSettingsPage", () => {

it("redirects to non-default organization", async () => {
server.use(
http.get("/api/v2/entitlements", () => {
return HttpResponse.json(MockEntitlementsWithMultiOrg);
}),
http.get("/api/v2/organizations", () => {
return HttpResponse.json([MockDefaultOrganization, MockOrganization2]);
}),
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,6 +7,7 @@ import type { Organization } from "api/typesGenerated";
import { EmptyState } from "components/EmptyState/EmptyState";
import { displaySuccess } from "components/GlobalSnackbar/utils";
import { Loader } from "components/Loader/Loader";
import { useFeatureVisibility } from "modules/dashboard/useFeatureVisibility";
import type { FC } from "react";
import { useMutation, useQuery, useQueryClient } from "react-query";
import { Navigate, useNavigate, useParams } from "react-router-dom";
Expand All@@ -22,6 +23,7 @@ const OrganizationSettingsPage: FC = () => {
organization?: string;
};
const { organizations } = useOrganizationSettings();
const feats = useFeatureVisibility();

const navigate = useNavigate();
const queryClient = useQueryClient();
Expand DownExpand Up@@ -69,7 +71,12 @@ const OrganizationSettingsPage: FC = () => {
// The user may not be able to edit this org but they can still see it because
// they can edit members, etc. In this case they will be shown a read-only
// summary page instead of the settings form.
if (!permissions[organization.id]?.editOrganization) {
// Similarly, if the feature is not entitled then the user will not be able to
// edit the organization.
if (
!permissions[organization.id]?.editOrganization ||
!feats.multiple_organizations
) {
return <OrganizationSummaryPageView organization={organization} />;
}

Expand Down
1 change: 1 addition & 0 deletionssite/src/testHelpers/storybook.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,6 +24,7 @@ export const withDashboardProvider = (

const entitlements: Entitlements = {
...MockEntitlements,
has_license: features.length > 0,
features: withDefaultFeatures(
Object.fromEntries(
features.map((feature) => [
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp