-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Show alert if there are failed/pending deliveries #5403
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 15 commits
7474935
eea1f00
93a4613
18ade3f
b54b6f7
f2d5143
b1b9be9
098aff4
433420b
379e926
651fab7
6f272f3
be4f48b
27f99b8
d20057f
4db334c
420dd0d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "saleor-dashboard": patch | ||
| --- | ||
|
|
||
| "Apps" link in sidebar now shows an alert if one or more apps have failed or pending webhook deliveries. This means you can see if there are issues with your apps without having to enter app details. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| name: app_alerts | ||
| displayName: App alerts | ||
| enabled: false | ||
| payload: "default" | ||
| visible: false | ||
| --- | ||
|
|
||
|  | ||
| Experience new notifications displaying alerts for apps in the Dashboard. | ||
| Get meaningful information when Saleor detects issues with an app. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import { AppSections } from "@dashboard/apps/urls"; | ||
| import { ExclamationIcon } from "@dashboard/icons/ExclamationIcon"; | ||
| import { ExclamationIconFilled } from "@dashboard/icons/ExclamationIconFilled"; | ||
| import { Box, Text, Tooltip } from "@saleor/macaw-ui-next"; | ||
| import React, { useState } from "react"; | ||
| import { FormattedMessage } from "react-intl"; | ||
| import { Link } from "react-router-dom"; | ||
|
|
||
| import { useAppsAlert } from "./useAppsAlert"; | ||
|
|
||
| const ExclamationIconComponent = () => { | ||
| const [isHovered, setIsHovered] = useState(false); | ||
| const colorLighter = "#FFD87E"; | ||
| const colorDefault = "#FFB84E"; | ||
|
|
||
| return ( | ||
| <Box | ||
| __color={isHovered ? colorLighter : colorDefault} | ||
| __width={17} | ||
| __height={17} | ||
| onMouseEnter={() => setIsHovered(true)} | ||
| onMouseLeave={() => setIsHovered(false)} | ||
| > | ||
| {isHovered ? <ExclamationIconFilled /> : <ExclamationIcon />} | ||
| </Box> | ||
| ); | ||
| }; | ||
|
|
||
| export const SidebarAppAlert = () => { | ||
| const { hasFailedAttempts } = useAppsAlert(); | ||
|
|
||
| if (!hasFailedAttempts) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <Tooltip> | ||
| <Tooltip.Trigger> | ||
| <Link to={AppSections.appsSection}> | ||
| <ExclamationIconComponent /> | ||
| </Link> | ||
| </Tooltip.Trigger> | ||
|
|
||
| <Tooltip.Content align="start" side="bottom"> | ||
| <Text> | ||
| <FormattedMessage | ||
| defaultMessage="Issues found.{break}Review app alerts." | ||
| id="4MIO2H" | ||
| values={{ | ||
| break: <br />, | ||
| }} | ||
| /> | ||
| </Text> | ||
| </Tooltip.Content> | ||
| </Tooltip> | ||
| ); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import { gql } from "@apollo/client"; | ||
|
|
||
| export const appFailedPendingWebhooks = gql` | ||
| query AppFailedPendingWebhooks { | ||
| apps(first: 50, filter: { type: THIRDPARTY }) { | ||
| edges { | ||
| node { | ||
| webhooks { | ||
| failedDelivers: eventDeliveries( | ||
| first: 1 | ||
| filter: { status: FAILED } | ||
| sortBy: { field: CREATED_AT, direction: DESC } | ||
| ) { | ||
| edges { | ||
| node { | ||
| id | ||
| } | ||
| } | ||
| } | ||
| pendingDelivers: eventDeliveries( | ||
| first: 1 | ||
| filter: { status: PENDING } | ||
| sortBy: { field: CREATED_AT, direction: DESC } | ||
| ) { | ||
| edges { | ||
| node { | ||
| attempts(first: 6, sortBy: { field: CREATED_AT, direction: DESC }) { | ||
| edges { | ||
| node { | ||
| status | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
20
to
36
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: I don't think we need to show pending deliveries, we should care only about failed ones
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're commenting outdated code :D We're fetching attempts of pending deliveries to check if they have failed https://github.com/saleor/saleor-dashboard/pull/5403/files#diff-9f3bbc45c9cc037644ba210310c6e2cb538fa2dfc054166306de7ebd00489e9fR19-R35 |
||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| `; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { useEffect } from "react"; | ||
|
|
||
| import { useAppsFailedDeliveries } from "./useAppsFailedDeliveries"; | ||
|
|
||
| export const useAppsAlert = () => { | ||
| const { hasFailed, fetchAppsWebhooks } = useAppsFailedDeliveries(); | ||
|
|
||
| // TODO: Implement fetching at intervals | ||
| useEffect(() => { | ||
| fetchAppsWebhooks(); | ||
| }, []); | ||
|
|
||
| return { | ||
| hasFailedAttempts: hasFailed, | ||
| }; | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.