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

feat: add notifications troubleshooting tab#16650

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
mtojek merged 5 commits intomainfromtest-notif-ui
Feb 21, 2025
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
4 changes: 4 additions & 0 deletionssite/src/api/api.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2297,6 +2297,10 @@ class ApiMethods {
return res.data;
};

postTestNotification = async () => {
await this.axios.post<void>("/api/v2/notifications/test");
};

requestOneTimePassword = async (
req: TypesGen.RequestOneTimePasscodeRequest,
) => {
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,9 @@ import {
selectTemplatesByGroup,
systemNotificationTemplates,
} from "api/queries/notifications";
import { FeatureStageBadge } from "components/FeatureStageBadge/FeatureStageBadge";
import { Loader } from "components/Loader/Loader";
import { SettingsHeader } from "components/SettingsHeader/SettingsHeader";
import { TabLink, Tabs, TabsList } from "components/Tabs/Tabs";
import { useSearchParamsKey } from "hooks/useSearchParamsKey";
import { useDeploymentSettings } from "modules/management/DeploymentSettingsProvider";
Expand All@@ -14,9 +16,11 @@ import type { FC } from "react";
import { Helmet } from "react-helmet-async";
import { useQueries } from "react-query";
import { deploymentGroupHasParent } from "utils/deployOptions";
import { docs } from "utils/docs";
import { pageTitle } from "utils/page";
import OptionsTable from "../OptionsTable";
import { NotificationEvents } from "./NotificationEvents";
import { Troubleshooting } from "./Troubleshooting";

export const NotificationsPage: FC = () => {
const { deploymentConfig } = useDeploymentSettings();
Expand All@@ -40,48 +44,62 @@ export const NotificationsPage: FC = () => {
<Helmet>
<title>{pageTitle("Notifications Settings")}</title>
</Helmet>
<Section
title="Notifications"
<SettingsHeader
title={
<>
Notifications
<span css={{ position: "relative", top: "-6px" }}>
<FeatureStageBadge
contentType={"beta"}
size="lg"
css={{ marginBottom: "5px", fontSize: "0.75rem" }}
/>
</span>
</>
}
description="Control delivery methods for notifications on this deployment."
layout="fluid"
featureStage={"beta"}
>
<Tabs active={tabState.value}>
<TabsList>
<TabLink to="?tab=events" value="events">
Events
</TabLink>
<TabLink to="?tab=settings" value="settings">
Settings
</TabLink>
</TabsList>
</Tabs>
docsHref={docs("/admin/monitoring/notifications")}
/>
<Tabs active={tabState.value}>
<TabsList>
<TabLink to="?tab=events" value="events">
Events
</TabLink>
<TabLink to="?tab=settings" value="settings">
Settings
</TabLink>
<TabLink to="?tab=troubleshooting" value="troubleshooting">
Troubleshooting
</TabLink>
</TabsList>
</Tabs>

<div css={styles.content}>
{ready ? (
tabState.value === "events" ? (
<NotificationEvents
templatesByGroup={templatesByGroup.data}
deploymentConfig={deploymentConfig.config}
defaultMethod={castNotificationMethod(
dispatchMethods.data.default,
)}
availableMethods={dispatchMethods.data.available.map(
castNotificationMethod,
)}
/>
) : (
<OptionsTable
options={deploymentConfig.options.filter((o) =>
deploymentGroupHasParent(o.group, "Notifications"),
)}
/>
)
<div css={styles.content}>
{ready ? (
tabState.value === "events" ? (
<NotificationEvents
templatesByGroup={templatesByGroup.data}
deploymentConfig={deploymentConfig.config}
defaultMethod={castNotificationMethod(
dispatchMethods.data.default,
)}
availableMethods={dispatchMethods.data.available.map(
castNotificationMethod,
)}
/>
) : tabState.value === "troubleshooting" ? (
<Troubleshooting />
) : (
<Loader />
)}
</div>
</Section>
<OptionsTable
options={deploymentConfig.options.filter((o) =>
deploymentGroupHasParent(o.group, "Notifications"),
)}
/>
)
) : (
<Loader />
)}
</div>
</>
);
};
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
import type { Meta, StoryObj } from "@storybook/react";
import { spyOn, userEvent, within } from "@storybook/test";
import { API } from "api/api";
import { Troubleshooting } from "./Troubleshooting";
import { baseMeta } from "./storybookUtils";

const meta: Meta<typeof Troubleshooting> = {
title: "pages/DeploymentSettingsPage/NotificationsPage/Troubleshooting",
component: Troubleshooting,
...baseMeta,
};

export default meta;

type Story = StoryObj<typeof Troubleshooting>;

export const TestNotification: Story = {
play: async ({ canvasElement }) => {
spyOn(API, "postTestNotification").mockResolvedValue();
const user = userEvent.setup();
const canvas = within(canvasElement);

const sendButton = canvas.getByRole("button", {
name: "Send notification",
});
await user.click(sendButton);
await within(document.body).findByText("Test notification sent");
},
};
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
import { useTheme } from "@emotion/react";
import LoadingButton from "@mui/lab/LoadingButton";
import { API } from "api/api";
import { displayError, displaySuccess } from "components/GlobalSnackbar/utils";
import type { FC } from "react";
import { useMutation } from "react-query";

export const Troubleshooting: FC = () => {
const { mutate: sendTestNotificationApi, isLoading } = useMutation(
API.postTestNotification,
{
onSuccess: () => displaySuccess("Test notification sent"),
onError: () => displayError("Failed to send test notification"),
},
);

const theme = useTheme();
return (
<>
<div
css={{
fontSize: 14,
color: theme.palette.text.secondary,
lineHeight: "160%",
marginBottom: 16,
}}
>
Send a test notification to troubleshoot your notification settings.
</div>
<div>
<span>
<LoadingButton
variant="outlined"
loading={isLoading}
size="small"
css={{ minWidth: "auto", aspectRatio: "1" }}
onClick={() => {
sendTestNotificationApi();
}}
>
Send notification
</LoadingButton>
</span>
</div>
</>
);
};
Loading

[8]ページ先頭

©2009-2025 Movatter.jp