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