Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

3.4 KB
Raw Blame
export const AUDIT_WEBHOOK_READONLY_NOTICE_CLASS =
  'rounded-md border border-blue-200 bg-blue-50 px-3 py-2 text-xs text-blue-800 dark:border-blue-800 dark:bg-blue-900/25 dark:text-blue-200';

export const AUDIT_WEBHOOK_ENDPOINT_CARD_CLASS =
  'flex items-center justify-between gap-3 rounded-md border border-border bg-surface-alt p-3';

export const AUDIT_WEBHOOK_ENDPOINT_ICON_CLASS =
  'p-2 bg-blue-100 dark:bg-blue-900/25 text-blue-600 dark:text-blue-300 rounded-md shrink-0';

export const AUDIT_WEBHOOK_SECURITY_NOTE_TITLE = 'Security Note';

export const AUDIT_WEBHOOK_SECURITY_NOTE_BODY =
  'Audit webhooks are dispatched asynchronously to avoid blocking user operations. Endpoints should still verify source trust (for example via an ingest secret) before processing events.';

export interface AuditWebhookFeatureGateCopy {
  title: string;
  body: string;
}

export interface AuditWebhookFeatureGateCopyOptions {
  showCommercialCopy?: boolean;
  paidRuntimeRequired?: boolean;
}

export interface AuditWebhookEmptyStateCopy {
  title: string;
}

export function getAuditWebhookFeatureGateCopy(
  options: AuditWebhookFeatureGateCopyOptions = {},
): AuditWebhookFeatureGateCopy {
  if (options.paidRuntimeRequired) {
    return {
      title: 'Pulse Pro runtime required',
      body: 'Your Pro license is active, but this install is running the community runtime. Install the private Pulse Pro runtime to deliver audit webhooks. Public GitHub releases and the public Docker image do not include those Pro runtime hooks.',
    };
  }

  const showCommercialCopy = options.showCommercialCopy !== false;

  if (!showCommercialCopy) {
    return {
      title: 'Audit Webhooks',
      body: 'Audit webhook delivery is not enabled for this instance.',
    };
  }

  return {
    title: 'Audit Webhooks',
    body: 'Audit webhook delivery is available on paid self-hosted and hosted plans.',
  };
}

// People looking for alert delivery land here first because it is the only
// webhook page in Settings (issue #1344 tried to add a Discord webhook from
// it). The panel says what it is for and where alert notifications live.
export function getAuditWebhookNotificationsSignpost() {
  return {
    text: 'These carry security events only. To send alerts to Discord, Slack, ntfy or email, set up',
    linkLabel: 'alert notifications',
  } as const;
}

export function getAuditWebhookEmptyStateCopy(): AuditWebhookEmptyStateCopy {
  return {
    title: 'No audit webhooks configured yet.',
  };
}

export function getAuditWebhookLoadingState() {
  return {
    text: 'Loading audit webhooks…',
  } as const;
}

export function getAuditWebhookReadErrorCopy(hasLoadedConfiguration: boolean) {
  return {
    title: 'Audit webhook configuration could not be loaded.',
    body: hasLoadedConfiguration
      ? 'Last loaded destinations are shown below. Load the configuration before making changes.'
      : 'Existing destinations are unknown. Load the configuration before making changes.',
    retryLabel: 'Retry loading',
  } as const;
}

export function getAuditWebhookInvalidUrlMessage(): string {
  return 'Please enter a valid URL';
}

export function getAuditWebhookDuplicateUrlMessage(): string {
  return 'This URL is already configured';
}

export function getAuditWebhookSaveSuccessMessage(): string {
  return 'Audit webhooks updated';
}

export function getAuditWebhookSaveErrorMessage(): string {
  return 'Failed to save webhook configuration';
}