File size: 2,022 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import type { ButtonProps, IconProps, VariantType } from '@adminjs/design-system'

import { ParsedLayoutElement } from '../../../backend/utils/layout-element-parser/index.js'

/**
 * JSON representation of an {@link Action}
 * @see Action
 * @subcategory Frontend
 */
export interface ActionJSON {
  /**
   * Unique action name
   */
  name: string;
  /**
   * Type of an action
   */
  actionType: 'record' | 'resource' | 'bulk';
  /**
   * Action icon
   */
  icon?: IconProps['icon'];
  /**
   * Action label - visible on the frontend
   */
  label: string;
  /**
   * Guarding message which should be presented in `alert()` after clicking the action button
   */
  guard?: string;
  /**
   * If action should have a filter (for resource actions)
   */
  showFilter: boolean;
  /**
   * If action should have resource actions buttons displayed above action header.
   *
   * Defaults to `true`
   */
  showResourceActions: boolean;
  /**
   * Action component. When set to false action will be invoked immediately after clicking it,
   * to put in another words: there wont be an action view
   */
  component?: string | false | null;
  /**
   * Whether given action should be seen in a drawer
   */
  showInDrawer: boolean;
  /**
   * Whether given action have an action header
   */
  hideActionHeader: boolean;
  /**
   * containerWidth passed from the action setup.
   */
  containerWidth: string | number | Array<string | number>;
  /**
   * Id of a resource to which given action belongs.
   */
  resourceId: string;

  /**
   * Parsed layout passed in {@link Action#layout}
   */
  layout: Array<ParsedLayoutElement> | null;

  /**
   * Action variant
   */
  variant: VariantType;

  /**
   * Action color
   */
  color?: ButtonProps['color'];

  /**
   * If action is nested
   */
  parent: string | null;

  /**
   * Indicates if action has action handler defined
   */
  hasHandler: boolean;

  /**
   * Any custom options passed from the {@link Action} configuration.
   */
  custom: Record<string, any>;
}