-
Notifications
You must be signed in to change notification settings - Fork 81
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
V2 translate #6569
Merged
Merged
V2 translate #6569
Changes from 167 commits
Commits
Show all changes
171 commits
Select commit
Hold shift + click to select a range
4f1f348
translations atom
Zasa-san 1402b90
migrate Translate WIP
Zasa-san d8dbc10
Merge branch 'development' into v2-translate
Zasa-san 6ee267f
Merge branch 'development' into v2-translate
Zasa-san 6ca6e91
handle inline edit mode
Zasa-san 97b6381
stop event
Zasa-san b88ad18
Merge branch 'development' into v2-translate
Zasa-san 07a6f03
Merge branch 'development' into v2-translate
Zasa-san 77c9882
Merge branch 'development' into v2-translate
Zasa-san cbb3310
Merge branch 'development' into v2-translate
Zasa-san d261f87
adds update translations endpoint
mfacar 4987ccc
wip modal form
Zasa-san c22f8e4
get translations V2 WIP
mfacar 900e765
Merge branch 'development' of https://github.com/huridocs/uwazi into …
mfacar fe426e7
Merge branch 'development' into v2-translate
Zasa-san 2530799
Merge branch 'development' into v2-translate
Zasa-san 6057563
Merge branch 'development' of https://github.com/huridocs/uwazi into …
Zasa-san 44bc9b1
Merge branch 'development' into v2-translate
Zasa-san d9f71d8
Merge branch 'development' of https://github.com/huridocs/uwazi into …
Zasa-san c7a07d0
Merge branch 'development' of https://github.com/huridocs/uwazi into …
Zasa-san 011be44
Merge branch 'development' of https://github.com/huridocs/uwazi into …
Zasa-san 4a3bb7b
Merge branch 'development' of https://github.com/huridocs/uwazi into …
Zasa-san e55a018
Merge branch 'development' into v2-translate
Zasa-san f69ee77
Merge branch 'development' into v2-translate
Zasa-san 0b4ca31
Merge branch 'development' into v2-translate
Zasa-san ea9094c
Merge branch 'development' into v2-translate
Zasa-san 166a6fc
Merge branch 'development' into v2-translate
Zasa-san 9978be6
Merge branch 'development' into v2-translate
Zasa-san 1f43323
Merge branch 'development' into v2-translate
Zasa-san 2262919
Merge branch 'development' into v2-translate
Zasa-san 661ba10
Merge branch 'development' into v2-translate
Zasa-san 3efa166
Merge branch 'development' into v2-translate
Zasa-san 9f5a9f2
Merge branch 'development' into v2-translate
Zasa-san d64fe0d
Merge branch 'development' into v2-translate
Zasa-san dc256a7
Merge branch 'development' into v2-translate
Zasa-san 60c2edf
Merge branch 'development' into v2-translate
Zasa-san 3d6d693
Merge branch 'development' into v2-translate
Zasa-san e5ee66b
Merge branch 'development' into v2-translate
Zasa-san 4a39595
Merge branch 'development' into v2-translate
Zasa-san daf1a87
Merge branch 'development' into v2-translate
Zasa-san 2fa92c2
Merge branch 'development' into v2-translate
Zasa-san 715737d
Merge branch 'development' into v2-translate
Zasa-san 24ce3c5
Merge branch 'development' into v2-translate
Zasa-san f484920
Merge branch 'development' into v2-translate
Zasa-san 7936bec
Merge branch 'development' into v2-translate
Zasa-san e17a671
Merge branch 'development' into v2-translate
Zasa-san 8d9a299
Merge branch 'development' into v2-translate
Zasa-san f78d994
Merge branch 'development' into v2-translate
Zasa-san 3c6dc0e
Merge branch 'development' into v2-translate
Zasa-san d0a84f9
Merge branch 'development' into v2-translate
Zasa-san 1d622fc
Merge branch 'development' into v2-translate
Zasa-san 06de907
Merge branch 'development' into v2-translate
Zasa-san 19039e6
Merge branch 'development' into v2-translate
Zasa-san d00e858
Merge branch 'development' into v2-translate
Zasa-san a61f64e
Merge branch 'development' into v2-translate
Zasa-san 121c699
Merge branch 'development' into v2-translate
Zasa-san 0e35d51
Merge branch 'development' into v2-translate
Zasa-san 8db958c
Merge branch 'development' into v2-translate
Zasa-san f794b1b
Merge branch 'development' into v2-translate
Zasa-san f787dc3
Merge branch 'development' into v2-translate
Zasa-san 4a92690
Merge branch 'development' into v2-translate
Zasa-san 45ca4bd
Merge branch 'development' into v2-translate
Zasa-san dc1a1cb
Translate component using translationsAtom and loading correct values…
konzz 007773a
Merge branch 'development' into v2-translate
Zasa-san ed947a9
test new endpoint
Zasa-san 91ff794
Merge branch 'development' of https://github.com/huridocs/uwazi into …
Zasa-san 83cf08f
Merge branch 'development' into v2-translate
Zasa-san 285b30b
correctly set form
Zasa-san 8878777
Merge branch 'development' of https://github.com/huridocs/uwazi into …
Zasa-san 73788b6
Merge branch 'development' into v2-translate
Zasa-san 35d6427
Merge branch 'development' into v2-translate
Zasa-san 5437171
context to post request
josh-huridocs 3b38af0
Merge branch 'development' of https://github.com/huridocs/uwazi into …
mfacar 549248b
Merge branch 'v2-translate' of https://github.com/huridocs/uwazi into…
mfacar be34a6c
update translate atom after update
mfacar ff0ed47
uses context by language
mfacar 35d01ec
Merge branch 'development' of https://github.com/huridocs/uwazi into …
mfacar 92b822e
look & feel + socket events
mfacar ca4d6c7
Merge branch 'development' of https://github.com/huridocs/uwazi into …
mfacar 55f2e39
ci fixes
mfacar 83d7dfe
migrate t and update cache reset strategy
Zasa-san 1d547ef
Merge branch 'development' of https://github.com/huridocs/uwazi into …
Zasa-san 496e55b
Merge branch 'development' into v2-translate
Zasa-san 2cab6e5
update affected files
josh-huridocs de42dcc
adjust zindex and use t function for texts inside
josh-huridocs ba8c3f0
Merge branch 'development' into v2-translate
Zasa-san 9702a33
migrate I18Nmenu
Zasa-san 663e3e1
remove icon dependency
Zasa-san 9a35deb
cleanup
Zasa-san 2d875d0
Merge branch 'development' into v2-translate
Zasa-san 82c6277
Merge branch 'development' into v2-translate
Zasa-san 30e2359
update import
Zasa-san cc35f60
Merge branch 'development' into v2-translate
Zasa-san 2e42e50
fix issue with dropdown
Zasa-san 7d03077
Merge branch 'development' of https://github.com/huridocs/uwazi into …
Zasa-san 99e8601
update t function and move to v2 folder
Zasa-san 4c07fef
update imports
Zasa-san 9e154cb
remove unused afterEach
Zasa-san 28b81f0
stories cleanup
Zasa-san fe91373
remove redux provider from pdf unit test
Zasa-san 741a5d3
remove commented
Zasa-san 146cc9f
locale sensitve i18n link
Zasa-san 4c5c886
remove legacy store
Zasa-san 1a1cf49
use new i18n link for breadcrumbs
Zasa-san ed66ef0
reorganize files
Zasa-san 6aecd27
unit test snapshot update
Zasa-san cf62f59
update import
Zasa-san 852157e
avoid undefined when no classname and update snapshots
Zasa-san 1fe5b74
revert some unnecessary changes
Zasa-san ffd8908
do not return component in notification
Zasa-san d7c7076
fix type + wip fix test
Zasa-san 0a340cd
fix export
Zasa-san d4a5c67
fix multiple unit test by updating selectors, stores or mocking trans…
Zasa-san b43dcc8
more fixes
Zasa-san bf688c3
revert removal of redux translations
Zasa-san 90d058c
Merge branch 'development' of https://github.com/huridocs/uwazi into …
mfacar 1185c4b
fix test and eslint errors
mfacar beddf35
Merge branch 'development' into v2-translate
mfacar d260d35
update snapshot
Zasa-san 547b1cf
update selectors and e2e
Zasa-san fdf53bf
more specific selector
Zasa-san 0a66d83
wait for modal
Zasa-san 0545a47
Merge branch 'development' into v2-translate
Zasa-san 638e4b2
attempt to stabilize
Zasa-san cbcce05
Merge branch 'development' into v2-translate
Zasa-san e2dce27
I18NMenu test update wip
Zasa-san e8360af
use actual store for test
Zasa-san c53f719
Merge branch 'development' into v2-translate
Zasa-san ecd161a
use real events
Zasa-san 2b4ad78
close modal after a11y check
Zasa-san a696a88
Merge branch 'development' into v2-translate
Zasa-san 5c58b1d
more attempts at fixing e2e
Zasa-san 29a8de3
Merge branch 'v2-translate' of https://github.com/huridocs/uwazi into…
Zasa-san 9464aa1
more explicit steps
Zasa-san 575293a
continued attempt at fixing test
Zasa-san 1b9a199
install function handles modal closing
Zasa-san 49bb3c7
more specific install selector
Zasa-san 49f14da
restore workflow file
Zasa-san 46e62ab
account for new languages in socket emit
Zasa-san d9122af
wip update api
Zasa-san 74b1fa1
set translation modal's zindex to 10000
josh-huridocs 5ec6935
propagation of thesaurus translations
mfacar 0ce17b9
Merge branch 'v2-translate' of https://github.com/huridocs/uwazi into…
mfacar 5187529
socket events test update
Zasa-san 86db47e
update translations on language delete
Zasa-san 9592d29
udpate how the test updates component
Zasa-san 42362e5
translateModal test wip
Zasa-san ee96cef
test modal closes properly
Zasa-san e09c85e
update submit test
Zasa-san cb403f7
Merge branch 'development' into v2-translate
Zasa-san 1450ff2
update response type
Zasa-san 445209f
validate form and notify
Zasa-san 2bff8dd
fix lint error
Zasa-san 5954271
Merge branch 'development' of https://github.com/huridocs/uwazi into …
Zasa-san 4714ab6
stabilze e2e
Zasa-san 0ba2330
disable modal elements while saving
Zasa-san 50a06fa
update test description
Zasa-san 1a94955
update snapshot
Zasa-san 5d7a4ff
more attempts at e2e stabiliation
Zasa-san 1a1b77d
Merge branch 'development' into v2-translate
Zasa-san 8d069c5
Merge branch 'development' into v2-translate
Zasa-san d83f0ae
cleanup
Zasa-san 4745e06
Merge branch 'v2-translate' of https://github.com/huridocs/uwazi into…
Zasa-san 5edc9a0
Merge branch 'development' into v2-translate
Zasa-san c343363
Merge branch 'development' into v2-translate
Zasa-san f2d801f
Merge branch 'development' into v2-translate
Zasa-san 91d2c83
Merge branch 'development' into v2-translate
Zasa-san 14f4b61
Merge branch 'development' into v2-translate
daneryl 2f96da5
fix route duplication
Zasa-san 66e5c63
Merge branch 'v2-translate' of https://github.com/huridocs/uwazi into…
Zasa-san 5f0ad4d
Merge branch 'development' into v2-translate
Zasa-san 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Application, Request } from 'express'; | ||
import { needsAuthorization } from 'api/auth'; | ||
import { validation } from 'api/utils'; | ||
import translations from 'api/i18n'; | ||
import { getTranslationsEntriesV2 } from 'api/i18n/v2_support'; | ||
|
||
export default (app: Application) => { | ||
app.get('/api/translationsV2', async (_req: Request, res) => { | ||
const translationsV2 = await getTranslationsEntriesV2(); | ||
const translationList = await translationsV2.all(); | ||
res.json(translationList); | ||
}); | ||
|
||
app.post( | ||
'/api/translationsV2', | ||
needsAuthorization(), | ||
validation.validateRequest({ | ||
type: 'object', | ||
properties: { | ||
body: { | ||
type: 'array', | ||
items: { | ||
type: 'object', | ||
properties: { | ||
_id: { type: 'string' }, | ||
language: { type: 'string' }, | ||
key: { type: 'string' }, | ||
value: { type: 'string' }, | ||
context: { | ||
type: 'object', | ||
properties: { | ||
id: { type: 'string' }, | ||
label: { type: 'string' }, | ||
type: { type: 'string' }, | ||
}, | ||
required: ['id', 'label', 'type'], | ||
}, | ||
}, | ||
required: ['language', 'key', 'value', 'context'], | ||
}, | ||
}, | ||
}, | ||
required: ['body'], | ||
}), | ||
async (req, res) => { | ||
await translations.v2StructureSave(req.body); | ||
req.sockets.emitToCurrentTenant('translationKeysChange', req.body); | ||
res.status(200); | ||
res.json({ success: true }); | ||
} | ||
); | ||
}; |
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,100 @@ | ||
import 'isomorphic-fetch'; | ||
import request from 'supertest'; | ||
|
||
import { TranslationDBO } from 'api/i18n.v2/schemas/TranslationDBO'; | ||
import i18nRoutes from 'api/i18n/routes'; | ||
import { getFixturesFactory } from 'api/utils/fixturesFactory'; | ||
import { testingEnvironment } from 'api/utils/testingEnvironment'; | ||
import { TestEmitSources, iosocket, setUpApp } from 'api/utils/testingRoutes'; | ||
import { UserRole } from 'shared/types/userSchema'; | ||
|
||
describe('i18n translations V2 routes', () => { | ||
const createTranslationDBO = getFixturesFactory().v2.database.translationDBO; | ||
const app = setUpApp(i18nRoutes, (req, _res, next) => { | ||
req.user = { | ||
username: 'admin', | ||
role: UserRole.ADMIN, | ||
email: '[email protected]', | ||
}; | ||
// @ts-ignore | ||
req.file = { path: 'filder/filename.ext' }; | ||
next(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
const translationsV2: TranslationDBO[] = [ | ||
createTranslationDBO('Search', 'Buscar', 'es', { | ||
id: 'System', | ||
type: 'Entity', | ||
label: 'User Interface', | ||
}), | ||
createTranslationDBO('Search', 'Search', 'en', { | ||
id: 'System', | ||
type: 'Uwazi UI', | ||
label: 'User Interface', | ||
}), | ||
]; | ||
await testingEnvironment.setUp( | ||
{ | ||
settings: [ | ||
{ | ||
languages: [ | ||
{ key: 'en', label: 'English', default: true }, | ||
{ key: 'es', label: 'Spanish', default: false }, | ||
], | ||
}, | ||
], | ||
translationsV2, | ||
}, | ||
'index_i18n_v2_routes' | ||
); | ||
}); | ||
|
||
afterEach(() => { | ||
iosocket.emit.mockReset(); | ||
}); | ||
|
||
afterAll(async () => { | ||
await testingEnvironment.tearDown(); | ||
}); | ||
|
||
describe('api/translationsV2', () => { | ||
it('should update the translations and emit translationKeysChange event', async () => { | ||
const response = await request(app) | ||
.post('/api/translationsV2') | ||
.send([ | ||
{ | ||
language: 'es', | ||
key: 'Search', | ||
value: 'Búsqueda', | ||
context: { | ||
id: 'System', | ||
label: 'User Interface', | ||
type: 'Uwazi UI', | ||
}, | ||
}, | ||
]); | ||
expect(response.status).toEqual(200); | ||
expect(iosocket.emit).toHaveBeenCalledWith( | ||
'translationKeysChange', | ||
TestEmitSources.currentTenant, | ||
[ | ||
{ | ||
context: { id: 'System', label: 'User Interface', type: 'Uwazi UI' }, | ||
key: 'Search', | ||
language: 'es', | ||
value: 'Búsqueda', | ||
}, | ||
] | ||
); | ||
}); | ||
|
||
it('should handle invalid POST request payload', async () => { | ||
const response = await request(app).post('/api/translationsV2').send({ invalidKey: 'value' }); // Invalid payload | ||
expect(response.status).toBe(400); | ||
expect(response.body).toEqual( | ||
expect.objectContaining({ prettyMessage: 'validation failed' }) | ||
); | ||
}); | ||
}); | ||
}); |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Are this changes still needed ? looks like i18n.v2 has the same endpoints defined ?
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.
🤦♂️ An oversight. Fixed!