|
|
@@ -10,7 +10,10 @@ import Tag from "components/porter/Tag";
|
|
|
import Text from "components/porter/Text";
|
|
|
import Logs from "main/home/app-dashboard/validate-apply/logs/Logs";
|
|
|
import { useIntercom } from "lib/hooks/useIntercom";
|
|
|
-import { type ClientNotification } from "lib/porter-apps/notification";
|
|
|
+import {
|
|
|
+ isClientServiceNotification,
|
|
|
+ type ClientNotification,
|
|
|
+} from "lib/porter-apps/notification";
|
|
|
|
|
|
import { feedDate } from "shared/string_utils";
|
|
|
import calendar from "assets/calendar-02.svg";
|
|
|
@@ -41,55 +44,71 @@ const NotificationExpandedView: React.FC<Props> = ({
|
|
|
const { showIntercomWithMessage } = useIntercom();
|
|
|
|
|
|
const summary = useMemo(() => {
|
|
|
- if (notification.isDeployRelated) {
|
|
|
- return "failed to deploy";
|
|
|
- } else {
|
|
|
- return "is unhealthy";
|
|
|
- }
|
|
|
+ return match(notification)
|
|
|
+ .with({ scope: "REVISION" }, () => {
|
|
|
+ return "The latest version failed to deploy";
|
|
|
+ })
|
|
|
+ .with({ scope: "SERVICE" }, (n) => {
|
|
|
+ return n.isDeployRelated ? "failed to deploy" : "is unhealthy";
|
|
|
+ })
|
|
|
+ .with({ scope: "APPLICATION" }, () => {
|
|
|
+ return "The application failed to deploy";
|
|
|
+ })
|
|
|
+ .otherwise(() => {
|
|
|
+ return "";
|
|
|
+ });
|
|
|
}, [JSON.stringify(notification)]);
|
|
|
|
|
|
const serviceNames = useMemo(() => {
|
|
|
+ if (!isClientServiceNotification(notification)) {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
if (notification.service.config.type === "predeploy") {
|
|
|
return ["predeploy"];
|
|
|
}
|
|
|
return [notification.service.name.value];
|
|
|
- }, [notification.service.name.value]);
|
|
|
+ }, [JSON.stringify(notification)]);
|
|
|
|
|
|
return (
|
|
|
<StyledNotificationExpandedView>
|
|
|
<ExpandedViewContent>
|
|
|
<Container row spaced>
|
|
|
<Container row>
|
|
|
- <ServiceNameTag>
|
|
|
- {match(notification.service.config.type)
|
|
|
- .with("web", () => <ServiceTypeIcon src={web} />)
|
|
|
- .with("worker", () => <ServiceTypeIcon src={worker} />)
|
|
|
- .with("job", () => <ServiceTypeIcon src={job} />)
|
|
|
- .with("predeploy", () => <ServiceTypeIcon src={job} />)
|
|
|
- .exhaustive()}
|
|
|
- <Spacer inline x={0.5} />
|
|
|
- {notification.service.name.value}
|
|
|
- </ServiceNameTag>
|
|
|
- <Spacer inline x={0.5} />
|
|
|
+ {isClientServiceNotification(notification) && (
|
|
|
+ <>
|
|
|
+ <ServiceNameTag>
|
|
|
+ {match(notification.service.config.type)
|
|
|
+ .with("web", () => <ServiceTypeIcon src={web} />)
|
|
|
+ .with("worker", () => <ServiceTypeIcon src={worker} />)
|
|
|
+ .with("job", () => <ServiceTypeIcon src={job} />)
|
|
|
+ .with("predeploy", () => <ServiceTypeIcon src={job} />)
|
|
|
+ .exhaustive()}
|
|
|
+ <Spacer inline x={0.5} />
|
|
|
+ {notification.service.name.value}
|
|
|
+ </ServiceNameTag>
|
|
|
+ <Spacer inline x={0.5} />
|
|
|
+ </>
|
|
|
+ )}
|
|
|
<Text size={16} color={"#FFBF00"}>
|
|
|
{summary}
|
|
|
</Text>
|
|
|
</Container>
|
|
|
- {notification.service.config.type === "job" && (
|
|
|
- <Container row>
|
|
|
- <Tag>
|
|
|
- <TagIcon
|
|
|
- src={calendar}
|
|
|
- style={{ marginTop: "3px", marginLeft: "5px" }}
|
|
|
- />
|
|
|
- <Link
|
|
|
- to={`/apps/${appName}/job-history?service=${notification.service.name.value}`}
|
|
|
- >
|
|
|
- <Text size={16}>Job history</Text>
|
|
|
- </Link>
|
|
|
- </Tag>
|
|
|
- </Container>
|
|
|
- )}
|
|
|
+ {isClientServiceNotification(notification) &&
|
|
|
+ notification.service.config.type === "job" && (
|
|
|
+ <Container row>
|
|
|
+ <Tag>
|
|
|
+ <TagIcon
|
|
|
+ src={calendar}
|
|
|
+ style={{ marginTop: "3px", marginLeft: "5px" }}
|
|
|
+ />
|
|
|
+ <Link
|
|
|
+ to={`/apps/${appName}/job-history?service=${notification.service.name.value}`}
|
|
|
+ >
|
|
|
+ <Text size={16}>Job history</Text>
|
|
|
+ </Link>
|
|
|
+ </Tag>
|
|
|
+ </Container>
|
|
|
+ )}
|
|
|
</Container>
|
|
|
<Spacer y={0.5} />
|
|
|
<StyledActivityFeed>
|
|
|
@@ -173,21 +192,22 @@ const NotificationExpandedView: React.FC<Props> = ({
|
|
|
})}
|
|
|
</StyledActivityFeed>
|
|
|
<Spacer y={1} />
|
|
|
- {notification.service.config.type !== "job" && (
|
|
|
- <Logs
|
|
|
- projectId={projectId}
|
|
|
- clusterId={clusterId}
|
|
|
- appName={appName}
|
|
|
- serviceNames={serviceNames}
|
|
|
- deploymentTargetId={deploymentTargetId}
|
|
|
- appRevisionId={notification.appRevisionId}
|
|
|
- logFilterNames={["service_name"]}
|
|
|
- appId={appId}
|
|
|
- selectedService={serviceNames[0]}
|
|
|
- selectedRevisionId={notification.appRevisionId}
|
|
|
- defaultScrollToBottomEnabled={false}
|
|
|
- />
|
|
|
- )}
|
|
|
+ {isClientServiceNotification(notification) &&
|
|
|
+ notification.service.config.type !== "job" && (
|
|
|
+ <Logs
|
|
|
+ projectId={projectId}
|
|
|
+ clusterId={clusterId}
|
|
|
+ appName={appName}
|
|
|
+ serviceNames={serviceNames}
|
|
|
+ deploymentTargetId={deploymentTargetId}
|
|
|
+ appRevisionId={notification.appRevisionId}
|
|
|
+ logFilterNames={["service_name"]}
|
|
|
+ appId={appId}
|
|
|
+ selectedService={serviceNames[0]}
|
|
|
+ selectedRevisionId={notification.appRevisionId}
|
|
|
+ defaultScrollToBottomEnabled={false}
|
|
|
+ />
|
|
|
+ )}
|
|
|
</ExpandedViewContent>
|
|
|
{/* uncomment below once we implement recommended actions */}
|
|
|
{/* <ExpandedViewFooter>
|