Skip to content

Commit 97e63d1

Browse files
authored
Event Trigger Example Payload: Fix unsetting icon, and Use fallback icon in case of invalid icon-name. (#576)
* fix: unset event-trigger example icon * fix: use fallback icon when an invalid icon is used (example payload page)
1 parent 87ee98a commit 97e63d1

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.jobs.$jobParam.test/route.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { TestJobService } from "~/services/jobs/testJob.server";
3535
import { requireUserId } from "~/services/session.server";
3636
import { cn } from "~/utils/cn";
3737
import { Handle } from "~/utils/handle";
38+
import { isValidIcon } from "~/utils/icon";
3839
import { JobParamsSchema, jobRunDashboardPath, trimTrailingSlash } from "~/utils/pathBuilder";
3940

4041
export const loader = async ({ request, params }: LoaderArgs) => {
@@ -228,7 +229,7 @@ export default function Page() {
228229
}}
229230
>
230231
<DetailCell
231-
leadingIcon={example.icon ?? CodeBracketIcon}
232+
leadingIcon={isValidIcon(example.icon) ? example.icon : CodeBracketIcon}
232233
leadingIconClassName="text-blue-500"
233234
label={example.name}
234235
trailingIcon={example.id === selectedCodeSampleId ? "check" : "plus"}

apps/webapp/app/services/jobs/registerJob.server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ export class RegisterJobService {
222222
},
223223
update: {
224224
name: example.name,
225-
icon: example.icon,
225+
icon: example.icon ?? null,
226226
payload: example.payload,
227227
},
228228
});

apps/webapp/app/utils/icon.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { hasIcon } from "@trigger.dev/companyicons";
2+
import { iconNames as namedIcons } from "~/components/primitives/NamedIcon";
3+
4+
export const isValidIcon = (icon?: string): boolean => {
5+
if (!icon) {
6+
return false;
7+
}
8+
return namedIcons.includes(icon) || hasIcon(icon);
9+
};

0 commit comments

Comments
 (0)