Skip to content

Commit

Permalink
fix: link playbooks & notification dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Dec 19, 2024
1 parent ca98fda commit e66cbc3
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/api/services/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function fetchPermissions(
"team:team_id(id, name, icon)",
`person:person_id(${AVATAR_INFO})`,
`createdBy:created_by(${AVATAR_INFO})`,
`notification:notification_id(id,name)`,
`notification:notification_id(id,name,namespace)`,
`connection:connection_id(id,name,type)`
];

Expand Down
1 change: 1 addition & 0 deletions src/api/types/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Team, User } from "./users";

export type NotificationRules = {
id: string;
namespace?: string;
name: string;
title?: string;
events: string[];
Expand Down
3 changes: 2 additions & 1 deletion src/api/types/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type PermissionTable = {
created_by: string;
connection_id?: string;
person_id?: string;
notification_id?: string;
team_id?: string;
updated_by: string;
created_at: string;
Expand All @@ -37,7 +38,7 @@ export type PermissionAPIResponse = PermissionTable & {
playbook: Pick<PlaybookSpec, "id" | "name" | "icon" | "title">;
team: Pick<Team, "id" | "name" | "icon">;
connection: Pick<Connection, "id" | "name" | "type">;
notification: Pick<NotificationRules, "id" | "name">;
notification: Pick<NotificationRules, "id" | "name" | "namespace">;
person: User;
createdBy: User;
};
1 change: 1 addition & 0 deletions src/api/types/playbooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export interface PlaybookRun extends CreatedAt, Avatar, Agent {
check_id?: string;
config_id?: string;
component_id?: string;
notification_send_id?: string;
parameters?: Record<string, unknown>;
/* relationships */
playbooks?: PlaybookSpec;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export default function PermissionForm({
updated_at: data?.updated_at,
updated_by: data?.updated_by,
id: data?.id,
notification_id: data?.notification_id,
person_id: data?.person_id,
team_id: data?.team_id,
until: data?.until,
Expand Down
11 changes: 9 additions & 2 deletions src/components/Permissions/PermissionsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { TopologyLink } from "../Topology/TopologyLink";
import { permissionObjectList } from "./ManagePermissions/Forms/FormikPermissionSelectResourceFields";
import { permissionsActionsList } from "./PermissionsView";
import { BsBan } from "react-icons/bs";
import { Link } from "react-router-dom";

const permissionsTableColumns: MRT_ColumnDef<PermissionAPIResponse>[] = [
{
Expand Down Expand Up @@ -75,11 +76,17 @@ const permissionsTableColumns: MRT_ColumnDef<PermissionAPIResponse>[] = [
);
}

console.log("what");
if (notification) {
return (
<div className="flex flex-row items-center gap-2">
<span>{"notification/" + notification.name}</span>
<span>
<Link to="/notifications/rules?id=f488a83b-ee27-40c9-932e-3da77f02a5b9">
{"notification: " +
notification.namespace +
"/" +
notification.name}
</Link>
</span>
</div>
);
}
Expand Down
10 changes: 10 additions & 0 deletions src/components/Playbooks/Runs/Actions/PlaybookRunsActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ export default function PlaybookRunsActions({
}
/>
)}
{data.notification_send_id && (
<VerticalDescription
label="Trigger by notification"
value={
<Link to={`/notifications?id=${data.notification_send_id}`}>
{"Link"}
</Link>
}
/>
)}
</div>
<div className="ml-auto flex h-auto flex-col justify-center gap-2">
<div className="flex flex-row gap-2">
Expand Down

0 comments on commit e66cbc3

Please sign in to comment.