Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterEnum
ALTER TYPE "AutomationType" ADD VALUE 'INCIDENT_DETECTION';
1 change: 1 addition & 0 deletions apps/api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ enum IntegrationApp {
enum AutomationType {
PR_TITLE_CHECK
PR_SIZE_LABELER
INCIDENT_DETECTION
}

enum DigestType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export default /* GraphQL */ `
enum AutomationType {
PR_TITLE_CHECK
PR_SIZE_LABELER
INCIDENT_DETECTION
}

type Automation {
Expand Down
25 changes: 24 additions & 1 deletion apps/api/src/app/automations/services/automation.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export interface CanRunAutomationArgs {
export type AutomationTypeMap = {
[AutomationType.PR_TITLE_CHECK]: AutomationPrTitleCheck;
[AutomationType.PR_SIZE_LABELER]: AutomationPrSizeLabeler;
[AutomationType.INCIDENT_DETECTION]: AutomationIncidentDetection;
};

export interface AutomationPrTitleCheck extends Omit<Automation, "settings"> {
Expand All @@ -54,13 +55,35 @@ export interface AutomationPrSizeLabeler extends Omit<Automation, "settings"> {

export type AutomationSettings =
| AutomationPrTitleCheck
| AutomationPrSizeLabeler;
| AutomationPrSizeLabeler
| AutomationIncidentDetection;

export interface PrTitleCheckSettings extends Prisma.JsonObject {
regex?: string;
regexExample?: string;
}

export interface AutomationIncidentDetection
extends Omit<Automation, "settings"> {
type: typeof AutomationType.INCIDENT_DETECTION;
settings: IncidentDetectionSettings;
}

export interface IncidentDetectionSettings {
revert?: {
enabled?: boolean;
};
hotfix?: {
enabled?: boolean;
prTitleRegEx?: string;
branchRegEx?: string;
prLabelRegEx?: string;
};
rollback?: {
enabled?: boolean;
};
}

export interface PrSizeLabelerSettings {
repositories?: string[];
labels?: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,32 @@ export const CardAutomation = ({
p="md"
style={{ borderBottom: "1px solid #303030", flexGrow: 1 }}
>
<Stack gap="md" h="100%">
<Group gap={5}>
{benefits &&
Object.entries(benefits).map(
([key, value]) =>
value && (
<IconAutomationBenefit
key={key}
enabled={enabled}
benefit={key as AutomationBenefit}
/>
),
)}
</Group>
<Box style={{ flexGrow: 1 }}>
<Title order={2} size="h4">
{title}
</Title>
<Text mt={5}>{description}</Text>
</Box>
<Stack gap="md" h="100%" mih={191} justify="space-between">
<Stack gap="md">
<Group gap={5}>
{benefits &&
Object.entries(benefits).map(
([key, value]) =>
value && (
<IconAutomationBenefit
key={key}
enabled={enabled}
benefit={key as AutomationBenefit}
/>
),
)}
</Group>
<Box style={{ flexGrow: 1 }}>
<Title order={2} size="h4">
{title}
</Title>
<Text mt={5}>{description}</Text>
</Box>
</Stack>

<BadgeStoreStatus enabled={enabled} available={available} />
<Box>
<BadgeStoreStatus enabled={enabled} available={available} />
</Box>
</Stack>
</Card.Section>
</Card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export const HeaderAutomation = ({ automation }: HeaderAutomationProps) => {
return (
<>
<Stack p="md">
<ImageDemo title={automation.title} src={automation.demoUrl} />
{automation.demoUrl && (
<ImageDemo title={automation.title} src={automation.demoUrl} />
)}

<Text>{automation.description}</Text>
<SectionBenefits benefits={automation.benefits} />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import {
Divider,
SimpleGrid,
Stack,
Switch,
TextInput,
Title,
} from "@mantine/core";
import { BoxSetting } from "../../../../../../components/box-setting";
import { UseFormReturnType } from "@mantine/form";
import { FormIncidentDetection } from "../../types";

interface FormIncidentDetectionSettingsProps {
form: UseFormReturnType<FormIncidentDetection>;
}

export const FormIncidentDetectionSettings = ({
form,
}: FormIncidentDetectionSettingsProps) => {
return (
<>
<Stack p="md">
<Title order={5}>Settings</Title>

<BoxSetting label="Enabled">
<Switch
size="lg"
color="green.7"
onLabel="ON"
offLabel="OFF"
{...form.getInputProps("enabled", { type: "checkbox" })}
/>
</BoxSetting>
</Stack>

{form.values.enabled && (
<>
<Divider my="sm" />

<Stack p="md">
<Title order={5}>Reverts</Title>

<BoxSetting
label="Create incident on deployed reverts"
description="Automatically creates an incident when a revert PR is deployed."
>
<Switch
size="lg"
color="green.7"
onLabel="ON"
offLabel="OFF"
{...form.getInputProps("settings.revert.enabled", {
type: "checkbox",
})}
/>
</BoxSetting>
</Stack>

<Divider my="sm" />

<Stack p="md">
<Title order={5}>Rollback</Title>

<BoxSetting
label="Create incident on rollbacks"
description="Automatically creates an incident when a rollback is detected."
>
<Switch
size="lg"
color="green.7"
onLabel="ON"
offLabel="OFF"
{...form.getInputProps("settings.rollback.enabled", {
type: "checkbox",
})}
/>
</BoxSetting>
</Stack>

<Divider my="sm" />

<Stack p="md">
<Title order={5}>Hotfixes</Title>
<BoxSetting
label="Create incident on deployed hotfixes"
description="Automatically creates an incident when a hotfix PR is deployed."
>
<Switch
size="lg"
color="green.7"
onLabel="ON"
offLabel="OFF"
{...form.getInputProps("settings.hotfix.enabled", {
type: "checkbox",
})}
/>
</BoxSetting>
{form.values.settings.hotfix?.enabled && (
<SimpleGrid cols={2}>
<TextInput
label="Pull Request Title"
description="Regular expression to match against the PR title."
placeholder="hotfix"
maxLength={200}
{...form.getInputProps("settings.hotfix.prTitleRegEx")}
/>
<TextInput
label="Branch Pattern"
description="Regular expression to match against the branch name."
placeholder="^hotfix"
maxLength={200}
{...form.getInputProps("settings.hotfix.branchRegEx")}
/>
<TextInput
label="Pull Request Label"
description="Regular expression to match against PR labels."
placeholder="hotfix"
maxLength={200}
{...form.getInputProps("settings.hotfix.prLabelRegEx")}
/>
</SimpleGrid>
)}
</Stack>
</>
)}
</>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { FormIncidentDetectionSettings } from "./form-incident-detection-settings";
Loading
Loading