Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

3.4 KB
Raw Blame
// SPDX-License-Identifier: LicenseRef-Carbon-Commercial
// Carbon Enterprise file, licensed only under the Carbon Commercial License
// (packages/ee/LICENSE). Not AGPL. Running, modifying, or copying it beyond those terms requires a commercial license.

import { Copy, Input, InputGroup, InputRightElement } from "@carbon/react";
import { isBrowser } from "@carbon/utils";
import { z } from "zod";
import { defineIntegration } from "../fns";
import { pieceLogo } from "../integrations/piece-logo";
export const Linear = defineIntegration({
  name: "Linear",
  id: "linear",
  active: true,
  category: "Project Management",
  logo: pieceLogo("linear"),
  description:
    "Linear is a project management software that allows you to create issues and track project progress seamlessly. With this integration, you can link issues and change notices from Carbon to Linear.",
  shortDescription: "Sync issues and change notices from Carbon to Linear.",
  setupInstructions: SetupInstructions,
  images: [],
  settings: [
    {
      name: "apiKey",
      label: "API Key",
      type: "secret",
      required: true,
      value: ""
    },
    {
      name: "webhookSigningSecret",
      label: "Webhook Signing Secret",
      description:
        "Optional. When set, Carbon rejects webhook requests that are not signed with this secret.",
      type: "secret",
      required: false,
      value: ""
    }
  ],
  schema: z.object({
    // Empty means "keep the existing vaulted secret" (the field loads masked and
    // is not sent to the browser). Presence is enforced at install-time in the
    // settings action; a non-empty value must still be a valid Linear key.
    apiKey: z
      .string()
      .refine((val) => val === "" || val.startsWith("lin_api"), {
        message: "Linear API Key must start with 'lin_api'"
      }),
    // Optional, vaulted like apiKey (empty keeps the stored value). When set,
    // the webhook route requires a valid `Linear-Signature` on every delivery.
    webhookSigningSecret: z.string().optional()
  })
});

function SetupInstructions({ companyId }: { companyId: string }) {
  const webhookUrl = isBrowser
    ? `${window.location.origin}/api/webhook/${Linear.id}/${companyId}`
    : "";

  return (
    <>
      <p className="text-sm text-muted-foreground">
        To integrate Linear with Carbon, start by logging into your Linear
        account and navigating to the API settings page.
      </p>
      <p className="text-sm text-muted-foreground">
        Under the "Webhooks" section, click on "New Webhook" and give it a
        descriptive label.
      </p>
      <p className="text-sm text-muted-foreground">
        Copy the webhook URL provided below into the "URL" field.
      </p>
      <InputGroup className="mb-8">
        <Input value={webhookUrl} />
        <InputRightElement>
          <Copy text={webhookUrl} />
        </InputRightElement>
      </InputGroup>

      <p className="text-sm text-muted-foreground">
        After you save the webhook, Linear shows a signing secret on the
        webhook's detail page. Copy it into the "Webhook Signing Secret" field
        below so Carbon only accepts requests that Linear has signed.
      </p>

      <p className="text-sm text-muted-foreground">
        Next, from the sidebar go to "Security and access" page and generate a
        new API key. Copy the generated API key and paste it into the "API Key"
        field below.
      </p>
    </>
  );
}