UNPKG

@atlassian/johnson

Version:

A frontend module for Johnson framework

167 lines (140 loc) 4.04 kB
// TypeScript definitions for @atlassian/johnson import * as React from 'react'; // ============================================================================ // CONSTANTS // ============================================================================ // Product names export type ProductName = 'confluence' | 'jira'; export const CONFLUENCE: ProductName; export const JIRA: ProductName; // Event levels export type EventLevel = 'fatal' | 'error' | 'warning' | 'success'; // ============================================================================ // INTERFACES // ============================================================================ // Template context for events export interface TemplateContext { type: string; filesThatCanBeCopied?: string[]; filesThatCannotBeCopied?: string[]; numberOfFilesCopied?: number; } // Event interface export interface Event { description?: string; eventId?: string; helpLink?: string; level: EventLevel; templateContext?: TemplateContext; title?: string; dismissible?: boolean; old?: boolean; date?: string; exception?: string; additionalMarkup?: string; progress?: number; } // Events grouped by type export interface EventsByType { error?: Event[]; success?: Event[]; warning?: Event[]; } // Statistics export interface Stats { total?: number; } // Endpoints configuration export interface Endpoints { addAndRemoveSystemProps: string; data: string; dismissEvents: string; eventKbClickedAnalytics: string; findTheLogs: string; generalKbClickedAnalytics: string; home: string; kbLinkStartStop: string; migrateConfig: string; } // Initial data structure export interface InitialData { canAuthoriseUsers?: boolean; checksComplete?: boolean; events?: Event[]; errorsPresentButHidden?: boolean; } // i18n function type export type I18nFunction = (...args: unknown[]) => string; // i18n object (can contain any translation keys) export type I18nObject = Record<string, string>; // Redux state interfaces export interface EventsState { canAuthoriseUsers?: boolean; checksComplete?: boolean; dismissiblesOnly?: boolean; hasNonDismissibleErrors?: boolean; hasDismissibles?: boolean; errorsPresentButHidden?: boolean; newEvents?: EventsByType; oldEvents?: Event[][]; stats?: Stats; warningsOnly?: boolean; } export interface GlobalState { productName: ProductName; } export interface RootState { endpoints: Partial<Endpoints>; events: EventsState; global: GlobalState; } // ============================================================================ // COMPONENT PROPS // ============================================================================ // Main Johnson component props export interface JohnsonProps { endpoints: Endpoints; i18n: I18nObject; initialData?: InitialData; productName: ProductName; } // App component props (internal) export interface AppProps { endpoints: Partial<Endpoints>; i18n: I18nObject; initialData?: Record<string, unknown> | null; setEventsData: (data: unknown) => void; } // ============================================================================ // MAIN COMPONENT // ============================================================================ // Main Johnson component class declare class Johnson extends React.PureComponent<JohnsonProps> { static defaultProps: { initialData: object; }; } // Default export export default Johnson; // Named exports export { Johnson }; // ============================================================================ // UTILITY TYPES // ============================================================================ // Context types export interface AppContext { i18n: I18nFunction; } // Action types for Redux export interface SetEventsDataAction { type: string; payload: EventsState; } // API response types export interface ApiResponse { canAuthoriseUsers?: boolean; checksComplete?: boolean; events?: Event[]; errorsPresentButHidden?: boolean; [key: string]: unknown; }