All files / web/src/constants/ui messages.ts

100% Statements 134/134
100% Branches 2/2
7.4% Functions 2/27
100% Lines 134/134

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227              1x   1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x     1x 1x 1x     1x 1x 1x     1x 1x     1x 1x     1x 1x     1x 1x         1x   1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x     1x 1x 1x     1x 1x 1x     1x 1x 1x         1x   1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x     1x 1x 1x         1x 1x 1x 1x         1x   1x 1x 1x 1x 1x     1x 1x     1x 1x 1x     1x 1x         1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x     1x 1x 1x 1x         1x 1x 1x 1x 1x 1x 1x 1x         1x 1x 1x         1x 1x 1x 1x 1x 1x 1x 1x 1x                  
/**
 * UI message constants for user feedback
 */
 
/**
 * Success message templates
 */
export const SUCCESS_MESSAGES = {
  // Generic CRUD operations
  CREATED: (item: string) => `${item} created successfully`,
  UPDATED: (item: string) => `${item} updated successfully`,
  DELETED: (item: string) => `${item} deleted successfully`,
  SAVED: (item: string) => `${item} saved successfully`,
 
  // Specific operations
  EXPORTED: (item: string) => `${item} exported successfully`,
  IMPORTED: (item: string) => `${item} imported successfully`,
  ACTIVATED: (item: string) => `${item} activated successfully`,
  DEACTIVATED: (item: string) => `${item} deactivated successfully`,
  EXECUTED: (item: string) => `${item} executed successfully`,
  CONNECTED: 'Connected successfully',
  COPIED: 'Copied to clipboard',
  CLEARED: (item: string) => `${item} cleared`,
  DUPLICATED: (item: string) => `${item} duplicated`,
 
  // Workflow specific
  WORKFLOW_CREATED: 'Workflow created successfully',
  WORKFLOW_UPDATED: 'Workflow updated successfully',
  WORKFLOW_DELETED: 'Workflow deleted successfully',
  WORKFLOW_SAVED: 'Workflow saved successfully',
  WORKFLOW_EXPORTED: 'Workflow exported successfully',
  WORKFLOW_IMPORTED: 'Workflow imported successfully',
 
  // Agent specific
  AGENT_CREATED: 'Agent created successfully',
  AGENT_UPDATED: 'Agent updated successfully',
  AGENT_DELETED: 'Agent deleted successfully',
 
  // Secret management
  SECRET_CREATED: 'Secret created successfully',
  SECRET_UPDATED: 'Secret updated successfully',
  SECRET_DELETED: 'Secret deleted successfully',
 
  // Workflow activation
  WORKFLOW_ACTIVATED: 'Workflow activated successfully',
  WORKFLOW_DEACTIVATED: 'Workflow deactivated successfully',
 
  // Node testing
  NODE_TEST_SUCCESS: 'Node test passed successfully',
  TEST_PASSED: 'Test passed successfully',
 
  // Node execution
  NODE_EXECUTION_STARTED: 'Node execution started',
  NODE_EXECUTION_COMPLETED: 'Node execution completed successfully',
 
  // Execution state
  EXECUTION_CLEARED: 'Execution state cleared',
} as const
 
/**
 * Error message templates
 */
export const ERROR_MESSAGES = {
  // Generic operation failures
  FAILED_TO_CREATE: (item: string) => `Failed to create ${item}`,
  FAILED_TO_UPDATE: (item: string) => `Failed to update ${item}`,
  FAILED_TO_DELETE: (item: string) => `Failed to delete ${item}`,
  FAILED_TO_SAVE: (item: string) => `Failed to save ${item}`,
  FAILED_TO_LOAD: (item: string) => `Failed to load ${item}`,
  FAILED_TO_EXPORT: (item: string) => `Failed to export ${item}`,
  FAILED_TO_IMPORT: (item: string) => `Failed to import ${item}`,
 
  // Specific errors
  ALREADY_EXECUTING: 'Already executing',
  NOT_FOUND: (item: string) => `${item} not found`,
  INVALID_FORMAT: (item: string) => `Invalid ${item} format`,
  CONNECTION_FAILED: 'Connection failed',
  NETWORK_ERROR: 'Network error, please try again later',
  UNKNOWN_ERROR: 'An unknown error occurred',
 
  // Workflow errors
  WORKFLOW_NOT_FOUND: 'Workflow not found',
  WORKFLOW_EXECUTION_FAILED: 'Workflow execution failed',
  NO_TRIGGER_NODE: 'No trigger node found in workflow',
 
  // Node errors
  NODE_EXECUTION_FAILED: 'Node execution failed',
  NODE_CONFIG_INVALID: 'Node configuration is invalid',
  NODE_INPUT_REQUIRED: 'Node requires input connection',
 
  // General validation errors
  VALIDATION_FAILED: 'Validation failed',
  REQUIRED_FIELD_MISSING: 'Required field is missing',
} as const
 
/**
 * Validation message templates
 */
export const VALIDATION_MESSAGES = {
  // Required fields
  REQUIRED_FIELD: (field: string) => `Please enter ${field}`,
  REQUIRED_SELECT: (field: string) => `Please select ${field}`,
  REQUIRED_PROVIDE: (field: string) => `Please provide ${field}`,
 
  // Specific field validation
  ENTER_NAME: 'Please enter a name',
  ENTER_WORKFLOW_NAME: 'Please enter workflow name',
  ENTER_AGENT_NAME: 'Please enter Agent name',
  SELECT_MODEL: 'Please select an AI model',
  ENTER_PROMPT: 'Please enter a prompt or input',
  ENTER_URL: 'Please enter request URL',
  SET_WEBHOOK_PATH: 'Please set webhook path',
  SET_CRON_EXPRESSION: 'Please set cron expression',
 
  // Format validation
  INVALID_EMAIL: 'Please enter a valid email address',
  INVALID_URL: 'Please enter a valid URL',
  INVALID_CRON: 'Invalid cron expression',
  INVALID_JSON: 'Invalid JSON format',
  INVALID_FORMAT: (item: string) => `Invalid ${item} format`,
 
  // Length limits
  TOO_SHORT: (field: string, min: number) => `${field} must be at least ${min} characters`,
  TOO_LONG: (field: string, max: number) => `${field} must be no more than ${max} characters`,
} as const
 
/**
 * Add REQUIRED_FIELD_MISSING to VALIDATION_MESSAGES for compatibility
 */
export const VALIDATION_MESSAGES_EXTENDED = {
  ...VALIDATION_MESSAGES,
  REQUIRED_FIELD_MISSING: ERROR_MESSAGES.REQUIRED_FIELD_MISSING,
} as const
 
/**
 * Confirmation dialog messages
 */
export const CONFIRM_MESSAGES = {
  // Delete confirmation
  DELETE_CONFIRM: (item: string) => `Are you sure you want to delete this ${item}?`,
  DELETE_WORKFLOW: 'Are you sure you want to delete this workflow?',
  DELETE_AGENT: 'Are you sure you want to delete this Agent?',
  DELETE_SECRET: 'Are you sure you want to delete this secret?',
  DELETE_NODE: 'Are you sure you want to delete this node?',
 
  // Unsaved changes
  UNSAVED_CHANGES: 'You have unsaved changes. Are you sure you want to leave?',
  UNSAVED_WORKFLOW: 'Workflow has unsaved changes. Do you want to save before leaving?',
 
  // Action confirmation
  OVERWRITE_CONFIRM: 'This will overwrite existing data. Continue?',
  CLEAR_ALL: 'Are you sure you want to clear all data?',
  DISCONNECT_NODE: 'Disconnecting will remove related connections. Continue?',
 
  // Destructive actions
  DESTRUCTIVE_ACTION: 'This action cannot be undone. Are you sure?',
} as const
 
/**
 * Loading and status messages
 */
export const LOADING_MESSAGES = {
  // Loading states
  LOADING: 'Loading...',
  SAVING: 'Saving...',
  DELETING: 'Deleting...',
  EXECUTING: 'Executing...',
  PROCESSING: 'Processing...',
  SENDING: 'Sending...',
  IMPORTING: 'Importing...',
  EXPORTING: 'Exporting...',
  TESTING: 'Testing...',
  CONNECTING: 'Connecting...',
 
  // Empty states
  NO_DATA: 'No data available',
  NO_WORKFLOWS: 'No workflows found',
  NO_AGENTS: 'No agents found',
  NO_RESULTS: 'No results found',
  EMPTY_LIST: 'The list is empty',
 
  // Hints
  DRAG_TO_UPLOAD: 'Drag file here or click to upload',
  SELECT_TO_CONTINUE: 'Please select an item to continue',
  SAVE_FIRST: 'Please save the workflow first',
} as const
 
/**
 * Action hint messages
 */
export const HINT_MESSAGES = {
  DOUBLE_CLICK_TO_EDIT: 'Double-click to edit',
  CLICK_TO_SELECT: 'Click to select',
  DRAG_TO_MOVE: 'Drag to move',
  DRAG_TO_CONNECT: 'Drag to connect nodes',
  RIGHT_CLICK_FOR_MENU: 'Right-click for more options',
  USE_KEYBOARD_SHORTCUTS: 'Press ? to view keyboard shortcuts',
} as const
 
/**
 * Info messages
 */
export const INFO_MESSAGES = {
  EXECUTION_CANCELLED: 'Execution cancelled',
} as const
 
/**
 * Combined export of all message constants
 */
export const MESSAGES = {
  SUCCESS: SUCCESS_MESSAGES,
  ERROR: ERROR_MESSAGES,
  VALIDATION: VALIDATION_MESSAGES,
  CONFIRM: CONFIRM_MESSAGES,
  LOADING: LOADING_MESSAGES,
  HINT: HINT_MESSAGES,
  INFO: INFO_MESSAGES,
} as const
 
// Type exports
export type SuccessMessageKey = keyof typeof SUCCESS_MESSAGES
export type ErrorMessageKey = keyof typeof ERROR_MESSAGES
export type ValidationMessageKey = keyof typeof VALIDATION_MESSAGES
export type ConfirmMessageKey = keyof typeof CONFIRM_MESSAGES
export type LoadingMessageKey = keyof typeof LOADING_MESSAGES
export type HintMessageKey = keyof typeof HINT_MESSAGES
export type InfoMessageKey = keyof typeof INFO_MESSAGES