Skip to content

Commit bed3788

Browse files
author
Feroze Mohideen
authored
Add link to job run in notifications (#4027)
1 parent f07f194 commit bed3788

File tree

11 files changed

+44
-26
lines changed

11 files changed

+44
-26
lines changed

api/server/handlers/porter_app/create_and_update_events.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ func (p *CreateUpdatePorterAppEventHandler) handleNotification(ctx context.Conte
653653
PorterAgentEventId: int64(agentEventMetadata.AgentEventID),
654654
RawSummary: agentEventMetadata.Summary,
655655
RawDetail: agentEventMetadata.Detail,
656+
JobRunId: agentEventMetadata.JobRunID,
656657
})
657658

658659
_, err = p.Config().ClusterControlPlaneClient.CreateNotification(ctx, createNotificationRequest)

dashboard/src/main/home/app-dashboard/app-view/tabs/activity-feed/events/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ const serviceNoticationValidator = z.object({
7979
status: z.literal("UNKNOWN"),
8080
}),
8181
]),
82+
job_run_id: z.string(),
8283
}),
8384
});
8485
const revisionNotificationValidator = z.object({

dashboard/src/main/home/app-dashboard/app-view/tabs/notifications/NotificationFeed.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React, { useEffect, useState } from "react";
22
import { useHistory, useLocation } from "react-router";
33
import styled from "styled-components";
44

5-
import Container from "components/porter/Container";
65
import Fieldset from "components/porter/Fieldset";
76
import Link from "components/porter/Link";
87
import Spacer from "components/porter/Spacer";
@@ -68,7 +67,7 @@ const NotificationFeed: React.FC<Props> = ({
6867
return (
6968
<StyledNotificationFeed>
7069
{selectedNotification ? (
71-
<Container>
70+
<>
7271
<Link to={`/apps/${appName}/notifications`}>
7372
<BackButton>
7473
<i className="material-icons">keyboard_backspace</i>
@@ -84,7 +83,7 @@ const NotificationFeed: React.FC<Props> = ({
8483
deploymentTargetId={deploymentTargetId}
8584
appId={appId}
8685
/>
87-
</Container>
86+
</>
8887
) : (
8988
<NotificationList
9089
notifications={notifications}
@@ -103,6 +102,7 @@ export default NotificationFeed;
103102

104103
const StyledNotificationFeed = styled.div`
105104
display: flex;
105+
flex-direction: column;
106106
margin-bottom: -50px;
107107
width: 100%;
108108
animation: fadeIn 0.3s 0s;

dashboard/src/main/home/app-dashboard/app-view/tabs/notifications/NotificationTile.tsx

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { match } from "ts-pattern";
44

55
import Container from "components/porter/Container";
66
import Spacer from "components/porter/Spacer";
7+
import Tag from "components/porter/Tag";
78
import Text from "components/porter/Text";
89
import {
910
isClientServiceNotification,
@@ -29,6 +30,8 @@ const NotificationTile: React.FC<Props> = ({ notification, onClick }) => {
2930
.with({ scope: "SERVICE" }, (n) => {
3031
return n.isDeployRelated
3132
? "A service failed to deploy"
33+
: ["job", "predeploy"].includes(n.service.config.type)
34+
? "A job run encountered issues"
3235
: "A service is unhealthy";
3336
})
3437
.with({ scope: "APPLICATION" }, () => {
@@ -52,16 +55,16 @@ const NotificationTile: React.FC<Props> = ({ notification, onClick }) => {
5255
<Spacer inline x={0.5} />
5356
{isClientServiceNotification(notification) && (
5457
<Container row style={{ width: "200px" }}>
55-
<ServiceNameTag>
58+
<Tag>
5659
{match(notification.service.config.type)
5760
.with("web", () => <ServiceTypeIcon src={web} />)
5861
.with("worker", () => <ServiceTypeIcon src={worker} />)
5962
.with("job", () => <ServiceTypeIcon src={job} />)
6063
.with("predeploy", () => <ServiceTypeIcon src={job} />)
6164
.exhaustive()}
6265
<Spacer inline x={0.5} />
63-
{notification.service.name.value}
64-
</ServiceNameTag>
66+
<Text>{notification.service.name.value}</Text>
67+
</Tag>
6568
</Container>
6669
)}
6770
</Container>
@@ -103,19 +106,9 @@ const NotificationSummary = styled.div`
103106
font-weight: 500;
104107
`;
105108

106-
const ServiceNameTag = styled.div`
107-
display: flex;
108-
justify-content: center;
109-
padding: 3px 5px;
110-
border-radius: 5px;
111-
background: #ffffff22;
112-
user-select: text;
113-
font-size: 13px;
114-
`;
115-
116109
const ServiceTypeIcon = styled.img`
117-
height: 12px;
118-
margin-top: 2px;
110+
height: 13px;
111+
margin-top: 4px;
119112
`;
120113

121114
const StatusDot = styled.div<{ color: string }>`

dashboard/src/main/home/app-dashboard/app-view/tabs/notifications/expanded-views/NotificationExpandedView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export default NotificationExpandedView;
5050

5151
export const StyledNotificationExpandedView = styled.div`
5252
height: 100%;
53+
width: 100%;
5354
display: flex;
5455
justify-content: space-between;
5556
flex-direction: column;

dashboard/src/main/home/app-dashboard/app-view/tabs/notifications/expanded-views/ServiceNotificationExpandedView.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ const ServiceNotificationExpandedView: React.FC<Props> = ({
5555
{notification.service.name.value}
5656
</ServiceNameTag>
5757
<Spacer inline x={0.5} />
58-
5958
<Text size={16} color={"#FFBF00"}>
6059
{notification.isDeployRelated
6160
? "failed to deploy"

dashboard/src/main/home/app-dashboard/app-view/tabs/notifications/expanded-views/messages/ServiceMessage.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ const ServiceMessage: React.FC<Props> = ({
6161
<Container row>
6262
<img
6363
src={document}
64-
style={{ width: "15px", marginRight: "15px" }}
64+
style={{ width: "15px", marginRight: "10px" }}
6565
/>
6666
{message.error.summary}
6767
</Container>
6868
<Container row>
69-
<img src={time} style={{ width: "15px", marginRight: "15px" }} />
69+
<img src={time} style={{ width: "15px", marginRight: "10px" }} />
7070
<Text>{feedDate(message.timestamp)}</Text>
7171
</Container>
7272
</Container>
@@ -121,7 +121,26 @@ const ServiceMessage: React.FC<Props> = ({
121121
</ul>
122122
</>
123123
)}
124-
124+
{service.config.type === "job" && message.metadata.job_run_id && (
125+
<Container row>
126+
<Tag>
127+
<Link
128+
to={`/apps/${appName}/job-history?job_run_id=${message.metadata.job_run_id}&service=${service.name.value}`}
129+
>
130+
<Text size={16}>Job run</Text>
131+
<i
132+
className="material-icons"
133+
style={{
134+
fontSize: "16px",
135+
marginLeft: "5px",
136+
}}
137+
>
138+
open_in_new
139+
</i>
140+
</Link>
141+
</Tag>
142+
</Container>
143+
)}
125144
{service.config.type !== "job" && message.error.should_view_logs && (
126145
<>
127146
<Container row>

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ require (
8383
github.com/matryer/is v1.4.0
8484
github.com/nats-io/nats.go v1.24.0
8585
github.com/open-policy-agent/opa v0.44.0
86-
github.com/porter-dev/api-contracts v0.2.55
86+
github.com/porter-dev/api-contracts v0.2.56
8787
github.com/riandyrn/otelchi v0.5.1
8888
github.com/santhosh-tekuri/jsonschema/v5 v5.0.1
8989
github.com/stefanmcshane/helm v0.0.0-20221213002717-88a4a2c6e77d

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
15221522
github.com/polyfloyd/go-errorlint v0.0.0-20210722154253-910bb7978349/go.mod h1:wi9BfjxjF/bwiZ701TzmfKu6UKC357IOAtNr0Td0Lvw=
15231523
github.com/porter-dev/api-contracts v0.2.55 h1:H8RvD004mX4uWrlRVcL8kzo7ZtFQyZDN+X9j+2bW7fc=
15241524
github.com/porter-dev/api-contracts v0.2.55/go.mod h1:fX6JmP5QuzxDLvqP3evFOTXjI4dHxsG0+VKNTjImZU8=
1525+
github.com/porter-dev/api-contracts v0.2.56 h1:zym8eomipCj7BVQVlnCY4RjNv1tkduY68gsmwVJIfaQ=
1526+
github.com/porter-dev/api-contracts v0.2.56/go.mod h1:fX6JmP5QuzxDLvqP3evFOTXjI4dHxsG0+VKNTjImZU8=
15251527
github.com/porter-dev/switchboard v0.0.3 h1:dBuYkiVLa5Ce7059d6qTe9a1C2XEORFEanhbtV92R+M=
15261528
github.com/porter-dev/switchboard v0.0.3/go.mod h1:xSPzqSFMQ6OSbp42fhCi4AbGbQbsm6nRvOkrblFeXU4=
15271529
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=

internal/porter_app/notifications/app_event.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ type AppEventMetadata struct {
2828
AppName string `json:"app_name"`
2929
// Detail is the detail of the app event
3030
Detail string `json:"detail"`
31+
// JobRunID is the ID of the job run that this event refers to, if applicable
32+
JobRunID string `json:"job_run_id"`
3133
}
3234

3335
// ParseAgentEventMetadata parses raw app event metadata to a AppEventMetadata struct

0 commit comments

Comments
 (0)