Skip to content

Commit d75e2af

Browse files
authored
Adding docs for snap-components (#59)
* Init docs for snap-components * add points to add * update docs * remove features that are not there yet
1 parent de38821 commit d75e2af

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Snap Components
2+
3+
Snap components enable adding custom UI components defined by snap-kit to the DevRev UI.
4+
These components can be used to display data or interact with the user.
5+
Snap components are defined in the snap-in manifest file. DevRev UI renders these components based on the defined configuration.
6+
7+
Each snap-component has the following properties:
8+
9+
- `surface` : the surfaces where the snap component can be displayed. Currently, only `issue` is supported. // TODO: Confirm this.
10+
- `snap_kit_action_name` : the name of the snap kit action that will be triggered when the action defined in the snap-kit of the snap component is interacted with.
11+
<!-- - `snap_kit_body` : the initial body of the snap kit action that will be rendered when the snap component is loaded. -->
12+
13+
<!-- - `initializer` : references a function that can be called to initialize the snap component. This is useful when the snap component needs to be initialized with data from the server based on the context where it is being initialized. -->
14+
15+
```yaml
16+
functions:
17+
- name: upgrade_test_function_1
18+
description: first function
19+
20+
snap_kit_actions:
21+
- name: show_test_cases
22+
function: show_test_cases_or_runs
23+
24+
snap_components:
25+
- name: show_test_cases
26+
display_name: Test Case Details
27+
description: Test Case Details
28+
surface: issue
29+
snap_kit_action_name: show_test_cases
30+
<!-- initializer: upgrade_test_function_1 -->
31+
snap_kit_body:
32+
{
33+
"snaps":[]
34+
}
35+
```
36+
37+
## Format of context passed to snap-kit action
38+
39+
```typescript
40+
// The payload contains details and values of the snap-kit from which the action was invoked.
41+
interface Payload {
42+
action: {
43+
block_id: string;
44+
id: string;
45+
timestamp: number;
46+
type: string;
47+
value: string;
48+
};
49+
action_id: string;
50+
actor_id: string;
51+
body: {
52+
snaps: any[];
53+
};
54+
context: {
55+
// id of the object where the snap component is invoked.
56+
object_id: string;
57+
};
58+
dev_org: string;
59+
parent_id: string;
60+
request_id: string;
61+
}
62+
63+
interface Secrets {
64+
actor_session_token: string;
65+
service_account_token: string;
66+
}
67+
68+
interface Context {
69+
dev_oid: string;
70+
// Snap-kit action ID in DONv2 format.
71+
source_id: string;
72+
snap_in_id: string;
73+
snap_in_version_id: string;
74+
service_account_id: string;
75+
secrets: Secrets;
76+
}
77+
78+
interface ExecutionMetadata {
79+
request_id: string;
80+
// function that is being invoked.
81+
function_name: string;
82+
// endpoint for DevRev that can be used to make API calls.
83+
devrev_endpoint: string;
84+
}
85+
86+
interface InputData {
87+
global_values: {
88+
// contains the inputs that are defined in the snap-in.
89+
};
90+
event_sources: any;
91+
resources: {
92+
keyrings: any;
93+
tags: any;
94+
};
95+
}
96+
97+
// Event object passed to the snap-kit action.
98+
interface Event {
99+
// The payload of the event
100+
payload: Payload;
101+
context: Context;
102+
execution_metadata: ExecutionMetadata;
103+
input_data: InputData;
104+
}
105+
```
106+
107+
## Screenshots
108+
109+
<!-- ## Example for initializer -->
110+
111+
## List of surfaces
112+
113+
| Surface | Description |
114+
|-------------------------|-----------------------------------------------------------------------------------------------|
115+
| issue | Issue surface is used to display snap components in the issue view. |
116+
| support | Support surface is used to display snap components in the Customer Portal. |
117+
| comments_rte | Comments RTE surface is used to display snap components in the comments section of the timeline. |
118+
| snap_in__configuration | Snap-in configuration surface is used to display snap components in the snap-in configuration view. |
119+
| plug | Plug surface is used to display snap components in the plug widget. |
120+

0 commit comments

Comments
 (0)