-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/i18n/refactoring and tests #230
Merged
Merged
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
3662bea
feat: basic i18n implementation at server side
StyleT 1218f0a
chore: unit tests fix
StyleT 6c637bf
chore: tests added
StyleT b54c36e
chore: args order fix
StyleT b31216c
Merge pull request #200 from namecheap/feature/i18n/basic_ssr_impleme…
StyleT 1a45fb4
Merge branch 'master' into feature/i18n/master
StyleT eebec42
Merge branch 'master' into feature/i18n/master
StyleT 86a84c9
initial client side intl implementation
StyleT 16c0b23
client side intl implementation vol 2
StyleT b53b8ce
Fetching intl settings from config
StyleT 65477b5
Bugfix & ability to disable i18n feature
StyleT ba42365
globalSpinner now is enabled by default & is synchronized with langua…
StyleT 51c4a07
Removed location patch
StyleT 8b43607
added x-request-host headers that will be sent to fragments
StyleT 924b27b
typo fix
StyleT 6a49945
tests fix for ClientRouter
StyleT ec07550
Adjustments to work with Localization from ILC side
StyleT da5105f
Better error handling during route change
StyleT 2e18c02
fix: fixed performance tracking for special routes
StyleT 838a83f
Fixed work with query params & hash during locale change
StyleT 3c79ea9
Merge branch 'master' into feature/i18n/master
StyleT 0ed629d
Merge branch 'feature/i18n/master' into feature/i18n/client_side_api
StyleT d9a5049
Added ability to correctly unmount apps
StyleT e0b6741
Removed unnecessary use of systemSdk
StyleT df191ad
fixed issue with infinite loop during locale change error
StyleT d6f4ef7
feat: currency can be changed together with locale
StyleT 96e09bc
ilc-server-sdk -> ilc-sdk
StyleT 5027be5
Fixed props for navbar
StyleT 50a7278
Updated config
StyleT 4f5e392
ilc-sdk update
StyleT d235fef
Code refactoring
StyleT 3292a4a
iterablePromise fn moved to utils
StyleT 29ee5e8
Code refactoring
StyleT 0b325b8
tests fix
StyleT 90f62be
client side tests fix
StyleT 3e8133f
code refactoring
StyleT 17fc8f5
chore: improved unit tests readability
StyleT fd40f1f
Merge pull request #215 from namecheap/feature/i18n/client_side_api
StyleT b025a12
Merge branch 'master' into feature/i18n/master
StyleT 4ce2b1e
feat: global spinner config moved to registry (#218)
StyleT a63b7bb
feat: I18n settings were moved to Registry (#219)
StyleT 69c252c
Merge branch 'master' into feature/i18n/master
StyleT 303513b
fix: fixed handling of the localized A tags (#224)
StyleT 8c23c9f
chore: better ilc-sdk import
StyleT 690586a
Merge branch 'master' into feature/i18n/master
StyleT 8fe0972
feat: added ability to export "mainSpa" callback as default one
StyleT 4a16717
Merge pull request #229 from namecheap/feature/i18n/default_mainSpa_c…
StyleT 384b9e7
chore: singleSpa.registerApplication() refactor
StyleT c55b39e
chore: test code removal
StyleT 5dc518e
feat: added corect currency handling
StyleT b31fa3f
feat: added i18n.routingStrategy settings key
StyleT f82a80d
chore: registry tests fix
StyleT a755871
chore: code refactoring
StyleT 0d05a07
chore: better file naming
StyleT 59cae79
feat: Better interface for interaction with apps during language change
StyleT 04b1513
ilc-sdk bump
StyleT bcea8be
chore: fixed TODO
StyleT 0fd15a3
feat: added special fn for appId to appName/slotName conversion
StyleT 747c1af
feat: improved error handling for i18n config change event
StyleT 615341f
chore: refactoring & tests fix
StyleT b4c4f64
chore: unused code removal
StyleT 7954c16
chore: centralized appId to name/slotName conversion
StyleT 0addbae
chore: ilc-sdk version bump
StyleT 38a9bbe
chore: code refactoring
StyleT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: improved error handling for i18n config change event
- Loading branch information
commit 747c1af88d313f44a543ecd40b011f159303e285
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* Allows to dispatch an event reaction on which can be synchronized between all listening parties. | ||
* Can be used to perform some change of the UI simultaneously across all concerned parties even if it requires | ||
* some resources to be loaded over the network. | ||
* | ||
* @param {string} eventName | ||
* @param {Object} eventDetail | ||
* @param {Function} errorHandler | ||
* @return {Promise<void>} - resolves when all parties finished event handling | ||
*/ | ||
export default function (eventName, eventDetail, errorHandler) { | ||
const handlers = []; | ||
const detail = Object.assign(eventDetail, { | ||
addHandler: v => handlers.push(v), | ||
}); | ||
|
||
//Here "parties" array will be filled with listeners | ||
window.dispatchEvent(new CustomEvent(eventName, {detail})); | ||
|
||
handlers.forEach(v => { | ||
v.errorHandler = (...args) => errorHandler(v.actorId, ...args); | ||
v.prepare = wrapWithPromise(v.prepare); | ||
v.execute = wrapWithPromise(v.execute); | ||
}); | ||
|
||
const preparationPromises = handlers.map(v => v.prepare(eventDetail)); | ||
|
||
return Promise.allSettled(preparationPromises).then(results => { | ||
for (let ii = 0; ii < results.length; ii++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why |
||
const row = results[ii]; | ||
|
||
if (row.status === 'rejected') { | ||
handlers[ii].errorHandler(row.reason); | ||
handlers.splice(ii, 1); | ||
results.splice(ii, 1); | ||
ii--; | ||
} | ||
} | ||
|
||
const executionPromises = handlers.map((v, i) => v.execute(eventDetail, results[i].value)); | ||
|
||
return Promise.allSettled(executionPromises); | ||
}).then(results => { | ||
results | ||
.map((v, i) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's better to use |
||
v.errorHandler = handlers[i].errorHandler; | ||
return v; | ||
}) | ||
.filter(v => v.status === 'rejected') | ||
.forEach(v => v.errorHandler(v.reason)); | ||
}); | ||
} | ||
|
||
function wrapWithPromise(callback) { | ||
return (...args) => new Promise((resolve, reject) => { | ||
try { | ||
resolve(callback.apply(null, args)); | ||
} catch (err) { | ||
reject(err); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not critical, but will be better to put
undefined
arguments as last argument or as optional inside object. and in this case we won't setundefiend
here.https://github.com/namecheap/ilc/pull/230/files#diff-318e72ee3c278cb96c1bb2130002e8a9bcdebd2042222be2a5284e589a1bb75eR204