@atlaskit/link-datasource 0.14.4 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/ui/issue-like-table/draggable-table-heading.js +5 -1
  3. package/dist/cjs/ui/issue-like-table/index.js +78 -31
  4. package/dist/cjs/ui/issue-like-table/styled.js +5 -3
  5. package/dist/cjs/version.json +1 -1
  6. package/dist/es2019/ui/issue-like-table/draggable-table-heading.js +5 -1
  7. package/dist/es2019/ui/issue-like-table/index.js +60 -14
  8. package/dist/es2019/ui/issue-like-table/styled.js +3 -0
  9. package/dist/es2019/version.json +1 -1
  10. package/dist/esm/ui/issue-like-table/draggable-table-heading.js +5 -1
  11. package/dist/esm/ui/issue-like-table/index.js +79 -32
  12. package/dist/esm/ui/issue-like-table/styled.js +3 -2
  13. package/dist/esm/version.json +1 -1
  14. package/dist/types/ui/issue-like-table/draggable-table-heading.d.ts +2 -1
  15. package/dist/types/ui/issue-like-table/index.d.ts +1 -0
  16. package/dist/types/ui/issue-like-table/styled.d.ts +4 -0
  17. package/dist/types-ts4.5/ui/issue-like-table/draggable-table-heading.d.ts +2 -1
  18. package/dist/types-ts4.5/ui/issue-like-table/index.d.ts +1 -0
  19. package/dist/types-ts4.5/ui/issue-like-table/styled.d.ts +4 -0
  20. package/examples-helpers/buildIssueLikeTable.tsx +4 -2
  21. package/examples-helpers/buildJiraIssuesTable.tsx +4 -2
  22. package/package.json +4 -4
  23. package/examples-helpers/mockAutocompleteData.ts +0 -54
  24. package/examples-helpers/mockJiraAvailableSites.ts +0 -27
  25. package/examples-helpers/mockJiraData.ts +0 -546
  26. package/examples-helpers/mockSuggestionData.ts +0 -17
  27. package/examples-helpers/setupDatasourcesMocks.ts +0 -199
  28. package/examples-helpers/setupModalExampleMocks.ts +0 -32
@@ -1,199 +0,0 @@
1
- import fetchMock from 'fetch-mock/cjs/client';
2
-
3
- import {
4
- DatasourceDataResponseItem,
5
- DatasourceResponseSchemaProperty,
6
- IconType,
7
- LinkType,
8
- StatusType,
9
- StringType,
10
- TagType,
11
- UserType,
12
- } from '@atlaskit/linking-types';
13
-
14
- import { mockJiraData } from './mockJiraData';
15
-
16
- const columns: DatasourceResponseSchemaProperty[] = [
17
- {
18
- key: 'id',
19
- title: '',
20
- type: 'string',
21
- isIdentity: true,
22
- },
23
- {
24
- key: 'key',
25
- title: 'Key',
26
- type: 'link',
27
- },
28
- {
29
- key: 'type',
30
- type: 'icon',
31
- title: 'Type',
32
- },
33
- {
34
- key: 'summary',
35
- title: 'Summary',
36
- type: 'link',
37
- },
38
- {
39
- key: 'assignee',
40
- title: 'Assignee',
41
- type: 'user',
42
- },
43
- {
44
- key: 'priority',
45
- title: 'P',
46
- type: 'icon',
47
- },
48
- {
49
- key: 'labels',
50
- title: 'Labels',
51
- type: 'tag',
52
- isList: true,
53
- },
54
- {
55
- key: 'status',
56
- title: 'Status',
57
- type: 'status',
58
- },
59
- {
60
- key: 'created',
61
- title: 'Created',
62
- type: 'string',
63
- },
64
- {
65
- key: 'due',
66
- title: 'Due Date',
67
- type: 'string',
68
- },
69
- ...new Array<DatasourceResponseSchemaProperty>(100)
70
- .fill({
71
- key: 'due',
72
- title: 'Due Date',
73
- type: 'string',
74
- })
75
- .map((prop, i) => ({ ...prop, key: prop.key + i, title: prop.title + i })),
76
- ];
77
-
78
- const initialVisibleColumnKeys: string[] = [
79
- // Order of actual columns is in different order is on purpose
80
- // To demonstrate that this list is a king
81
- 'type',
82
- 'key',
83
- 'summary',
84
- 'assignee',
85
- 'priority',
86
- 'labels',
87
- 'status',
88
- 'created',
89
- ];
90
-
91
- export const MOCK_DATASOURCE_ID = 'some-datasource-id';
92
-
93
- interface FetchMockRequestDetails {
94
- body: string;
95
- credentials: string;
96
- headers: object;
97
- method: string;
98
- }
99
-
100
- export const setupDatasourcesMocks = (
101
- datasourceId: string = MOCK_DATASOURCE_ID,
102
- ) => {
103
- fetchMock.post(
104
- `/gateway/api/object-resolver/datasource/${datasourceId}/fetch/details`,
105
- async () =>
106
- new Promise(resolve => {
107
- setTimeout(() => {
108
- resolve({
109
- ari: 'ari:cloud:linking-platform:datasource/12e74246-a3f1-46c1-9fd9-8d952aa9f12f',
110
- id: '12e74246-a3f1-46c1-9fd9-8d952aa9f12f',
111
- name: 'JQL Datasource',
112
- description: 'Fetches Issues using JQL',
113
- parameters: [
114
- {
115
- key: 'cloudId',
116
- type: 'string',
117
- description: 'Cloud Id',
118
- },
119
- {
120
- key: 'jql',
121
- type: 'string',
122
- description: 'JQL query to retrieve list of issues',
123
- },
124
- ],
125
- schema: {
126
- properties: columns,
127
- defaultProperties: initialVisibleColumnKeys,
128
- },
129
- });
130
- }, 300);
131
- }),
132
- );
133
-
134
- let numberOfLoads = 0;
135
- const getItems = (cloudId: string = '', maxItems = 99) => ({
136
- data: mockJiraData.data
137
- .slice(0, maxItems)
138
- .map((item): DatasourceDataResponseItem => {
139
- return {
140
- // Fake identifier attribute that needs to be flat primitive value.
141
- // Adding number of pages to make all issueNumbers unique
142
- id: (item.issueNumber + numberOfLoads) as StringType['value'],
143
- type: {
144
- source: item.type.source,
145
- label: item.type.label,
146
- } as IconType['value'],
147
- key: {
148
- url: item.link,
149
- text: item.issueNumber + numberOfLoads,
150
- linkType: 'key',
151
- } as LinkType['value'],
152
- summary: {
153
- url: item.link,
154
- text: `[${cloudId}] ${item.summary}`,
155
- } as LinkType['value'],
156
- assignee: {
157
- displayName: item.assignee?.displayName,
158
- avatarSource: item.assignee?.source,
159
- } as UserType['value'],
160
- priority: {
161
- source: item.priority.source,
162
- label: item.priority.label,
163
- } as IconType['value'],
164
- status: {
165
- text: item.status.text,
166
- status: item.status.status,
167
- } as StatusType['value'],
168
- created: item.created as StringType['value'],
169
- due: item.due as StringType['value'],
170
- labels: item.labels as TagType['value'][],
171
- };
172
- }),
173
- totalIssues: mockJiraData.totalIssues,
174
- nextPageCursor:
175
- numberOfLoads < 4 && maxItems > 1 ? 'c3RhcnRBdD01' : undefined,
176
- });
177
-
178
- fetchMock.post(
179
- `/gateway/api/object-resolver/datasource/${datasourceId}/fetch/data`,
180
- async (url: string, details: FetchMockRequestDetails) => {
181
- const requestBody = JSON.parse(details.body);
182
- const {
183
- parameters: { cloudId },
184
- } = requestBody;
185
- return new Promise(resolve => {
186
- setTimeout(() => {
187
- // special case to return only one item to show smart-card rendering path
188
- if (cloudId === '11111') {
189
- resolve(getItems(cloudId, 1));
190
- return;
191
- }
192
- resolve(getItems(cloudId));
193
- }, numberOfLoads++ * 1000);
194
- });
195
- },
196
- );
197
- };
198
-
199
- setupDatasourcesMocks();
@@ -1,32 +0,0 @@
1
- import fetchMock from 'fetch-mock/cjs/client';
2
-
3
- import { mockAutoCompleteData } from './mockAutocompleteData';
4
- import { mockSiteData } from './mockJiraAvailableSites';
5
- import { mockSuggestionData } from './mockSuggestionData';
6
-
7
- export const setupModalExampleMocks = () => {
8
- fetchMock.mock('/gateway/api/available-sites', async () =>
9
- Promise.resolve({ sites: mockSiteData }),
10
- );
11
-
12
- // /gateway/api/ex/jira/:cloudId//rest/api/latest/jql/autocompletedata
13
- fetchMock.mock(
14
- /\/gateway\/api\/ex\/jira\/.+\/\/rest\/api\/latest\/jql\/autocompletedata/g,
15
- async () =>
16
- new Promise(resolve => {
17
- setTimeout(() => resolve(mockAutoCompleteData), 150);
18
- }),
19
- );
20
-
21
- // /gateway/api/ex/jira/:cloudId//rest/api/latest/jql/autocompletedata/suggestions?fieldName=:fieldName&fieldValue=:fieldValue
22
- fetchMock.mock(
23
- /\/gateway\/api\/ex\/jira\/.+\/\/rest\/api\/latest\/jql\/autocompletedata\/suggestions\?.+/g,
24
- async () =>
25
- new Promise(resolve => {
26
- setTimeout(() => resolve(mockSuggestionData), 150);
27
- }),
28
- );
29
- };
30
-
31
- // Calling it on module level once for any number of imports
32
- setupModalExampleMocks();