@atlaskit/help 7.1.24 → 7.1.26

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 (201) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/analytics.js +0 -6
  3. package/dist/cjs/assets/ErrorImage.js +0 -4
  4. package/dist/cjs/assets/NotFoundImage.js +0 -4
  5. package/dist/cjs/assets/SomethingWrongImage.js +0 -4
  6. package/dist/cjs/assets/WhatsNewIcoExperiment.js +0 -4
  7. package/dist/cjs/assets/WhatsNewIconFix.js +0 -4
  8. package/dist/cjs/assets/WhatsNewIconImprovement.js +0 -4
  9. package/dist/cjs/assets/WhatsNewIconNew.js +0 -4
  10. package/dist/cjs/assets/WhatsNewIconRemoved.js +0 -4
  11. package/dist/cjs/components/Article/ArticleContent/index.js +2 -16
  12. package/dist/cjs/components/Article/ArticleLoadingFail/index.js +2 -20
  13. package/dist/cjs/components/Article/ArticleLoadingFail/styled.js +0 -9
  14. package/dist/cjs/components/Article/HelpArticle/Loading/index.js +0 -9
  15. package/dist/cjs/components/Article/HelpArticle/WasHelpfulForm/WasHelpfulNoButton.js +4 -21
  16. package/dist/cjs/components/Article/HelpArticle/WasHelpfulForm/WasHelpfulYesButton.js +4 -21
  17. package/dist/cjs/components/Article/HelpArticle/WasHelpfulForm/index.js +26 -78
  18. package/dist/cjs/components/Article/HelpArticle/WasHelpfulForm/styled.js +0 -15
  19. package/dist/cjs/components/Article/HelpArticle/index.js +9 -39
  20. package/dist/cjs/components/Article/WhatsNewArticle/Loading/index.js +0 -10
  21. package/dist/cjs/components/Article/WhatsNewArticle/index.js +2 -28
  22. package/dist/cjs/components/Article/WhatsNewArticle/styled.js +0 -21
  23. package/dist/cjs/components/Article/index.js +16 -46
  24. package/dist/cjs/components/Article/styled.js +0 -7
  25. package/dist/cjs/components/ArticlesList/ArticlesList.js +8 -19
  26. package/dist/cjs/components/ArticlesList/ArticlesListItem/index.js +6 -28
  27. package/dist/cjs/components/ArticlesList/ArticlesListItem/styled.js +0 -21
  28. package/dist/cjs/components/ArticlesList/index.js +8 -28
  29. package/dist/cjs/components/ArticlesList/styled.js +0 -12
  30. package/dist/cjs/components/Help.js +5 -36
  31. package/dist/cjs/components/HelpContent.js +14 -47
  32. package/dist/cjs/components/HelpContentButton/index.js +10 -28
  33. package/dist/cjs/components/HelpContentButton/styled.js +0 -19
  34. package/dist/cjs/components/RelatedArticles/RelatedArticlesLoading.js +0 -9
  35. package/dist/cjs/components/RelatedArticles/index.js +17 -57
  36. package/dist/cjs/components/RelatedArticles/styled.js +1 -22
  37. package/dist/cjs/components/Search/SearchInput/index.js +6 -40
  38. package/dist/cjs/components/Search/SearchInput/styled.js +0 -11
  39. package/dist/cjs/components/Search/SearchResults/SearchExternalSite.js +3 -23
  40. package/dist/cjs/components/Search/SearchResults/SearchResults.js +2 -7
  41. package/dist/cjs/components/Search/SearchResults/SearchResultsEmpty.js +3 -24
  42. package/dist/cjs/components/Search/SearchResults/SearchResultsError.js +1 -12
  43. package/dist/cjs/components/Search/SearchResults/index.js +9 -33
  44. package/dist/cjs/components/Search/SearchResults/styled.js +0 -19
  45. package/dist/cjs/components/ShowMoreButton/index.js +7 -18
  46. package/dist/cjs/components/WhatsNew/WhatsNewButton/index.js +4 -29
  47. package/dist/cjs/components/WhatsNew/WhatsNewResults/WhatsNewResultsEmpty/index.js +2 -16
  48. package/dist/cjs/components/WhatsNew/WhatsNewResults/WhatsNewResultsEmpty/styled.js +0 -13
  49. package/dist/cjs/components/WhatsNew/WhatsNewResults/WhatsNewResultsError/index.js +1 -12
  50. package/dist/cjs/components/WhatsNew/WhatsNewResults/WhatsNewResultsError/styled.js +0 -13
  51. package/dist/cjs/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/WhatsNewResultItem/index.js +6 -27
  52. package/dist/cjs/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/WhatsNewResultItem/styled.js +0 -17
  53. package/dist/cjs/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/WhatsNewResultsList.js +7 -27
  54. package/dist/cjs/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/index.js +8 -25
  55. package/dist/cjs/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/styled.js +0 -20
  56. package/dist/cjs/components/WhatsNew/WhatsNewResults/WhatsNewResultsLoading/index.js +0 -12
  57. package/dist/cjs/components/WhatsNew/WhatsNewResults/WhatsNewResultsLoading/styled.js +0 -9
  58. package/dist/cjs/components/WhatsNew/WhatsNewResults/index.js +9 -49
  59. package/dist/cjs/components/WhatsNew/WhatsNewResults/styled.js +0 -13
  60. package/dist/cjs/components/constants.js +0 -4
  61. package/dist/cjs/components/contexts/headerContext.js +5 -13
  62. package/dist/cjs/components/contexts/helpArticleContext.js +8 -18
  63. package/dist/cjs/components/contexts/homeContext.js +5 -13
  64. package/dist/cjs/components/contexts/navigationContext.js +48 -132
  65. package/dist/cjs/components/contexts/relatedArticlesContext.js +8 -16
  66. package/dist/cjs/components/contexts/searchContext.js +23 -57
  67. package/dist/cjs/components/contexts/whatsNewArticleContext.js +26 -58
  68. package/dist/cjs/components/styled.js +0 -11
  69. package/dist/cjs/i18n/index.js +0 -25
  70. package/dist/cjs/index.js +0 -9
  71. package/dist/cjs/messages.js +0 -2
  72. package/dist/cjs/model/Article.js +0 -1
  73. package/dist/cjs/model/Help.js +0 -3
  74. package/dist/cjs/model/Requests.js +0 -1
  75. package/dist/cjs/model/WhatsNew.js +0 -1
  76. package/dist/cjs/util/hooks/cancellablePromise.js +2 -7
  77. package/dist/cjs/util/hooks/ctx.js +0 -6
  78. package/dist/cjs/util/hooks/previous.js +3 -4
  79. package/dist/cjs/util/i18n-util.js +1 -7
  80. package/dist/cjs/util/index.js +0 -21
  81. package/dist/cjs/util/styled.js +3 -28
  82. package/dist/cjs/util/testing/mock.js +2 -18
  83. package/dist/cjs/version.json +1 -1
  84. package/dist/es2019/components/Article/ArticleContent/index.js +0 -4
  85. package/dist/es2019/components/Article/ArticleLoadingFail/index.js +0 -4
  86. package/dist/es2019/components/Article/HelpArticle/WasHelpfulForm/WasHelpfulNoButton.js +0 -4
  87. package/dist/es2019/components/Article/HelpArticle/WasHelpfulForm/WasHelpfulYesButton.js +0 -4
  88. package/dist/es2019/components/Article/HelpArticle/WasHelpfulForm/index.js +2 -17
  89. package/dist/es2019/components/Article/HelpArticle/WasHelpfulForm/styled.js +1 -0
  90. package/dist/es2019/components/Article/HelpArticle/index.js +0 -10
  91. package/dist/es2019/components/Article/WhatsNewArticle/index.js +0 -4
  92. package/dist/es2019/components/Article/index.js +2 -7
  93. package/dist/es2019/components/Article/styled.js +1 -0
  94. package/dist/es2019/components/ArticlesList/ArticlesList.js +0 -4
  95. package/dist/es2019/components/ArticlesList/ArticlesListItem/index.js +0 -5
  96. package/dist/es2019/components/ArticlesList/index.js +0 -9
  97. package/dist/es2019/components/ArticlesList/styled.js +1 -0
  98. package/dist/es2019/components/Help.js +0 -3
  99. package/dist/es2019/components/HelpContent.js +0 -3
  100. package/dist/es2019/components/HelpContentButton/index.js +0 -2
  101. package/dist/es2019/components/HelpContentButton/styled.js +1 -0
  102. package/dist/es2019/components/RelatedArticles/RelatedArticlesLoading.js +0 -2
  103. package/dist/es2019/components/RelatedArticles/index.js +0 -4
  104. package/dist/es2019/components/RelatedArticles/styled.js +2 -3
  105. package/dist/es2019/components/Search/SearchInput/index.js +0 -8
  106. package/dist/es2019/components/Search/SearchResults/SearchExternalSite.js +0 -2
  107. package/dist/es2019/components/Search/SearchResults/SearchResultsEmpty.js +0 -2
  108. package/dist/es2019/components/Search/SearchResults/index.js +2 -1
  109. package/dist/es2019/components/WhatsNew/WhatsNewButton/index.js +0 -3
  110. package/dist/es2019/components/WhatsNew/WhatsNewResults/WhatsNewResultsEmpty/index.js +0 -2
  111. package/dist/es2019/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/WhatsNewResultItem/index.js +0 -5
  112. package/dist/es2019/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/WhatsNewResultsList.js +0 -4
  113. package/dist/es2019/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/index.js +0 -5
  114. package/dist/es2019/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/styled.js +1 -0
  115. package/dist/es2019/components/WhatsNew/WhatsNewResults/WhatsNewResultsLoading/styled.js +1 -1
  116. package/dist/es2019/components/WhatsNew/WhatsNewResults/index.js +2 -7
  117. package/dist/es2019/components/constants.js +2 -3
  118. package/dist/es2019/components/contexts/navigationContext.js +19 -44
  119. package/dist/es2019/components/contexts/searchContext.js +0 -6
  120. package/dist/es2019/components/contexts/whatsNewArticleContext.js +2 -4
  121. package/dist/es2019/components/styled.js +1 -0
  122. package/dist/es2019/model/Article.js +0 -1
  123. package/dist/es2019/model/Help.js +0 -1
  124. package/dist/es2019/model/Requests.js +0 -1
  125. package/dist/es2019/model/WhatsNew.js +0 -1
  126. package/dist/es2019/util/hooks/cancellablePromise.js +2 -6
  127. package/dist/es2019/util/hooks/ctx.js +0 -4
  128. package/dist/es2019/util/hooks/previous.js +5 -3
  129. package/dist/es2019/util/i18n-util.js +1 -4
  130. package/dist/es2019/util/index.js +0 -9
  131. package/dist/es2019/util/styled.js +4 -5
  132. package/dist/es2019/util/testing/mock.js +2 -5
  133. package/dist/es2019/version.json +1 -1
  134. package/dist/esm/components/Article/ArticleContent/index.js +2 -7
  135. package/dist/esm/components/Article/ArticleLoadingFail/index.js +2 -7
  136. package/dist/esm/components/Article/ArticleLoadingFail/styled.js +0 -2
  137. package/dist/esm/components/Article/HelpArticle/WasHelpfulForm/WasHelpfulNoButton.js +4 -10
  138. package/dist/esm/components/Article/HelpArticle/WasHelpfulForm/WasHelpfulYesButton.js +4 -10
  139. package/dist/esm/components/Article/HelpArticle/WasHelpfulForm/index.js +27 -52
  140. package/dist/esm/components/Article/HelpArticle/WasHelpfulForm/styled.js +1 -2
  141. package/dist/esm/components/Article/HelpArticle/index.js +9 -23
  142. package/dist/esm/components/Article/WhatsNewArticle/index.js +2 -7
  143. package/dist/esm/components/Article/WhatsNewArticle/styled.js +0 -2
  144. package/dist/esm/components/Article/index.js +16 -31
  145. package/dist/esm/components/Article/styled.js +1 -2
  146. package/dist/esm/components/ArticlesList/ArticlesList.js +8 -12
  147. package/dist/esm/components/ArticlesList/ArticlesListItem/index.js +6 -13
  148. package/dist/esm/components/ArticlesList/ArticlesListItem/styled.js +0 -2
  149. package/dist/esm/components/ArticlesList/index.js +8 -18
  150. package/dist/esm/components/ArticlesList/styled.js +1 -2
  151. package/dist/esm/components/Help.js +5 -16
  152. package/dist/esm/components/HelpContent.js +14 -24
  153. package/dist/esm/components/HelpContentButton/index.js +10 -14
  154. package/dist/esm/components/HelpContentButton/styled.js +1 -2
  155. package/dist/esm/components/RelatedArticles/RelatedArticlesLoading.js +0 -2
  156. package/dist/esm/components/RelatedArticles/index.js +17 -33
  157. package/dist/esm/components/RelatedArticles/styled.js +2 -5
  158. package/dist/esm/components/Search/SearchInput/index.js +6 -18
  159. package/dist/esm/components/Search/SearchInput/styled.js +0 -2
  160. package/dist/esm/components/Search/SearchResults/SearchExternalSite.js +3 -7
  161. package/dist/esm/components/Search/SearchResults/SearchResults.js +2 -2
  162. package/dist/esm/components/Search/SearchResults/SearchResultsEmpty.js +3 -7
  163. package/dist/esm/components/Search/SearchResults/SearchResultsError.js +1 -1
  164. package/dist/esm/components/Search/SearchResults/index.js +9 -14
  165. package/dist/esm/components/Search/SearchResults/styled.js +0 -2
  166. package/dist/esm/components/ShowMoreButton/index.js +7 -7
  167. package/dist/esm/components/WhatsNew/WhatsNewButton/index.js +4 -10
  168. package/dist/esm/components/WhatsNew/WhatsNewResults/WhatsNewResultsEmpty/index.js +2 -5
  169. package/dist/esm/components/WhatsNew/WhatsNewResults/WhatsNewResultsEmpty/styled.js +0 -2
  170. package/dist/esm/components/WhatsNew/WhatsNewResults/WhatsNewResultsError/index.js +1 -1
  171. package/dist/esm/components/WhatsNew/WhatsNewResults/WhatsNewResultsError/styled.js +0 -2
  172. package/dist/esm/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/WhatsNewResultItem/index.js +6 -14
  173. package/dist/esm/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/WhatsNewResultItem/styled.js +0 -2
  174. package/dist/esm/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/WhatsNewResultsList.js +7 -13
  175. package/dist/esm/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/index.js +8 -14
  176. package/dist/esm/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/styled.js +1 -2
  177. package/dist/esm/components/WhatsNew/WhatsNewResults/WhatsNewResultsLoading/styled.js +1 -3
  178. package/dist/esm/components/WhatsNew/WhatsNewResults/index.js +9 -23
  179. package/dist/esm/components/WhatsNew/WhatsNewResults/styled.js +0 -2
  180. package/dist/esm/components/constants.js +2 -3
  181. package/dist/esm/components/contexts/headerContext.js +5 -7
  182. package/dist/esm/components/contexts/helpArticleContext.js +8 -10
  183. package/dist/esm/components/contexts/homeContext.js +5 -7
  184. package/dist/esm/components/contexts/navigationContext.js +48 -112
  185. package/dist/esm/components/contexts/relatedArticlesContext.js +8 -10
  186. package/dist/esm/components/contexts/searchContext.js +23 -43
  187. package/dist/esm/components/contexts/whatsNewArticleContext.js +26 -44
  188. package/dist/esm/components/styled.js +1 -2
  189. package/dist/esm/model/Article.js +0 -1
  190. package/dist/esm/model/Help.js +0 -1
  191. package/dist/esm/model/Requests.js +0 -1
  192. package/dist/esm/model/WhatsNew.js +0 -1
  193. package/dist/esm/util/hooks/cancellablePromise.js +2 -4
  194. package/dist/esm/util/hooks/ctx.js +0 -4
  195. package/dist/esm/util/hooks/previous.js +5 -3
  196. package/dist/esm/util/i18n-util.js +1 -4
  197. package/dist/esm/util/index.js +0 -9
  198. package/dist/esm/util/styled.js +4 -8
  199. package/dist/esm/util/testing/mock.js +2 -5
  200. package/dist/esm/version.json +1 -1
  201. package/package.json +6 -4
@@ -14,7 +14,6 @@ const DEFAULT_ARTICLE_ID = {
14
14
  type: ARTICLE_TYPE.HELP_ARTICLE
15
15
  };
16
16
  export const [useNavigationContext, CtxProvider] = createCtx();
17
-
18
17
  const getNewHistoryItem = (id, type) => {
19
18
  let uid = Math.floor(Math.random() * Math.pow(10, 17));
20
19
  const newHistoryItem = {
@@ -25,12 +24,11 @@ const getNewHistoryItem = (id, type) => {
25
24
  };
26
25
  return newHistoryItem;
27
26
  };
27
+
28
28
  /**
29
29
  * Get a simplified version of the history. The items in this array should
30
30
  * have only the ID, UID and state === 'reload'
31
31
  */
32
-
33
-
34
32
  const getSimpleHistory = history => history.map(historyItem => {
35
33
  const {
36
34
  id,
@@ -44,11 +42,10 @@ const getSimpleHistory = history => history.map(historyItem => {
44
42
  type
45
43
  };
46
44
  });
45
+
47
46
  /**
48
47
  * Get history data (list of IDs and UID)
49
48
  */
50
-
51
-
52
49
  const getHistoryData = history => history.map(historyItem => {
53
50
  const {
54
51
  id,
@@ -59,23 +56,20 @@ const getHistoryData = history => history.map(historyItem => {
59
56
  uid
60
57
  };
61
58
  });
59
+
62
60
  /**
63
61
  * Get the last article in the history
64
62
  */
65
-
66
-
67
63
  const getCurrentArticle = history => history[history.length - 1];
64
+
68
65
  /**
69
66
  * Get an ArticleItem/WhatsNewArticleItem based on the last article in the history
70
67
  */
71
-
72
-
73
68
  const getCurrentArticleItemSlim = history => {
74
69
  const {
75
70
  article,
76
71
  type
77
72
  } = getCurrentArticle(history);
78
-
79
73
  if (article) {
80
74
  if (type === ARTICLE_TYPE.HELP_ARTICLE) {
81
75
  const {
@@ -95,10 +89,8 @@ const getCurrentArticleItemSlim = history => {
95
89
  }
96
90
  }
97
91
  };
98
-
99
92
  const getViewForArticleId = articleId => {
100
93
  let view = VIEW.DEFAULT_CONTENT;
101
-
102
94
  if (articleId.type === ARTICLE_TYPE.HELP_ARTICLE) {
103
95
  if (articleId.id) {
104
96
  view = VIEW.ARTICLE;
@@ -112,10 +104,8 @@ const getViewForArticleId = articleId => {
112
104
  view = VIEW.WHATS_NEW;
113
105
  }
114
106
  }
115
-
116
107
  return view;
117
108
  };
118
-
119
109
  const navigationReducer = ({
120
110
  articleId: currentArticleId,
121
111
  history: currentHistory,
@@ -126,12 +116,10 @@ const navigationReducer = ({
126
116
  history: currentHistory,
127
117
  view: currentView
128
118
  };
129
-
130
119
  if (action.type === 'newArticle' && action.payload) {
131
120
  const {
132
121
  payload: newArticleId
133
122
  } = action;
134
-
135
123
  if (isEqual(newArticleId, DEFAULT_ARTICLE_ID)) {
136
124
  newState = {
137
125
  articleId: newArticleId,
@@ -159,10 +147,10 @@ const navigationReducer = ({
159
147
  payload: HistoryItemUpdate
160
148
  } = action;
161
149
  const index = currentHistory.findIndex(historyItemTemp => historyItemTemp.uid === HistoryItemUpdate.uid);
162
-
163
150
  if (index !== -1) {
164
151
  const newHistory = [...currentHistory];
165
- newHistory[index] = { ...HistoryItemUpdate
152
+ newHistory[index] = {
153
+ ...HistoryItemUpdate
166
154
  };
167
155
  newState = {
168
156
  articleId: currentArticleId,
@@ -172,11 +160,9 @@ const navigationReducer = ({
172
160
  }
173
161
  } else if (action.type === 'removeLastHistoryItem') {
174
162
  const newHistory = currentHistory.length > 0 ? [...currentHistory] : [];
175
-
176
163
  if (newHistory.length > 0) {
177
164
  newHistory.splice(-1);
178
165
  }
179
-
180
166
  newState = {
181
167
  articleId: currentArticleId,
182
168
  history: newHistory,
@@ -208,10 +194,8 @@ const navigationReducer = ({
208
194
  view: newView
209
195
  };
210
196
  }
211
-
212
197
  return newState;
213
198
  };
214
-
215
199
  export const NavigationContextProvider = ({
216
200
  navigationData = {
217
201
  articleId: DEFAULT_ARTICLE_ID,
@@ -265,71 +249,64 @@ export const NavigationContextProvider = ({
265
249
  if (currentHistory.length === 1 && !isDefaultContentDefined || currentView === VIEW.WHATS_NEW && !isDefaultContentDefined) {
266
250
  return false;
267
251
  }
252
+
268
253
  /**
269
254
  * if an overlay is visible return true to display the back buton
270
255
  */
271
-
272
-
273
256
  return isOverlayVisible;
274
257
  }, [currentHistory.length, isDefaultContentDefined, isOverlayVisible, currentView]);
275
258
  const fetchArticleData = useCallback(async historyItem => {
276
259
  try {
277
260
  let article;
278
-
279
261
  switch (historyItem.type) {
280
262
  case ARTICLE_TYPE.HELP_ARTICLE:
281
263
  if (!onGetHelpArticle) {
282
264
  throw new Error('onGetHelpArticle prop not defined');
283
265
  }
284
-
285
266
  article = await onGetHelpArticle({
286
267
  id: historyItem.id,
287
268
  type: historyItem.type
288
269
  });
289
270
  break;
290
-
291
271
  case ARTICLE_TYPE.WHATS_NEW:
292
272
  if (!onGetWhatsNewArticle) {
293
273
  throw new Error('onGetWhatsNewArticle prop not defined');
294
274
  }
295
-
296
275
  if (historyItem.id === '') {
297
276
  break;
298
277
  }
299
-
300
278
  article = await onGetWhatsNewArticle({
301
279
  id: historyItem.id,
302
280
  type: historyItem.type
303
281
  });
304
282
  break;
305
-
306
283
  default:
307
284
  throw new Error('onGetHelpArticle prop not defined');
308
285
  break;
309
286
  }
310
-
311
- return { ...historyItem,
287
+ return {
288
+ ...historyItem,
312
289
  ...(article && {
313
290
  article
314
291
  }),
315
292
  state: REQUEST_STATE.done
316
293
  };
317
294
  } catch (error) {
318
- return { ...historyItem,
295
+ return {
296
+ ...historyItem,
319
297
  state: REQUEST_STATE.error
320
298
  };
321
299
  }
322
300
  }, [onGetHelpArticle, onGetWhatsNewArticle]);
323
301
  const reloadArticle = useCallback(async historyItem => {
324
- let historyItemToReload = { ...historyItem
302
+ let historyItemToReload = {
303
+ ...historyItem
325
304
  };
326
-
327
305
  if (historyItem.type === ARTICLE_TYPE.HELP_ARTICLE || historyItem.type === ARTICLE_TYPE.WHATS_NEW) {
328
306
  historyItemToReload.state = REQUEST_STATE.loading;
329
307
  } else {
330
308
  historyItemToReload.state = REQUEST_STATE.error;
331
309
  }
332
-
333
310
  dispatchNavigationAction({
334
311
  type: 'updateHistoryItem',
335
312
  payload: historyItemToReload
@@ -351,9 +328,9 @@ export const NavigationContextProvider = ({
351
328
  });
352
329
  return;
353
330
  }
354
- } // if the history is not empty and ...
355
-
331
+ }
356
332
 
333
+ // if the history is not empty and ...
357
334
  if (currentHistory.length > 0) {
358
335
  // the history has more than one article, navigate back through the history
359
336
  if (currentHistory.length > 1) {
@@ -393,10 +370,10 @@ export const NavigationContextProvider = ({
393
370
  }, [isSearchResultVisible]);
394
371
  useEffect(() => {
395
372
  const lastHistoryItem = currentHistory.length > 0 ? getCurrentArticle(currentHistory) : getNewHistoryItem(DEFAULT_ARTICLE_ID.id, DEFAULT_ARTICLE_ID.type);
373
+
396
374
  /**
397
375
  * If the propsArticleId.id (host articleId) is different from currentArticleId.id (internal articleId)
398
376
  * */
399
-
400
377
  if (!isEqual(propsArticleId, currentArticleId)) {
401
378
  /**
402
379
  * If propsArticleId and lastHistoryItem are the same, we just need to update the articleId
@@ -419,7 +396,6 @@ export const NavigationContextProvider = ({
419
396
  } else {
420
397
  if (setNavigationData) {
421
398
  const simpleHistory = getSimpleHistory(currentHistory);
422
-
423
399
  if (currentArticleId.id !== lastHistoryItem.id || currentArticleId.type !== lastHistoryItem.type) {
424
400
  /**
425
401
  * If the propsArticleId.id (host articleId) is equal to currentArticleId.id (internal articleId)
@@ -452,18 +428,17 @@ export const NavigationContextProvider = ({
452
428
  payload: historyItemUpdate
453
429
  });
454
430
  };
431
+
455
432
  /**
456
433
  * If the last history item state is "loading" or "reload", we need to request the article (fetch article from API)
457
434
  */
458
-
459
-
460
435
  const lastHistoryItem = getCurrentArticle(currentHistory);
461
-
462
436
  if ((lastHistoryItem === null || lastHistoryItem === void 0 ? void 0 : lastHistoryItem.state) === REQUEST_STATE.load || (lastHistoryItem === null || lastHistoryItem === void 0 ? void 0 : lastHistoryItem.state) === REQUEST_STATE.reload) {
463
437
  requestNewArticle(lastHistoryItem);
464
438
  dispatchNavigationAction({
465
439
  type: 'updateHistoryItem',
466
- payload: { ...lastHistoryItem,
440
+ payload: {
441
+ ...lastHistoryItem,
467
442
  state: REQUEST_STATE.loading
468
443
  }
469
444
  });
@@ -33,7 +33,6 @@ export const SearchContextProvider = ({
33
33
  }
34
34
  }, [onSearch]);
35
35
  const debouncedDoSearch = debounce(doSearch, 500);
36
-
37
36
  const search = onSearch && (newSearchValue => {
38
37
  if (newSearchValue !== searchValue) {
39
38
  if (newSearchValue.length >= MIN_CHARACTERS_FOR_SEARCH) {
@@ -44,7 +43,6 @@ export const SearchContextProvider = ({
44
43
  setSearchState(REQUEST_STATE.error);
45
44
  setSearchResult([]);
46
45
  }
47
-
48
46
  setSearchResultsVisible(true);
49
47
  } else if (newSearchValue.length === 0) {
50
48
  // If the search input is empty, the search results should be empty and
@@ -52,7 +50,6 @@ export const SearchContextProvider = ({
52
50
  setSearchResult(null);
53
51
  setSearchResultsVisible(false);
54
52
  }
55
-
56
53
  setSearchValue(newSearchValue);
57
54
  } else {
58
55
  setSearchState(REQUEST_STATE.loading);
@@ -60,15 +57,12 @@ export const SearchContextProvider = ({
60
57
  setSearchResultsVisible(true);
61
58
  }
62
59
  });
63
-
64
60
  const searchResultItemClick = (event, analyticsEvent, articleData) => {
65
61
  if (onSearchResultItemClick) {
66
62
  onSearchResultItemClick(event, analyticsEvent, articleData);
67
63
  }
68
-
69
64
  setSearchResultsVisible(false);
70
65
  };
71
-
72
66
  return /*#__PURE__*/React.createElement(CtxProvider, {
73
67
  value: {
74
68
  onSearch: search,
@@ -19,11 +19,10 @@ export const WhatsNewArticleProvider = ({
19
19
  const [searchWhatsNewArticlesState, setSearchWhatsNewArticlesState] = useState(REQUEST_STATE.done);
20
20
  const searchWhatsNew = useCallback(async (filter = '', numberOfItems = NUMBER_OF_WHATS_NEW_ITEMS_PER_PAGE, page = '') => {
21
21
  setWhatsNewSearchType(filter);
22
-
23
22
  if (onSearchWhatsNewArticles) {
24
23
  try {
25
- setSearchWhatsNewArticlesState(REQUEST_STATE.loading); // If the filter type hasn't change, then we are loading an extra page
26
-
24
+ setSearchWhatsNewArticlesState(REQUEST_STATE.loading);
25
+ // If the filter type hasn't change, then we are loading an extra page
27
26
  if (filter === whatsNewSearchType && page !== '') {
28
27
  const results = await onSearchWhatsNewArticles(filter, numberOfItems, page);
29
28
  setSearchWhatsNewArticlesResult({
@@ -37,7 +36,6 @@ export const WhatsNewArticleProvider = ({
37
36
  const results = await onSearchWhatsNewArticles(filter, numberOfItems, page);
38
37
  setSearchWhatsNewArticlesResult(results);
39
38
  }
40
-
41
39
  setSearchWhatsNewArticlesState(REQUEST_STATE.done);
42
40
  } catch (error) {
43
41
  setSearchWhatsNewArticlesResult(null);
@@ -1,4 +1,5 @@
1
1
  /** @jsx jsx */
2
+
2
3
  import styled from '@emotion/styled';
3
4
  import { gridSize } from '@atlaskit/theme/constants';
4
5
  export const HelpBodyContainer = styled.div`
@@ -1,6 +1,5 @@
1
1
  // TODO - Check if we need to delete this
2
2
  export let ARTICLE_ITEM_TYPES;
3
-
4
3
  (function (ARTICLE_ITEM_TYPES) {
5
4
  ARTICLE_ITEM_TYPES["topicInProduct"] = "topicInProduct";
6
5
  })(ARTICLE_ITEM_TYPES || (ARTICLE_ITEM_TYPES = {}));
@@ -1,6 +1,5 @@
1
1
  import { ArticleItem } from './Article';
2
2
  export let ARTICLE_TYPE;
3
-
4
3
  (function (ARTICLE_TYPE) {
5
4
  ARTICLE_TYPE["HELP_ARTICLE"] = "HELP_ARTICLE";
6
5
  ARTICLE_TYPE["WHATS_NEW"] = "WHATS_NEW";
@@ -1,5 +1,4 @@
1
1
  export let REQUEST_STATE;
2
-
3
2
  (function (REQUEST_STATE) {
4
3
  REQUEST_STATE["done"] = "done";
5
4
  REQUEST_STATE["loading"] = "loading";
@@ -1,5 +1,4 @@
1
1
  export let WHATS_NEW_ITEM_TYPES;
2
-
3
2
  (function (WHATS_NEW_ITEM_TYPES) {
4
3
  WHATS_NEW_ITEM_TYPES["NEW_FEATURE"] = "Announcement";
5
4
  WHATS_NEW_ITEM_TYPES["IMPROVEMENT"] = "Improvement";
@@ -6,20 +6,18 @@ export function makeCancelable(promise) {
6
6
  });
7
7
  return {
8
8
  promise: wrappedPromise,
9
-
10
9
  cancel() {
11
10
  isCanceled = true;
12
11
  }
13
-
14
12
  };
15
13
  }
16
14
  export default function useCancellablePromise(cancelable = makeCancelable) {
17
- const emptyPromise = Promise.resolve(true); // check if the input argument is a cancelable promise generator
15
+ const emptyPromise = Promise.resolve(true);
18
16
 
17
+ // check if the input argument is a cancelable promise generator
19
18
  if (cancelable(emptyPromise).cancel === undefined) {
20
19
  throw new Error('promise wrapper argument must provide a cancel() function');
21
20
  }
22
-
23
21
  const promises = useRef([]);
24
22
  useEffect(() => {
25
23
  promises.current = promises.current;
@@ -28,13 +26,11 @@ export default function useCancellablePromise(cancelable = makeCancelable) {
28
26
  promises.current = [];
29
27
  };
30
28
  }, []);
31
-
32
29
  const cancellablePromise = p => {
33
30
  const cPromise = cancelable(p);
34
31
  promises.current.push(cPromise);
35
32
  return cPromise.promise;
36
33
  };
37
-
38
34
  return {
39
35
  cancellablePromise
40
36
  };
@@ -1,16 +1,12 @@
1
1
  import { createContext, useContext } from 'react';
2
2
  export function createCtx() {
3
3
  const ctx = /*#__PURE__*/createContext(undefined);
4
-
5
4
  function useCtx() {
6
5
  const c = useContext(ctx);
7
-
8
6
  if (!c) {
9
7
  throw new Error('useCtx must be inside a Provider with a value');
10
8
  }
11
-
12
9
  return c;
13
10
  }
14
-
15
11
  return [useCtx, ctx.Provider];
16
12
  }
@@ -1,14 +1,16 @@
1
- import { useRef, useEffect } from 'react'; // Hook
1
+ import { useRef, useEffect } from 'react';
2
2
 
3
+ // Hook
3
4
  export function usePrevious(value) {
4
5
  // The ref object is a generic container whose current property is mutable ...
5
6
  // ... and can hold any value, similar to an instance property on a class
6
- const ref = useRef(); // Store current value in ref
7
+ const ref = useRef();
7
8
 
9
+ // Store current value in ref
8
10
  useEffect(() => {
9
11
  ref.current = value;
10
12
  }, [value]); // Only re-run if value changes
11
- // Return previous value (happens before update in useEffect above)
12
13
 
14
+ // Return previous value (happens before update in useEffect above)
13
15
  return ref.current;
14
16
  }
@@ -28,6 +28,7 @@ const localesMessagesMap = {
28
28
  sv,
29
29
  zh
30
30
  };
31
+
31
32
  /**
32
33
  * Tries to get the most specific messages bundle for a given locale.
33
34
  *
@@ -38,18 +39,14 @@ const localesMessagesMap = {
38
39
  *
39
40
  * @param locale string specifying the locale like 'en_GB', or 'fr'.
40
41
  */
41
-
42
42
  export const getMessagesForLocale = locale => {
43
43
  let messages = localesMessagesMap[locale];
44
-
45
44
  if (!messages) {
46
45
  const parentLocale = locale.split(/[-_]/)[0];
47
46
  messages = localesMessagesMap[parentLocale];
48
47
  }
49
-
50
48
  if (!messages) {
51
49
  messages = en;
52
50
  }
53
-
54
51
  return messages;
55
52
  };
@@ -9,19 +9,14 @@ export const getTypeIcon = itemType => {
9
9
  switch (itemType) {
10
10
  case WHATS_NEW_ITEM_TYPES.NEW_FEATURE:
11
11
  return WhatsNewIconNew();
12
-
13
12
  case WHATS_NEW_ITEM_TYPES.EXPERIMENT:
14
13
  return WhatsNewIconExperiment();
15
-
16
14
  case WHATS_NEW_ITEM_TYPES.FIX:
17
15
  return WhatsNewIconFix();
18
-
19
16
  case WHATS_NEW_ITEM_TYPES.IMPROVEMENT:
20
17
  return WhatsNewIconImprovement();
21
-
22
18
  case WHATS_NEW_ITEM_TYPES.REMOVED:
23
19
  return WhatsNewIconRemoved();
24
-
25
20
  default:
26
21
  return '';
27
22
  }
@@ -30,16 +25,12 @@ export const getTypeTitle = itemType => {
30
25
  switch (itemType) {
31
26
  case WHATS_NEW_ITEM_TYPES.NEW_FEATURE:
32
27
  return messages.help_whats_new_filter_select_option_new;
33
-
34
28
  case WHATS_NEW_ITEM_TYPES.EXPERIMENT:
35
29
  return messages.help_whats_new_filter_select_option_experiment;
36
-
37
30
  case WHATS_NEW_ITEM_TYPES.FIX:
38
31
  return messages.help_whats_new_filter_select_option_fix;
39
-
40
32
  case WHATS_NEW_ITEM_TYPES.IMPROVEMENT:
41
33
  return messages.help_whats_new_filter_select_option_improvement;
42
-
43
34
  case WHATS_NEW_ITEM_TYPES.REMOVED:
44
35
  return messages.help_whats_new_filter_select_option_removed;
45
36
  }
@@ -1,4 +1,5 @@
1
1
  /** @jsx jsx */
2
+
2
3
  import styled from '@emotion/styled';
3
4
  import { gridSize } from '@atlaskit/theme/constants';
4
5
  import * as colors from '@atlaskit/theme/colors';
@@ -12,6 +13,7 @@ export const DividerLine = styled.div`
12
13
  margin-top: ${gridSize() * 2}px;
13
14
  box-sizing: border-box;
14
15
  `;
16
+
15
17
  /**
16
18
  * Loading container
17
19
  */
@@ -46,6 +48,7 @@ export const LoadingRectangle = styled.div`
46
48
  );
47
49
  background-repeat: no-repeat;
48
50
  `;
51
+
49
52
  /**
50
53
  * Loading Circle
51
54
  */
@@ -72,6 +75,7 @@ export const LoadingCircle = styled.div`
72
75
  );
73
76
  background-repeat: no-repeat;
74
77
  `;
78
+
75
79
  /**
76
80
  * What's new icon
77
81
  */
@@ -89,19 +93,14 @@ export const WhatsNewTypeIcon = styled.div`
89
93
  switch (type) {
90
94
  case WHATS_NEW_ITEM_TYPES.IMPROVEMENT:
91
95
  return `var(--ds-icon-warning, ${colors.Y200})`;
92
-
93
96
  case WHATS_NEW_ITEM_TYPES.NEW_FEATURE:
94
97
  return `var(--ds-icon-success, ${colors.G300})`;
95
-
96
98
  case WHATS_NEW_ITEM_TYPES.FIX:
97
99
  return `var(--ds-icon-information, ${colors.B500})`;
98
-
99
100
  case WHATS_NEW_ITEM_TYPES.EXPERIMENT:
100
101
  return `var(--ds-icon-discovery, ${colors.P500})`;
101
-
102
102
  case WHATS_NEW_ITEM_TYPES.REMOVED:
103
103
  return `var(--ds-icon-disabled, ${colors.N700})`;
104
-
105
104
  default:
106
105
  return `var(--ds-icon, ${colors.N400})`;
107
106
  }
@@ -36,14 +36,13 @@ export const getMockArticleItem = (id, routeName = '', routeGroup = '', productN
36
36
  };
37
37
  export const getMockArticleItemList = numberOfItems => {
38
38
  const articleItemList = [];
39
-
40
39
  for (var i = 0; i < numberOfItems; i++) {
41
40
  articleItemList.push(getMockArticleItem(i.toString()));
42
41
  }
43
-
44
42
  return articleItemList;
45
- }; // What's New article data
43
+ };
46
44
 
45
+ // What's New article data
47
46
  export const getMockWhatsNewArticle = (id, routeName = '', routeGroup = '', productName = '', href = '') => {
48
47
  return {
49
48
  description: 'mock article description',
@@ -75,10 +74,8 @@ export const getMockWhatsNewArticleItem = (id, type, title = `Mock What's New ar
75
74
  };
76
75
  export const getMockWhatsNewArticleItemList = numberOfItems => {
77
76
  const articleItemList = [];
78
-
79
77
  for (var i = 0; i < numberOfItems; i++) {
80
78
  articleItemList.push(getMockWhatsNewArticleItem(i.toString()));
81
79
  }
82
-
83
80
  return articleItemList;
84
81
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/help",
3
- "version": "7.1.24",
3
+ "version": "7.1.26",
4
4
  "sideEffects": false
5
5
  }
@@ -6,13 +6,11 @@ import ArticleLoadingFail from '../ArticleLoadingFail';
6
6
  import WhatsNewArticle from '../WhatsNewArticle';
7
7
  export var ArticleContent = function ArticleContent(_ref) {
8
8
  var currentArticle = _ref.currentArticle,
9
- onHelpArticleLoadingFailTryAgainButtonClick = _ref.onHelpArticleLoadingFailTryAgainButtonClick,
10
- onWhatsNewArticleLoadingFailTryAgainButtonClick = _ref.onWhatsNewArticleLoadingFailTryAgainButtonClick;
11
-
9
+ onHelpArticleLoadingFailTryAgainButtonClick = _ref.onHelpArticleLoadingFailTryAgainButtonClick,
10
+ onWhatsNewArticleLoadingFailTryAgainButtonClick = _ref.onWhatsNewArticleLoadingFailTryAgainButtonClick;
12
11
  if (currentArticle && currentArticle.id) {
13
12
  if (currentArticle.type === ARTICLE_TYPE.HELP_ARTICLE) {
14
13
  var article = currentArticle.article;
15
-
16
14
  if (article && currentArticle.state === REQUEST_STATE.done) {
17
15
  return /*#__PURE__*/React.createElement(HelpArticle, {
18
16
  article: article
@@ -27,10 +25,8 @@ export var ArticleContent = function ArticleContent(_ref) {
27
25
  });
28
26
  }
29
27
  }
30
-
31
28
  if (currentArticle.type === ARTICLE_TYPE.WHATS_NEW) {
32
29
  var _article = currentArticle.article;
33
-
34
30
  if (_article && currentArticle.state === REQUEST_STATE.done) {
35
31
  return /*#__PURE__*/React.createElement(WhatsNewArticle, {
36
32
  article: _article
@@ -46,7 +42,6 @@ export var ArticleContent = function ArticleContent(_ref) {
46
42
  }
47
43
  }
48
44
  }
49
-
50
45
  return null;
51
46
  };
52
47
  export default ArticleContent;
@@ -13,27 +13,22 @@ var ANALYTICS_CONTEXT_DATA = {
13
13
  };
14
14
  export var ArticleLoadingFail = function ArticleLoadingFail(_ref) {
15
15
  var onTryAgainButtonClick = _ref.onTryAgainButtonClick,
16
- formatMessage = _ref.intl.formatMessage;
17
-
16
+ formatMessage = _ref.intl.formatMessage;
18
17
  var _useAnalyticsEvents = useAnalyticsEvents(),
19
- createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
20
-
18
+ createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
21
19
  var handleOnTryAgainButtonClick = onTryAgainButtonClick && function (event) {
22
20
  var analyticsEvent = createAnalyticsEvent({
23
21
  action: 'clicked'
24
22
  });
25
23
  onTryAgainButtonClick(event, analyticsEvent);
26
24
  };
27
-
28
25
  return /*#__PURE__*/React.createElement(LoadingErrorMessage, null, /*#__PURE__*/React.createElement(SomethingWrongImage, null), /*#__PURE__*/React.createElement("h2", null, formatMessage(messages.help_article_error_title)), /*#__PURE__*/React.createElement("p", null, formatMessage(messages.help_article_error_text)), /*#__PURE__*/React.createElement(LoadingErrorButtonContainer, null, handleOnTryAgainButtonClick && /*#__PURE__*/React.createElement(Button, {
29
26
  onClick: handleOnTryAgainButtonClick
30
27
  }, formatMessage(messages.help_article_error_button_label))));
31
28
  };
32
-
33
29
  var ArticleLoadingFailWithContext = function ArticleLoadingFailWithContext(props) {
34
30
  return /*#__PURE__*/React.createElement(AnalyticsContext, {
35
31
  data: ANALYTICS_CONTEXT_DATA
36
32
  }, /*#__PURE__*/React.createElement(ArticleLoadingFail, props));
37
33
  };
38
-
39
34
  export default injectIntl(ArticleLoadingFailWithContext);
@@ -1,7 +1,5 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
-
3
2
  var _templateObject, _templateObject2;
4
-
5
3
  /** @jsx jsx */
6
4
  import styled from '@emotion/styled';
7
5
  import { gridSize } from '@atlaskit/theme/constants';