@atlaskit/help 4.2.3 → 6.0.0
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.
- package/CHANGELOG.md +68 -0
- package/dist/cjs/analytics.js +1 -1
- package/dist/cjs/components/Article/ArticleContent/index.js +1 -1
- package/dist/cjs/components/Article/ArticleLoadingFail/index.js +2 -2
- package/dist/cjs/components/Article/ArticleLoadingFail/styled.js +1 -1
- package/dist/cjs/components/Article/HelpArticle/Loading/index.js +2 -2
- package/dist/cjs/components/Article/HelpArticle/WasHelpfulForm/WasHelpfulNoButton.js +2 -2
- package/dist/cjs/components/Article/HelpArticle/WasHelpfulForm/WasHelpfulYesButton.js +2 -2
- package/dist/cjs/components/Article/HelpArticle/WasHelpfulForm/index.js +2 -2
- package/dist/cjs/components/Article/HelpArticle/WasHelpfulForm/styled.js +1 -1
- package/dist/cjs/components/Article/WhatsNewArticle/Loading/index.js +2 -2
- package/dist/cjs/components/Article/WhatsNewArticle/index.js +2 -2
- package/dist/cjs/components/Article/WhatsNewArticle/styled.js +1 -1
- package/dist/cjs/components/ArticlesList/ArticlesListItem/index.js +3 -3
- package/dist/cjs/components/ArticlesList/ArticlesListItem/styled.js +1 -1
- package/dist/cjs/components/ArticlesList/constants.js +1 -1
- package/dist/cjs/components/ArticlesList/styled.js +1 -1
- package/dist/cjs/components/HelpContent.js +7 -9
- package/dist/cjs/components/HelpContentButton/styled.js +1 -1
- package/dist/cjs/components/MessagesIntlProvider.js +7 -7
- package/dist/cjs/components/RelatedArticles/RelatedArticlesLoading.js +2 -2
- package/dist/cjs/components/RelatedArticles/index.js +2 -2
- package/dist/cjs/components/RelatedArticles/styled.js +1 -1
- package/dist/cjs/components/Search/SearchInput/index.js +2 -2
- package/dist/cjs/components/Search/SearchInput/styled.js +1 -1
- package/dist/cjs/components/Search/SearchResults/SearchExternalSite.js +2 -2
- package/dist/cjs/components/Search/SearchResults/SearchResultsEmpty.js +2 -2
- package/dist/cjs/components/Search/SearchResults/SearchResultsError.js +2 -2
- package/dist/cjs/components/Search/SearchResults/styled.js +1 -1
- package/dist/cjs/components/ShowMoreButton/index.js +2 -2
- package/dist/cjs/components/WhatsNew/WhatsNewButton/index.js +2 -2
- package/dist/cjs/components/WhatsNew/WhatsNewResults/WhatsNewResultsEmpty/index.js +52 -0
- package/dist/cjs/components/WhatsNew/WhatsNewResults/WhatsNewResultsEmpty/styled.js +32 -0
- package/dist/cjs/components/WhatsNew/WhatsNewResults/WhatsNewResultsError/index.js +2 -2
- package/dist/cjs/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/WhatsNewResultItem/index.js +2 -2
- package/dist/cjs/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/WhatsNewResultItem/styled.js +1 -1
- package/dist/cjs/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/styled.js +1 -1
- package/dist/cjs/components/WhatsNew/WhatsNewResults/WhatsNewResultsLoading/index.js +2 -2
- package/dist/cjs/components/WhatsNew/WhatsNewResults/index.js +33 -11
- package/dist/cjs/components/WhatsNew/WhatsNewResults/styled.js +1 -1
- package/dist/cjs/components/constants.js +1 -1
- package/dist/cjs/components/contexts/headerContext.js +1 -1
- package/dist/cjs/components/contexts/helpArticleContext.js +1 -1
- package/dist/cjs/components/contexts/homeContext.js +1 -1
- package/dist/cjs/components/contexts/navigationContext.js +393 -473
- package/dist/cjs/components/contexts/relatedArticlesContext.js +1 -1
- package/dist/cjs/components/contexts/searchContext.js +1 -1
- package/dist/cjs/components/contexts/whatsNewArticleContext.js +2 -3
- package/dist/cjs/components/styled.js +2 -2
- package/dist/cjs/i18n/index.js +18 -18
- package/dist/cjs/index.js +16 -16
- package/dist/cjs/messages.js +23 -3
- package/dist/cjs/util/hooks/cancellablePromise.js +1 -1
- package/dist/cjs/util/styled.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/Article/ArticleContent/index.js +1 -1
- package/dist/es2019/components/Article/ArticleLoadingFail/index.js +1 -1
- package/dist/es2019/components/Article/HelpArticle/Loading/index.js +1 -1
- package/dist/es2019/components/Article/HelpArticle/WasHelpfulForm/WasHelpfulNoButton.js +1 -1
- package/dist/es2019/components/Article/HelpArticle/WasHelpfulForm/WasHelpfulYesButton.js +1 -1
- package/dist/es2019/components/Article/HelpArticle/WasHelpfulForm/index.js +1 -1
- package/dist/es2019/components/Article/WhatsNewArticle/Loading/index.js +1 -1
- package/dist/es2019/components/Article/WhatsNewArticle/index.js +1 -1
- package/dist/es2019/components/ArticlesList/ArticlesListItem/index.js +1 -1
- package/dist/es2019/components/HelpContent.js +7 -8
- package/dist/es2019/components/MessagesIntlProvider.js +4 -4
- package/dist/es2019/components/RelatedArticles/RelatedArticlesLoading.js +1 -1
- package/dist/es2019/components/RelatedArticles/index.js +1 -1
- package/dist/es2019/components/Search/SearchInput/index.js +1 -1
- package/dist/es2019/components/Search/SearchResults/SearchExternalSite.js +1 -1
- package/dist/es2019/components/Search/SearchResults/SearchResultsEmpty.js +1 -1
- package/dist/es2019/components/Search/SearchResults/SearchResultsError.js +1 -1
- package/dist/es2019/components/ShowMoreButton/index.js +1 -1
- package/dist/es2019/components/WhatsNew/WhatsNewButton/index.js +1 -1
- package/dist/es2019/components/WhatsNew/WhatsNewResults/WhatsNewResultsEmpty/index.js +35 -0
- package/dist/es2019/components/WhatsNew/WhatsNewResults/WhatsNewResultsEmpty/styled.js +16 -0
- package/dist/es2019/components/WhatsNew/WhatsNewResults/WhatsNewResultsError/index.js +1 -1
- package/dist/es2019/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/WhatsNewResultItem/index.js +1 -1
- package/dist/es2019/components/WhatsNew/WhatsNewResults/WhatsNewResultsLoading/index.js +1 -1
- package/dist/es2019/components/WhatsNew/WhatsNewResults/index.js +32 -10
- package/dist/es2019/components/contexts/navigationContext.js +336 -347
- package/dist/es2019/components/contexts/whatsNewArticleContext.js +1 -2
- package/dist/es2019/components/styled.js +1 -1
- package/dist/es2019/messages.js +22 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/Article/ArticleContent/index.js +1 -1
- package/dist/esm/components/Article/ArticleLoadingFail/index.js +1 -1
- package/dist/esm/components/Article/HelpArticle/Loading/index.js +1 -1
- package/dist/esm/components/Article/HelpArticle/WasHelpfulForm/WasHelpfulNoButton.js +1 -1
- package/dist/esm/components/Article/HelpArticle/WasHelpfulForm/WasHelpfulYesButton.js +1 -1
- package/dist/esm/components/Article/HelpArticle/WasHelpfulForm/index.js +1 -1
- package/dist/esm/components/Article/WhatsNewArticle/Loading/index.js +1 -1
- package/dist/esm/components/Article/WhatsNewArticle/index.js +1 -1
- package/dist/esm/components/ArticlesList/ArticlesListItem/index.js +1 -1
- package/dist/esm/components/HelpContent.js +7 -9
- package/dist/esm/components/MessagesIntlProvider.js +5 -4
- package/dist/esm/components/RelatedArticles/RelatedArticlesLoading.js +1 -1
- package/dist/esm/components/RelatedArticles/index.js +1 -1
- package/dist/esm/components/Search/SearchInput/index.js +1 -1
- package/dist/esm/components/Search/SearchResults/SearchExternalSite.js +1 -1
- package/dist/esm/components/Search/SearchResults/SearchResultsEmpty.js +1 -1
- package/dist/esm/components/Search/SearchResults/SearchResultsError.js +1 -1
- package/dist/esm/components/ShowMoreButton/index.js +1 -1
- package/dist/esm/components/WhatsNew/WhatsNewButton/index.js +1 -1
- package/dist/esm/components/WhatsNew/WhatsNewResults/WhatsNewResultsEmpty/index.js +32 -0
- package/dist/esm/components/WhatsNew/WhatsNewResults/WhatsNewResultsEmpty/styled.js +10 -0
- package/dist/esm/components/WhatsNew/WhatsNewResults/WhatsNewResultsError/index.js +1 -1
- package/dist/esm/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/WhatsNewResultItem/index.js +1 -1
- package/dist/esm/components/WhatsNew/WhatsNewResults/WhatsNewResultsLoading/index.js +1 -1
- package/dist/esm/components/WhatsNew/WhatsNewResults/index.js +31 -10
- package/dist/esm/components/contexts/navigationContext.js +395 -474
- package/dist/esm/components/contexts/whatsNewArticleContext.js +1 -2
- package/dist/esm/components/styled.js +1 -1
- package/dist/esm/messages.js +22 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics.d.ts +1 -1
- package/dist/types/assets/ErrorImage.d.ts +1 -0
- package/dist/types/assets/NotFoundImage.d.ts +1 -0
- package/dist/types/assets/SomethingWrongImage.d.ts +1 -0
- package/dist/types/assets/WhatsNewIcoExperiment.d.ts +1 -0
- package/dist/types/assets/WhatsNewIconFix.d.ts +1 -0
- package/dist/types/assets/WhatsNewIconImprovement.d.ts +1 -0
- package/dist/types/assets/WhatsNewIconNew.d.ts +1 -0
- package/dist/types/assets/WhatsNewIconRemoved.d.ts +1 -0
- package/dist/types/components/Article/ArticleLoadingFail/index.d.ts +4 -4
- package/dist/types/components/Article/ArticleLoadingFail/styled.d.ts +2 -2
- package/dist/types/components/Article/HelpArticle/Loading/index.d.ts +4 -4
- package/dist/types/components/Article/HelpArticle/WasHelpfulForm/WasHelpfulNoButton.d.ts +4 -4
- package/dist/types/components/Article/HelpArticle/WasHelpfulForm/WasHelpfulYesButton.d.ts +4 -4
- package/dist/types/components/Article/HelpArticle/WasHelpfulForm/index.d.ts +4 -4
- package/dist/types/components/Article/HelpArticle/WasHelpfulForm/styled.d.ts +3 -3
- package/dist/types/components/Article/WhatsNewArticle/Loading/index.d.ts +4 -4
- package/dist/types/components/Article/WhatsNewArticle/index.d.ts +4 -4
- package/dist/types/components/Article/WhatsNewArticle/styled.d.ts +6 -6
- package/dist/types/components/Article/styled.d.ts +1 -1
- package/dist/types/components/ArticlesList/ArticlesListItem/index.d.ts +4 -4
- package/dist/types/components/ArticlesList/ArticlesListItem/styled.d.ts +5 -5
- package/dist/types/components/ArticlesList/styled.d.ts +2 -2
- package/dist/types/components/Help.d.ts +1 -1
- package/dist/types/components/MessagesIntlProvider.d.ts +6 -5
- package/dist/types/components/RelatedArticles/RelatedArticlesLoading.d.ts +3 -3
- package/dist/types/components/RelatedArticles/index.d.ts +7 -3
- package/dist/types/components/RelatedArticles/styled.d.ts +3 -3
- package/dist/types/components/Search/SearchInput/index.d.ts +4 -4
- package/dist/types/components/Search/SearchInput/styled.d.ts +3 -3
- package/dist/types/components/Search/SearchResults/SearchExternalSite.d.ts +4 -4
- package/dist/types/components/Search/SearchResults/SearchResultsEmpty.d.ts +4 -4
- package/dist/types/components/Search/SearchResults/SearchResultsError.d.ts +4 -4
- package/dist/types/components/Search/SearchResults/styled.d.ts +5 -5
- package/dist/types/components/ShowMoreButton/index.d.ts +4 -4
- package/dist/types/components/WhatsNew/WhatsNewButton/index.d.ts +4 -4
- package/dist/types/components/WhatsNew/WhatsNewResults/WhatsNewResultsEmpty/index.d.ts +10 -0
- package/dist/types/components/WhatsNew/WhatsNewResults/WhatsNewResultsEmpty/styled.d.ts +3 -0
- package/dist/types/components/WhatsNew/WhatsNewResults/WhatsNewResultsError/index.d.ts +4 -4
- package/dist/types/components/WhatsNew/WhatsNewResults/WhatsNewResultsError/styled.d.ts +2 -2
- package/dist/types/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/WhatsNewResultItem/index.d.ts +4 -4
- package/dist/types/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/WhatsNewResultItem/styled.d.ts +3 -3
- package/dist/types/components/WhatsNew/WhatsNewResults/WhatsNewResultsList/styled.d.ts +4 -4
- package/dist/types/components/WhatsNew/WhatsNewResults/WhatsNewResultsLoading/index.d.ts +4 -4
- package/dist/types/components/WhatsNew/WhatsNewResults/WhatsNewResultsLoading/styled.d.ts +2 -2
- package/dist/types/components/WhatsNew/WhatsNewResults/index.d.ts +4 -4
- package/dist/types/components/WhatsNew/WhatsNewResults/styled.d.ts +4 -4
- package/dist/types/components/contexts/navigationContext.d.ts +8 -6
- package/dist/types/messages.d.ts +20 -0
- package/dist/types/util/index.d.ts +1 -0
- package/dist/types/util/styled.d.ts +1 -1
- package/package.json +5 -5
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
2
1
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
4
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
5
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
6
6
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
7
7
|
|
|
8
8
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
9
9
|
|
|
10
10
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
11
11
|
|
|
12
|
-
import React, {
|
|
12
|
+
import React, { useReducer, useEffect, useCallback, useMemo } from 'react';
|
|
13
13
|
import { REQUEST_STATE } from '../../model/Requests';
|
|
14
14
|
import { ARTICLE_TYPE } from '../../model/Help';
|
|
15
15
|
import { createCtx } from '../../util/hooks/ctx';
|
|
@@ -26,12 +26,176 @@ var _createCtx = createCtx(),
|
|
|
26
26
|
CtxProvider = _createCtx2[1];
|
|
27
27
|
|
|
28
28
|
export { useNavigationContext, CtxProvider };
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
|
|
30
|
+
var getNewHistoryItem = function getNewHistoryItem(id, type) {
|
|
31
|
+
var uid = Math.floor(Math.random() * Math.pow(10, 17));
|
|
32
|
+
var newHistoryItem = {
|
|
33
|
+
uid: uid,
|
|
34
|
+
id: id,
|
|
35
|
+
type: type,
|
|
36
|
+
state: REQUEST_STATE.loading
|
|
37
|
+
};
|
|
38
|
+
return newHistoryItem;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Get a simplified version of the history. The items in this array should
|
|
42
|
+
* have only the ID, UID and state === 'reload'
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
var getSimpleHistory = function getSimpleHistory(history) {
|
|
47
|
+
return history.map(function (historyItem) {
|
|
48
|
+
var id = historyItem.id,
|
|
49
|
+
uid = historyItem.uid,
|
|
50
|
+
type = historyItem.type;
|
|
51
|
+
return {
|
|
52
|
+
id: id,
|
|
53
|
+
uid: uid,
|
|
54
|
+
state: REQUEST_STATE.reload,
|
|
55
|
+
type: type
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Get the last article in the history
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
var _getCurrentArticle2 = function getCurrentArticle(history) {
|
|
65
|
+
return history[history.length - 1];
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Get an ArticleItem/WhatsNewArticleItem based on the last article in the history
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
var getCurrentArticleItemSlim = function getCurrentArticleItemSlim(history) {
|
|
73
|
+
var _getCurrentArticle = _getCurrentArticle2(history),
|
|
74
|
+
article = _getCurrentArticle.article,
|
|
75
|
+
type = _getCurrentArticle.type;
|
|
76
|
+
|
|
77
|
+
if (article) {
|
|
78
|
+
if (type === ARTICLE_TYPE.HELP_ARTICLE) {
|
|
79
|
+
var _ref = article,
|
|
80
|
+
body = _ref.body,
|
|
81
|
+
relatedArticles = _ref.relatedArticles,
|
|
82
|
+
articleItemData = _objectWithoutProperties(_ref, ["body", "relatedArticles"]);
|
|
83
|
+
|
|
84
|
+
var currentArticleSlimData = articleItemData;
|
|
85
|
+
return currentArticleSlimData;
|
|
86
|
+
} else if (type === ARTICLE_TYPE.WHATS_NEW) {
|
|
87
|
+
var _ref2 = article,
|
|
88
|
+
description = _ref2.description,
|
|
89
|
+
whatsNewArticleItemData = _objectWithoutProperties(_ref2, ["description"]);
|
|
90
|
+
|
|
91
|
+
var currentWhatsNewArticleSlimData = whatsNewArticleItemData;
|
|
92
|
+
return currentWhatsNewArticleSlimData;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
var getViewForArticleId = function getViewForArticleId(articleId) {
|
|
98
|
+
var view = VIEW.DEFAULT_CONTENT;
|
|
99
|
+
|
|
100
|
+
if (articleId.type === ARTICLE_TYPE.HELP_ARTICLE) {
|
|
101
|
+
if (articleId.id) {
|
|
102
|
+
view = VIEW.ARTICLE;
|
|
103
|
+
} else {
|
|
104
|
+
view = VIEW.DEFAULT_CONTENT;
|
|
105
|
+
}
|
|
106
|
+
} else if (articleId.type === ARTICLE_TYPE.WHATS_NEW) {
|
|
107
|
+
if (articleId.id) {
|
|
108
|
+
view = VIEW.WHATS_NEW_ARTICLE;
|
|
109
|
+
} else {
|
|
110
|
+
view = VIEW.WHATS_NEW;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return view;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
var navigationReducer = function navigationReducer(_ref3, action) {
|
|
118
|
+
var currentArticleId = _ref3.articleId,
|
|
119
|
+
currentHistory = _ref3.history,
|
|
120
|
+
currentView = _ref3.view;
|
|
121
|
+
var newState = {
|
|
122
|
+
articleId: currentArticleId,
|
|
123
|
+
history: currentHistory,
|
|
124
|
+
view: currentView
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
if (action.type === 'newArticle' && action.payload) {
|
|
128
|
+
var newArticleId = action.payload;
|
|
129
|
+
newState = {
|
|
130
|
+
articleId: newArticleId,
|
|
131
|
+
history: [].concat(_toConsumableArray(currentHistory), [getNewHistoryItem(newArticleId.id, newArticleId.type)]),
|
|
132
|
+
view: getViewForArticleId(newArticleId)
|
|
133
|
+
};
|
|
134
|
+
} else if (action.type === 'updateHistoryItem' && action.payload) {
|
|
135
|
+
var HistoryItemUpdate = action.payload;
|
|
136
|
+
var index = currentHistory.findIndex(function (historyItemTemp) {
|
|
137
|
+
return historyItemTemp.uid === HistoryItemUpdate.uid;
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
if (index !== -1) {
|
|
141
|
+
var newHistory = _toConsumableArray(currentHistory);
|
|
142
|
+
|
|
143
|
+
newHistory[index] = _objectSpread({}, HistoryItemUpdate);
|
|
144
|
+
newState = {
|
|
145
|
+
articleId: currentArticleId,
|
|
146
|
+
history: newHistory,
|
|
147
|
+
view: getViewForArticleId(currentArticleId)
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
} else if (action.type === 'removeLastHistoryItem') {
|
|
151
|
+
var _newHistory = currentHistory.length > 0 ? _toConsumableArray(currentHistory) : [];
|
|
152
|
+
|
|
153
|
+
if (_newHistory.length > 0) {
|
|
154
|
+
_newHistory.splice(-1);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
newState = {
|
|
158
|
+
articleId: currentArticleId,
|
|
159
|
+
history: _newHistory,
|
|
160
|
+
view: getViewForArticleId(currentArticleId)
|
|
161
|
+
};
|
|
162
|
+
} else if (action.type === 'removeAllHistoryItems') {
|
|
163
|
+
var defaultHistory = [];
|
|
164
|
+
newState = {
|
|
165
|
+
articleId: currentArticleId,
|
|
166
|
+
history: defaultHistory,
|
|
167
|
+
view: VIEW.DEFAULT_CONTENT
|
|
168
|
+
};
|
|
169
|
+
} else if (action.type === 'updateArticleId' && action.payload) {
|
|
170
|
+
var _newArticleId = action.payload;
|
|
171
|
+
newState = {
|
|
172
|
+
articleId: _newArticleId,
|
|
173
|
+
history: currentHistory,
|
|
174
|
+
view: getViewForArticleId(_newArticleId)
|
|
175
|
+
};
|
|
176
|
+
} else if (action.type === 'updateView' && action.payload) {
|
|
177
|
+
var newView = action.payload;
|
|
178
|
+
newState = {
|
|
179
|
+
articleId: currentArticleId,
|
|
180
|
+
history: currentHistory,
|
|
181
|
+
view: newView
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return newState;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
export var NavigationContextProvider = function NavigationContextProvider(_ref4) {
|
|
189
|
+
var _ref4$articleId = _ref4.articleId,
|
|
190
|
+
propsArticleId = _ref4$articleId === void 0 ? {
|
|
191
|
+
id: '',
|
|
192
|
+
type: ARTICLE_TYPE.HELP_ARTICLE
|
|
193
|
+
} : _ref4$articleId,
|
|
194
|
+
articleIdSetter = _ref4.articleIdSetter,
|
|
195
|
+
_ref4$history = _ref4.history,
|
|
196
|
+
propsHistory = _ref4$history === void 0 ? [] : _ref4$history,
|
|
197
|
+
historySetter = _ref4.historySetter,
|
|
198
|
+
children = _ref4.children;
|
|
35
199
|
|
|
36
200
|
var _useHelpArticleContex = useHelpArticleContext(),
|
|
37
201
|
onGetHelpArticle = _useHelpArticleContex.onGetHelpArticle;
|
|
@@ -45,567 +209,324 @@ export var NavigationContextProvider = function NavigationContextProvider(_ref)
|
|
|
45
209
|
|
|
46
210
|
var _useSearchContext = useSearchContext(),
|
|
47
211
|
onSearch = _useSearchContext.onSearch,
|
|
48
|
-
isSearchResultVisible = _useSearchContext.isSearchResultVisible
|
|
212
|
+
isSearchResultVisible = _useSearchContext.isSearchResultVisible,
|
|
213
|
+
searchValue = _useSearchContext.searchValue;
|
|
49
214
|
|
|
50
215
|
var _useHeaderContext = useHeaderContext(),
|
|
51
216
|
onCloseButtonClick = _useHeaderContext.onCloseButtonClick;
|
|
52
217
|
|
|
53
|
-
var
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}, [
|
|
68
|
-
|
|
69
|
-
var _useState3 = useState(propsHistory ? propsHistory : []),
|
|
70
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
71
|
-
history = _useState4[0],
|
|
72
|
-
setHistory = _useState4[1];
|
|
73
|
-
|
|
74
|
-
var tempHistory = useRef(propsHistory ? propsHistory : []);
|
|
75
|
-
var clearHistory = useCallback(function () {
|
|
76
|
-
if (tempHistory.current.length > 0) {
|
|
77
|
-
if (!articleIdSetter) {
|
|
78
|
-
return;
|
|
79
|
-
} // Clear History
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
tempHistory.current = [];
|
|
83
|
-
setHistory(tempHistory.current); // Clear host history using the historySetter
|
|
84
|
-
|
|
85
|
-
historySetter && historySetter(tempHistory.current); // Set article ID to ''
|
|
86
|
-
|
|
87
|
-
articleIdSetter({
|
|
88
|
-
id: '',
|
|
89
|
-
type: ARTICLE_TYPE.HELP_ARTICLE
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}, [articleIdSetter, historySetter]);
|
|
93
|
-
var isDefaultContentDefined = useCallback(function () {
|
|
218
|
+
var _useReducer = useReducer(navigationReducer, {
|
|
219
|
+
articleId: propsArticleId,
|
|
220
|
+
history: propsHistory,
|
|
221
|
+
view: VIEW.DEFAULT_CONTENT
|
|
222
|
+
}),
|
|
223
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
224
|
+
_useReducer2$ = _useReducer2[0],
|
|
225
|
+
currentArticleId = _useReducer2$.articleId,
|
|
226
|
+
currentHistory = _useReducer2$.history,
|
|
227
|
+
currentView = _useReducer2$.view,
|
|
228
|
+
dispatchNavigationAction = _useReducer2[1];
|
|
229
|
+
|
|
230
|
+
var isOverlayVisible = useMemo(function () {
|
|
231
|
+
return currentView === VIEW.ARTICLE || currentView === VIEW.SEARCH || currentView === VIEW.WHATS_NEW || currentView === VIEW.WHATS_NEW_ARTICLE;
|
|
232
|
+
}, [currentView]);
|
|
233
|
+
var isDefaultContentDefined = useMemo(function () {
|
|
94
234
|
return homeContent !== undefined || homeOptions !== undefined;
|
|
95
235
|
}, [homeContent, homeOptions]);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return newHistoryItem;
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
* Get a simplified version of the history. The items in the history have only
|
|
109
|
-
* the ID, UID and state === 'reload'
|
|
110
|
-
*/
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
var getSimpleHistory = useCallback(function (fullHistory) {
|
|
114
|
-
var copyHistory = fullHistory.map(function (tempHistoryItem) {
|
|
115
|
-
var id = tempHistoryItem.id,
|
|
116
|
-
uid = tempHistoryItem.uid,
|
|
117
|
-
type = tempHistoryItem.type;
|
|
118
|
-
return {
|
|
119
|
-
id: id,
|
|
120
|
-
uid: uid,
|
|
121
|
-
state: REQUEST_STATE.reload,
|
|
122
|
-
type: type
|
|
123
|
-
};
|
|
124
|
-
});
|
|
125
|
-
return copyHistory;
|
|
126
|
-
}, []);
|
|
127
|
-
var updateView = useCallback(function () {
|
|
128
|
-
if (isSearchResultVisible) {
|
|
129
|
-
setView(VIEW.SEARCH);
|
|
130
|
-
} else if ((articleId === null || articleId === void 0 ? void 0 : articleId.type) === ARTICLE_TYPE.HELP_ARTICLE) {
|
|
131
|
-
if (articleId.id) {
|
|
132
|
-
setView(VIEW.ARTICLE);
|
|
133
|
-
} else {
|
|
134
|
-
setView(VIEW.DEFAULT_CONTENT);
|
|
135
|
-
}
|
|
136
|
-
} else if ((articleId === null || articleId === void 0 ? void 0 : articleId.type) === ARTICLE_TYPE.WHATS_NEW) {
|
|
137
|
-
if (articleId.id) {
|
|
138
|
-
setView(VIEW.WHATS_NEW_ARTICLE);
|
|
139
|
-
} else {
|
|
140
|
-
setView(VIEW.WHATS_NEW);
|
|
141
|
-
}
|
|
236
|
+
var canNavigateBack = useMemo(function () {
|
|
237
|
+
/**
|
|
238
|
+
* - If default content isn't defined and the history only has one article,
|
|
239
|
+
* we should not display the back button
|
|
240
|
+
* - If the prop.article.setArticleId is not defined, we should also hide the back
|
|
241
|
+
* button because we are not able to navigate though the history without it
|
|
242
|
+
*/
|
|
243
|
+
if (currentHistory.length === 1 && !isDefaultContentDefined || currentView === VIEW.WHATS_NEW && !isDefaultContentDefined) {
|
|
244
|
+
return false;
|
|
142
245
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return historyItemTemp.uid === historyItem.uid;
|
|
147
|
-
});
|
|
246
|
+
/**
|
|
247
|
+
* if an overlay is visible return true to display the back buton
|
|
248
|
+
*/
|
|
148
249
|
|
|
149
|
-
if (index !== -1) {
|
|
150
|
-
var newHistory = _toConsumableArray(tempHistory.current);
|
|
151
250
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
}, [getSimpleHistory, historySetter]);
|
|
159
|
-
var reloadHelpArticle = useCallback( /*#__PURE__*/function () {
|
|
160
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(historyItem) {
|
|
161
|
-
var reloadingHelpArticleHistoryItem, article;
|
|
251
|
+
return isOverlayVisible;
|
|
252
|
+
}, [currentHistory.length, isDefaultContentDefined, isOverlayVisible, currentView]);
|
|
253
|
+
var fetchArticleData = useCallback( /*#__PURE__*/function () {
|
|
254
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(historyItem) {
|
|
255
|
+
var article;
|
|
162
256
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
163
257
|
while (1) {
|
|
164
258
|
switch (_context.prev = _context.next) {
|
|
165
259
|
case 0:
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
260
|
+
_context.prev = 0;
|
|
261
|
+
_context.t0 = historyItem.type;
|
|
262
|
+
_context.next = _context.t0 === ARTICLE_TYPE.HELP_ARTICLE ? 4 : _context.t0 === ARTICLE_TYPE.WHATS_NEW ? 10 : 18;
|
|
263
|
+
break;
|
|
172
264
|
|
|
173
|
-
|
|
265
|
+
case 4:
|
|
266
|
+
if (onGetHelpArticle) {
|
|
174
267
|
_context.next = 6;
|
|
175
268
|
break;
|
|
176
269
|
}
|
|
177
270
|
|
|
178
|
-
|
|
179
|
-
state: REQUEST_STATE.error
|
|
180
|
-
});
|
|
181
|
-
_context.next = 18;
|
|
182
|
-
break;
|
|
271
|
+
throw new Error('onGetHelpArticle prop not defined');
|
|
183
272
|
|
|
184
273
|
case 6:
|
|
185
|
-
|
|
186
|
-
updateHistoryItem(reloadingHelpArticleHistoryItem);
|
|
187
|
-
_context.prev = 8;
|
|
188
|
-
_context.next = 11;
|
|
274
|
+
_context.next = 8;
|
|
189
275
|
return onGetHelpArticle({
|
|
190
|
-
id:
|
|
191
|
-
type:
|
|
276
|
+
id: historyItem.id,
|
|
277
|
+
type: historyItem.type
|
|
192
278
|
});
|
|
193
279
|
|
|
194
|
-
case
|
|
280
|
+
case 8:
|
|
195
281
|
article = _context.sent;
|
|
196
|
-
|
|
197
|
-
state: REQUEST_STATE.done,
|
|
198
|
-
article: article
|
|
199
|
-
});
|
|
200
|
-
_context.next = 18;
|
|
201
|
-
break;
|
|
202
|
-
|
|
203
|
-
case 15:
|
|
204
|
-
_context.prev = 15;
|
|
205
|
-
_context.t0 = _context["catch"](8);
|
|
206
|
-
reloadingHelpArticleHistoryItem = _objectSpread(_objectSpread({}, reloadingHelpArticleHistoryItem), {}, {
|
|
207
|
-
state: REQUEST_STATE.error
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
case 18:
|
|
211
|
-
_context.next = 21;
|
|
212
|
-
break;
|
|
282
|
+
return _context.abrupt("break", 20);
|
|
213
283
|
|
|
214
|
-
case
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
case 21:
|
|
220
|
-
updateHistoryItem(reloadingHelpArticleHistoryItem);
|
|
221
|
-
|
|
222
|
-
case 22:
|
|
223
|
-
case "end":
|
|
224
|
-
return _context.stop();
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}, _callee, null, [[8, 15]]);
|
|
228
|
-
}));
|
|
229
|
-
|
|
230
|
-
return function (_x) {
|
|
231
|
-
return _ref2.apply(this, arguments);
|
|
232
|
-
};
|
|
233
|
-
}(), [onGetHelpArticle, updateHistoryItem]);
|
|
234
|
-
var reloadWhatsNewArticle = useCallback( /*#__PURE__*/function () {
|
|
235
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(historyItem) {
|
|
236
|
-
var reloadingWhatsNewArticleHistoryItem, article;
|
|
237
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
238
|
-
while (1) {
|
|
239
|
-
switch (_context2.prev = _context2.next) {
|
|
240
|
-
case 0:
|
|
241
|
-
reloadingWhatsNewArticleHistoryItem = historyItem;
|
|
242
|
-
|
|
243
|
-
if (!onGetWhatsNewArticle) {
|
|
244
|
-
_context2.next = 20;
|
|
284
|
+
case 10:
|
|
285
|
+
if (onGetWhatsNewArticle) {
|
|
286
|
+
_context.next = 12;
|
|
245
287
|
break;
|
|
246
288
|
}
|
|
247
289
|
|
|
248
|
-
|
|
249
|
-
|
|
290
|
+
throw new Error('onGetWhatsNewArticle prop not defined');
|
|
291
|
+
|
|
292
|
+
case 12:
|
|
293
|
+
if (!(historyItem.id === '')) {
|
|
294
|
+
_context.next = 14;
|
|
250
295
|
break;
|
|
251
296
|
}
|
|
252
297
|
|
|
253
|
-
|
|
254
|
-
reloadingWhatsNewArticleHistoryItem = _objectSpread(_objectSpread({}, reloadingWhatsNewArticleHistoryItem), {}, {
|
|
255
|
-
state: REQUEST_STATE.error
|
|
256
|
-
});
|
|
257
|
-
_context2.next = 18;
|
|
258
|
-
break;
|
|
298
|
+
return _context.abrupt("break", 20);
|
|
259
299
|
|
|
260
|
-
case
|
|
261
|
-
|
|
262
|
-
updateHistoryItem(reloadingWhatsNewArticleHistoryItem);
|
|
263
|
-
_context2.prev = 8;
|
|
264
|
-
_context2.next = 11;
|
|
300
|
+
case 14:
|
|
301
|
+
_context.next = 16;
|
|
265
302
|
return onGetWhatsNewArticle({
|
|
266
|
-
id:
|
|
267
|
-
type:
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
case 11:
|
|
271
|
-
article = _context2.sent;
|
|
272
|
-
reloadingWhatsNewArticleHistoryItem = _objectSpread(_objectSpread({}, reloadingWhatsNewArticleHistoryItem), {}, {
|
|
273
|
-
state: REQUEST_STATE.done,
|
|
274
|
-
article: article
|
|
303
|
+
id: historyItem.id,
|
|
304
|
+
type: historyItem.type
|
|
275
305
|
});
|
|
276
|
-
_context2.next = 18;
|
|
277
|
-
break;
|
|
278
306
|
|
|
279
|
-
case
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
reloadingWhatsNewArticleHistoryItem = _objectSpread(_objectSpread({}, reloadingWhatsNewArticleHistoryItem), {}, {
|
|
283
|
-
state: REQUEST_STATE.error
|
|
284
|
-
});
|
|
307
|
+
case 16:
|
|
308
|
+
article = _context.sent;
|
|
309
|
+
return _context.abrupt("break", 20);
|
|
285
310
|
|
|
286
311
|
case 18:
|
|
287
|
-
|
|
288
|
-
break;
|
|
312
|
+
throw new Error('onGetHelpArticle prop not defined');
|
|
289
313
|
|
|
290
314
|
case 20:
|
|
291
|
-
|
|
315
|
+
return _context.abrupt("return", _objectSpread(_objectSpread(_objectSpread({}, historyItem), article && {
|
|
316
|
+
article: article
|
|
317
|
+
}), {}, {
|
|
318
|
+
state: REQUEST_STATE.done
|
|
319
|
+
}));
|
|
320
|
+
|
|
321
|
+
case 23:
|
|
322
|
+
_context.prev = 23;
|
|
323
|
+
_context.t1 = _context["catch"](0);
|
|
324
|
+
return _context.abrupt("return", _objectSpread(_objectSpread({}, historyItem), {}, {
|
|
292
325
|
state: REQUEST_STATE.error
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
case 21:
|
|
296
|
-
updateHistoryItem(reloadingWhatsNewArticleHistoryItem);
|
|
326
|
+
}));
|
|
297
327
|
|
|
298
|
-
case
|
|
328
|
+
case 26:
|
|
299
329
|
case "end":
|
|
300
|
-
return
|
|
330
|
+
return _context.stop();
|
|
301
331
|
}
|
|
302
332
|
}
|
|
303
|
-
},
|
|
333
|
+
}, _callee, null, [[0, 23]]);
|
|
304
334
|
}));
|
|
305
335
|
|
|
306
|
-
return function (
|
|
307
|
-
return
|
|
336
|
+
return function (_x) {
|
|
337
|
+
return _ref5.apply(this, arguments);
|
|
308
338
|
};
|
|
309
|
-
}(), [
|
|
310
|
-
var
|
|
311
|
-
var
|
|
312
|
-
var
|
|
313
|
-
|
|
314
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
339
|
+
}(), [onGetHelpArticle, onGetWhatsNewArticle]);
|
|
340
|
+
var reloadArticle = useCallback( /*#__PURE__*/function () {
|
|
341
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(historyItem) {
|
|
342
|
+
var historyItemToReload;
|
|
343
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
315
344
|
while (1) {
|
|
316
|
-
switch (
|
|
345
|
+
switch (_context2.prev = _context2.next) {
|
|
317
346
|
case 0:
|
|
318
|
-
|
|
319
|
-
_context3.next = 17;
|
|
320
|
-
break;
|
|
321
|
-
}
|
|
347
|
+
historyItemToReload = _objectSpread({}, historyItem);
|
|
322
348
|
|
|
323
|
-
if (
|
|
324
|
-
|
|
325
|
-
|
|
349
|
+
if (historyItem.type === ARTICLE_TYPE.HELP_ARTICLE || historyItem.type === ARTICLE_TYPE.WHATS_NEW) {
|
|
350
|
+
historyItemToReload.state = REQUEST_STATE.loading;
|
|
351
|
+
} else {
|
|
352
|
+
historyItemToReload.state = REQUEST_STATE.error;
|
|
326
353
|
}
|
|
327
354
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
id: historyItem.id,
|
|
332
|
-
type: historyItem.type
|
|
355
|
+
dispatchNavigationAction({
|
|
356
|
+
type: 'updateHistoryItem',
|
|
357
|
+
payload: historyItemToReload
|
|
333
358
|
});
|
|
334
359
|
|
|
335
|
-
case
|
|
336
|
-
article = _context3.sent;
|
|
337
|
-
updateHistoryItem(historyItem, {
|
|
338
|
-
state: REQUEST_STATE.done,
|
|
339
|
-
article: article
|
|
340
|
-
});
|
|
341
|
-
_context3.next = 12;
|
|
342
|
-
break;
|
|
343
|
-
|
|
344
|
-
case 9:
|
|
345
|
-
_context3.prev = 9;
|
|
346
|
-
_context3.t0 = _context3["catch"](2);
|
|
347
|
-
updateHistoryItem(historyItem, {
|
|
348
|
-
state: REQUEST_STATE.error
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
case 12:
|
|
352
|
-
_context3.next = 15;
|
|
353
|
-
break;
|
|
354
|
-
|
|
355
|
-
case 14:
|
|
356
|
-
updateHistoryItem(historyItem, {
|
|
357
|
-
state: REQUEST_STATE.error
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
case 15:
|
|
361
|
-
_context3.next = 32;
|
|
362
|
-
break;
|
|
363
|
-
|
|
364
|
-
case 17:
|
|
365
|
-
if (!(historyItem.type === ARTICLE_TYPE.WHATS_NEW)) {
|
|
366
|
-
_context3.next = 32;
|
|
367
|
-
break;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
if (!onGetWhatsNewArticle) {
|
|
371
|
-
_context3.next = 31;
|
|
372
|
-
break;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
_context3.prev = 19;
|
|
376
|
-
_context3.next = 22;
|
|
377
|
-
return onGetWhatsNewArticle({
|
|
378
|
-
id: historyItem.id,
|
|
379
|
-
type: historyItem.type
|
|
380
|
-
});
|
|
381
|
-
|
|
382
|
-
case 22:
|
|
383
|
-
_article = _context3.sent;
|
|
384
|
-
updateHistoryItem(historyItem, {
|
|
385
|
-
state: REQUEST_STATE.done,
|
|
386
|
-
article: _article
|
|
387
|
-
});
|
|
388
|
-
_context3.next = 29;
|
|
389
|
-
break;
|
|
390
|
-
|
|
391
|
-
case 26:
|
|
392
|
-
_context3.prev = 26;
|
|
393
|
-
_context3.t1 = _context3["catch"](19);
|
|
394
|
-
updateHistoryItem(historyItem, {
|
|
395
|
-
state: REQUEST_STATE.error
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
case 29:
|
|
399
|
-
_context3.next = 32;
|
|
400
|
-
break;
|
|
401
|
-
|
|
402
|
-
case 31:
|
|
403
|
-
updateHistoryItem(historyItem, {
|
|
404
|
-
state: REQUEST_STATE.error
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
case 32:
|
|
360
|
+
case 3:
|
|
408
361
|
case "end":
|
|
409
|
-
return
|
|
362
|
+
return _context2.stop();
|
|
410
363
|
}
|
|
411
364
|
}
|
|
412
|
-
},
|
|
365
|
+
}, _callee2);
|
|
413
366
|
}));
|
|
414
367
|
|
|
415
|
-
return function (
|
|
416
|
-
return
|
|
368
|
+
return function (_x2) {
|
|
369
|
+
return _ref6.apply(this, arguments);
|
|
417
370
|
};
|
|
418
|
-
}(), [
|
|
419
|
-
var
|
|
420
|
-
|
|
421
|
-
return currentArticleItem;
|
|
422
|
-
}, []);
|
|
423
|
-
var getCurrentArticleItemData = useCallback(function () {
|
|
424
|
-
var _getCurrentArticle = getCurrentArticle(),
|
|
425
|
-
article = _getCurrentArticle.article,
|
|
426
|
-
type = _getCurrentArticle.type;
|
|
427
|
-
|
|
428
|
-
if (article) {
|
|
429
|
-
if (type === ARTICLE_TYPE.HELP_ARTICLE) {
|
|
430
|
-
var _ref5 = article,
|
|
431
|
-
body = _ref5.body,
|
|
432
|
-
relatedArticles = _ref5.relatedArticles,
|
|
433
|
-
articleItemData = _objectWithoutProperties(_ref5, ["body", "relatedArticles"]);
|
|
434
|
-
|
|
435
|
-
var currentArticleSlimData = articleItemData;
|
|
436
|
-
return currentArticleSlimData;
|
|
437
|
-
} else if (type === ARTICLE_TYPE.WHATS_NEW) {
|
|
438
|
-
var _ref6 = article,
|
|
439
|
-
description = _ref6.description,
|
|
440
|
-
whatsNewArticleItemData = _objectWithoutProperties(_ref6, ["description"]);
|
|
441
|
-
|
|
442
|
-
var currentWhatsNewArticleSlimData = whatsNewArticleItemData;
|
|
443
|
-
return currentWhatsNewArticleSlimData;
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
}, [getCurrentArticle]);
|
|
447
|
-
var isOverlayVisible = useCallback(function () {
|
|
448
|
-
return view === VIEW.ARTICLE || view === VIEW.SEARCH || view === VIEW.WHATS_NEW || view === VIEW.WHATS_NEW_ARTICLE;
|
|
449
|
-
}, [view]);
|
|
450
|
-
var canNavigateBack = useCallback(function () {
|
|
451
|
-
/**
|
|
452
|
-
* - If default content isn't defined and the history only has one article,
|
|
453
|
-
* we should not display the back button
|
|
454
|
-
* - If the prop.article.setArticleId is not defined, we should also hide the back
|
|
455
|
-
* button because we are not able to navigate though the history without it
|
|
456
|
-
*/
|
|
457
|
-
if (tempHistory.current.length === 1 && !isDefaultContentDefined() || view === VIEW.WHATS_NEW && !isDefaultContentDefined()) {
|
|
458
|
-
return false;
|
|
459
|
-
}
|
|
460
|
-
/**
|
|
461
|
-
* if an overlay is visible return true to display the back buton
|
|
462
|
-
*/
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
return isOverlayVisible();
|
|
466
|
-
}, [isDefaultContentDefined, isOverlayVisible, view]);
|
|
467
|
-
var navigateBack = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
468
|
-
var newHistoryValue, lastHistoryItem;
|
|
469
|
-
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
371
|
+
}(), []);
|
|
372
|
+
var navigateBack = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
373
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
470
374
|
while (1) {
|
|
471
|
-
switch (
|
|
375
|
+
switch (_context3.prev = _context3.next) {
|
|
472
376
|
case 0:
|
|
473
|
-
if (
|
|
474
|
-
|
|
377
|
+
if (!(currentView === VIEW.SEARCH && onSearch)) {
|
|
378
|
+
_context3.next = 8;
|
|
475
379
|
break;
|
|
476
380
|
}
|
|
477
381
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
case 2:
|
|
481
|
-
if (!(view === VIEW.SEARCH && onSearch)) {
|
|
482
|
-
_context4.next = 5;
|
|
382
|
+
if (!(searchValue !== '')) {
|
|
383
|
+
_context3.next = 6;
|
|
483
384
|
break;
|
|
484
385
|
}
|
|
485
386
|
|
|
486
387
|
onSearch('');
|
|
487
|
-
return
|
|
388
|
+
return _context3.abrupt("return");
|
|
488
389
|
|
|
489
|
-
case
|
|
390
|
+
case 6:
|
|
391
|
+
dispatchNavigationAction({
|
|
392
|
+
type: 'updateView',
|
|
393
|
+
payload: currentArticleId.type
|
|
394
|
+
});
|
|
395
|
+
return _context3.abrupt("return");
|
|
396
|
+
|
|
397
|
+
case 8:
|
|
490
398
|
// if the history is not empty and ...
|
|
491
|
-
if (
|
|
399
|
+
if (currentHistory.length > 0) {
|
|
492
400
|
// the history has more than one article, navigate back through the history
|
|
493
|
-
if (
|
|
401
|
+
if (currentHistory.length > 1) {
|
|
494
402
|
// Remove last element
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
historySetter && historySetter(tempHistory.current); // If the state of the current article (last article in the history)
|
|
501
|
-
// is 'reload', fetch the article
|
|
502
|
-
|
|
503
|
-
lastHistoryItem = getCurrentArticle();
|
|
504
|
-
|
|
505
|
-
if (lastHistoryItem.state === REQUEST_STATE.reload) {
|
|
506
|
-
// fetch article data for the new history Item
|
|
507
|
-
fetchArticleData(lastHistoryItem);
|
|
508
|
-
}
|
|
509
|
-
/**
|
|
510
|
-
* If the state of the current article (last article in the history)
|
|
511
|
-
* is NOT 'reload', it means the article is already loaded, is loading or
|
|
512
|
-
* it had an error (which is handled and we display an error messages with
|
|
513
|
-
* a "try again" button). So we just need to set the host article ID === to the
|
|
514
|
-
* current article ID using the "articleIdSetter" prop function
|
|
515
|
-
*/
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
if (lastHistoryItem) {
|
|
519
|
-
articleIdSetter({
|
|
520
|
-
id: lastHistoryItem.id,
|
|
521
|
-
type: lastHistoryItem.type
|
|
522
|
-
});
|
|
523
|
-
}
|
|
524
|
-
} else if (tempHistory.current.length === 1) {
|
|
403
|
+
dispatchNavigationAction({
|
|
404
|
+
type: 'removeLastHistoryItem'
|
|
405
|
+
});
|
|
406
|
+
} else if (currentHistory.length === 1) {
|
|
525
407
|
// but if the history only has one item, clear the history
|
|
526
|
-
|
|
408
|
+
dispatchNavigationAction({
|
|
409
|
+
type: 'removeAllHistoryItems'
|
|
410
|
+
});
|
|
527
411
|
}
|
|
528
412
|
}
|
|
529
413
|
|
|
530
|
-
case
|
|
414
|
+
case 9:
|
|
531
415
|
case "end":
|
|
532
|
-
return
|
|
416
|
+
return _context3.stop();
|
|
533
417
|
}
|
|
534
418
|
}
|
|
535
|
-
},
|
|
536
|
-
})), [
|
|
419
|
+
}, _callee3);
|
|
420
|
+
})), [currentView, onSearch, currentHistory.length, searchValue, currentArticleId.type]);
|
|
537
421
|
var onClose = useCallback(function (event, analyticsEvent) {
|
|
538
422
|
if (onCloseButtonClick) {
|
|
539
|
-
|
|
423
|
+
dispatchNavigationAction({
|
|
424
|
+
type: 'removeAllHistoryItems'
|
|
425
|
+
});
|
|
540
426
|
onCloseButtonClick(event, analyticsEvent);
|
|
541
427
|
}
|
|
542
|
-
}, [
|
|
428
|
+
}, [onCloseButtonClick]);
|
|
543
429
|
useEffect(function () {
|
|
544
|
-
if (
|
|
545
|
-
|
|
430
|
+
if (isSearchResultVisible) {
|
|
431
|
+
dispatchNavigationAction({
|
|
432
|
+
type: 'updateView',
|
|
433
|
+
payload: VIEW.SEARCH
|
|
434
|
+
});
|
|
546
435
|
}
|
|
436
|
+
}, [isSearchResultVisible]);
|
|
437
|
+
useEffect(function () {
|
|
438
|
+
var simpleHistory = getSimpleHistory(currentHistory);
|
|
439
|
+
historySetter && historySetter(simpleHistory);
|
|
440
|
+
}, [historySetter, currentHistory]);
|
|
441
|
+
useEffect(function () {
|
|
547
442
|
/**
|
|
548
|
-
* If the
|
|
549
|
-
*
|
|
550
|
-
*
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
443
|
+
* If the propsArticleId.id (host articleId) is different from currentArticleId.id (internal articleId)
|
|
444
|
+
* it means the host updated propsArticleId and we need to use this new value to load a new article.
|
|
445
|
+
* */
|
|
446
|
+
if ((propsArticleId === null || propsArticleId === void 0 ? void 0 : propsArticleId.id) !== currentArticleId.id || (propsArticleId === null || propsArticleId === void 0 ? void 0 : propsArticleId.type) !== currentArticleId.type) {
|
|
447
|
+
dispatchNavigationAction({
|
|
448
|
+
type: 'newArticle',
|
|
449
|
+
payload: propsArticleId
|
|
450
|
+
});
|
|
451
|
+
} else {
|
|
452
|
+
/**
|
|
453
|
+
* If the propsArticleId.id (host articleId) is equal to currentArticleId.id (internal articleId)
|
|
454
|
+
* and the id from the last history item is different from currentArticleId.id, it means the history
|
|
455
|
+
* changed and we need to update the host articleId (propsArticleId) using 'articleIdSetter' and the local
|
|
456
|
+
* history using the dispatchNavigationAction reducer
|
|
457
|
+
* */
|
|
458
|
+
var lastHistoryItem = currentHistory.length > 0 ? _getCurrentArticle2(currentHistory) : getNewHistoryItem('', ARTICLE_TYPE.HELP_ARTICLE);
|
|
459
|
+
|
|
460
|
+
if (articleIdSetter && lastHistoryItem && (currentArticleId.id !== lastHistoryItem.id || currentArticleId.type !== lastHistoryItem.type)) {
|
|
461
|
+
dispatchNavigationAction({
|
|
462
|
+
type: 'updateArticleId',
|
|
463
|
+
payload: {
|
|
464
|
+
id: lastHistoryItem.id,
|
|
465
|
+
type: lastHistoryItem.type
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
articleIdSetter({
|
|
469
|
+
id: lastHistoryItem.id,
|
|
470
|
+
type: lastHistoryItem.type
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}, [currentArticleId, propsArticleId, currentHistory, articleIdSetter]);
|
|
475
|
+
useEffect(function () {
|
|
476
|
+
var requestNewArticle = /*#__PURE__*/function () {
|
|
477
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(historyItem) {
|
|
478
|
+
var historyItemUpdate;
|
|
479
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
480
|
+
while (1) {
|
|
481
|
+
switch (_context4.prev = _context4.next) {
|
|
482
|
+
case 0:
|
|
483
|
+
_context4.next = 2;
|
|
484
|
+
return fetchArticleData(historyItem);
|
|
485
|
+
|
|
486
|
+
case 2:
|
|
487
|
+
historyItemUpdate = _context4.sent;
|
|
488
|
+
dispatchNavigationAction({
|
|
489
|
+
type: 'updateHistoryItem',
|
|
490
|
+
payload: historyItemUpdate
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
case 4:
|
|
494
|
+
case "end":
|
|
495
|
+
return _context4.stop();
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
}, _callee4);
|
|
499
|
+
}));
|
|
565
500
|
|
|
566
|
-
|
|
567
|
-
|
|
501
|
+
return function requestNewArticle(_x3) {
|
|
502
|
+
return _ref8.apply(this, arguments);
|
|
503
|
+
};
|
|
504
|
+
}();
|
|
505
|
+
/**
|
|
506
|
+
* If the last history item state is "loading" or "reload", we need to request the article (fetch article from API)
|
|
507
|
+
*/
|
|
568
508
|
|
|
569
|
-
fetchArticleData(newHistoryItem);
|
|
570
|
-
} else {
|
|
571
|
-
// articleId is undefined only during the first execution of this effect
|
|
572
|
-
if (articleId === undefined) {
|
|
573
|
-
var _lastHistoryItem = getCurrentArticle();
|
|
574
509
|
|
|
575
|
-
|
|
576
|
-
articleIdSetter({
|
|
577
|
-
id: _lastHistoryItem.id,
|
|
578
|
-
type: _lastHistoryItem.type
|
|
579
|
-
}); // fetch article data for the new history Item
|
|
510
|
+
var lastHistoryItem = _getCurrentArticle2(currentHistory);
|
|
580
511
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
} else {
|
|
584
|
-
// If article ID is empty clear the history
|
|
585
|
-
if (!getCurrentArticle()) {
|
|
586
|
-
clearHistory();
|
|
587
|
-
}
|
|
588
|
-
}
|
|
512
|
+
if ((lastHistoryItem === null || lastHistoryItem === void 0 ? void 0 : lastHistoryItem.state) === REQUEST_STATE.loading || (lastHistoryItem === null || lastHistoryItem === void 0 ? void 0 : lastHistoryItem.state) === REQUEST_STATE.reload) {
|
|
513
|
+
requestNewArticle(lastHistoryItem);
|
|
589
514
|
}
|
|
590
|
-
}, [
|
|
591
|
-
/**
|
|
592
|
-
* VIEW effect
|
|
593
|
-
* Set the view value based on the values of articleId
|
|
594
|
-
*/
|
|
595
|
-
|
|
596
|
-
useEffect(function () {
|
|
597
|
-
updateView();
|
|
598
|
-
}, [articleId, updateView]);
|
|
515
|
+
}, [currentArticleId, currentHistory, fetchArticleData]);
|
|
599
516
|
return /*#__PURE__*/React.createElement(CtxProvider, {
|
|
600
517
|
value: {
|
|
601
|
-
view:
|
|
602
|
-
articleId:
|
|
518
|
+
view: currentView,
|
|
519
|
+
articleId: currentArticleId,
|
|
603
520
|
setArticleId: articleIdSetter,
|
|
604
|
-
history:
|
|
605
|
-
getCurrentArticle: getCurrentArticle
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
521
|
+
history: currentHistory,
|
|
522
|
+
getCurrentArticle: function getCurrentArticle() {
|
|
523
|
+
return _getCurrentArticle2(currentHistory);
|
|
524
|
+
},
|
|
525
|
+
getCurrentArticleItemData: function getCurrentArticleItemData() {
|
|
526
|
+
return getCurrentArticleItemSlim(currentHistory);
|
|
527
|
+
},
|
|
528
|
+
reloadHelpArticle: onGetHelpArticle && reloadArticle,
|
|
529
|
+
reloadWhatsNewArticle: onGetWhatsNewArticle && reloadArticle,
|
|
609
530
|
canNavigateBack: canNavigateBack,
|
|
610
531
|
navigateBack: navigateBack,
|
|
611
532
|
isOverlayVisible: isOverlayVisible,
|