8000 Replace redux polyglot 2 by ThieryMichel · Pull Request #2365 · Inist-CNRS/lodex · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Replace redux polyglot 2 #2365

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

Merged
merged 3 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 15 additions & 43 deletions cypress/e2e/phase_1/subresource.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ describe('Subresource Page', () => {
datasetImportPage.importDataset('dataset/subresources-data.json');
navigationPage.goToDisplay();

cy.get('.sidebar')
.contains('Subresources')
.click();
cy.get('.sidebar').contains('Subresources').click();
});

it('should allow to add a subresource', () => {
Expand All @@ -35,9 +33,7 @@ describe('Subresource Page', () => {
);
});

cy.get('.wizard')
.find('.btn-save')
.click();
cy.get('.wizard').find('.btn-save').click();

cy.get('.wizard', { timeout: 2000 }).should('not.exist');

Expand All @@ -56,9 +52,7 @@ describe('Subresource Page', () => {
subresourcePage.createSubresource();
subresourcePage.addField('name', 'myField');

cy.get('.sidebar')
.contains('a', 'Main resource')
.click();
cy.get('.sidebar').contains('a', 'Main resource').click();

cy.url().should('contain', '/display/document/main');
cy.wait(200); // fix unexpected refresh after page change
Expand All @@ -76,21 +70,15 @@ describe('Subresource Page', () => {

datasetImportPage.fillTabDisplayFormat('link');

cy.get('.wizard')
.find('.btn-save')
.click();
cy.get('.wizard').find('.btn-save').click();

cy.get('.wizard').should('not.exist');

datasetImportPage.addColumn('name', { syndication: 1 });

cy.get('.sidebar')
.contains('Search & Facet')
.click();
cy.get('.sidebar').conta F438 ins('Search & Facet').click();
cy.get('[data-testid="autocomplete_search_in_fields"]').click();
cy.get('[role="listbox"]')
.contains('Resource field')
.click();
cy.get('[role="listbox"]').contains('Resource field').click();

navigationPage.publishAndGoToPublishedData();

Expand All @@ -107,9 +95,7 @@ describe('Subresource Page', () => {
cy.contains('button', 'Published data').click();
cy.contains('.publication-excerpt-column', 'Name').should('exist');

cy.get('.sidebar')
.contains('a', 'Main resource')
.click();
cy.get('.sidebar').contains('a', 'Main resource').click();

cy.url().should('contain', '/display/document/main');
cy.wait(200); // fix unexpected refresh after page change
Expand All @@ -119,21 +105,15 @@ describe('Subresource Page', () => {
cy.contains('New field').click();
cy.get('.wizard', { timeout: 10000 }).should('be.visible');

cy.get('input[name="label"]')
.clear()
.type('Animal crossing');
cy.get('input[name="label"]').clear().type('Animal crossing');

cy.contains('From Subresource').click();

cy.get('[data-testid="autocomplete-subresource-label"]').click();

cy.get('[role="listbox"]')
.contains('name')
.click();
cy.get('[role="listbox"]').contains('name').click();

cy.get('.wizard')
.find('.btn-save')
.click();
cy.get('.wizard').find('.btn-save').click();

cy.get('.wizard').should('not.exist');

Expand All @@ -145,7 +125,7 @@ describe('Subresource Page', () => {
.within(() => {
cy.get('span[data-field-name]')
.invoke('attr', 'data-field-name')
.then(fieldNameAttrValue => {
.then((fieldNameAttrValue) => {
fieldName = fieldNameAttrValue;
});
});
Expand All @@ -156,9 +136,7 @@ describe('Subresource Page', () => {
cy.contains('New field').click();
cy.get('.wizard', { timeout: 10000 }).should('be.visible');

cy.get('input[name="label"]')
.clear()
.type('Animal link');
cy.get('input[name="label"]').clear().type('Animal link');

cy.contains('From Subresource').click();

Expand All @@ -176,21 +154,15 @@ describe('Subresource Page', () => {
cy.get('#format-edit-dialog')
.contains('confirm', { matchCase: false })
.click();
cy.get('.wizard')
.find('.btn-save')
.click();
cy.get('.wizard').find('.btn-save').click();

cy.get('.wizard').should('not.exist');

datasetImportPage.addColumn('name', { syndication: 1 });

cy.get('.sidebar')
.contains('Search & Facet')
.click();
cy.get('.sidebar').contains('Search & Facet').click();
cy.get('[data-testid="autocomplete_search_in_fields"]').click();
cy.get('[role="listbox"]')
.contains('Animal link')
.click();
cy.get('[role="listbox"]').contains('Animal link').click();

navigationPage.publishAndGoToPublishedData();

Expand Down
28 changes: 0 additions & 28 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@
"redux-form": "^8.3.10",
"redux-localstorage": "^1.0.0-rc5",
"redux-localstorage-filter": "^0.1.1",
"redux-polyglot": "^0.7.0",
"redux-saga": "^0.16.2",
"reselect": "^3.0.1",
"scheduler": "0.18.0",
Expand Down
4 changes: 1 addition & 3 deletions src/api/controller/api/enrichment.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
setEnrichmentJobId,
} from '../../services/enrichment/enrichment';
import { cancelJob, getActiveJob } from '../../workers/tools';
import { getLocale } from 'redux-polyglot/dist/selectors';
import { orderEnrichmentsByDependencies } from '../../services/orderEnrichmentsByDependencies';

export const setup = async (ctx, next) => {
Expand Down Expand Up @@ -43,9 +42,8 @@ export const postEnrichment = async (ctx) => {
// if code error is 11000, it's a duplicate key error
if (error.code === 11000) {
// send message due to browser locale
const locale = getLocale(ctx);
const errorMessage =
locale === 'fr'
ctx.cookies.get('frontend_lang') === 'fr_FR'
? 'Un enrichissement avec ce nom existe déjà'
: 'A enrichment with this name already exists';
ctx.body = { error: errorMessage };
Expand Down
2 changes: 1 addition & 1 deletion src/api/controller/front.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const getDefaultInitialState = (ctx, token, cookie, locale) => ({
configuredFieldName: null,
published: true,
},
polyglot: {
i18n: {
locale,
phrases: translations.getByLanguage(locale),
},
Expand Down
18 changes: 5 additions & 13 deletions src/app/js/admin/Admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,21 @@ import React from 'react';
import PropTypes from 'prop-types';
import { compose, lifecycle } from 'recompose';
import { connect } from 'react-redux';
import translate from 'redux-polyglot/translate';
import { Card } from '@mui/material';

/**
* @TODO: Remove this file
* THis file is useless now but we keep it to reproduce features
*/

import { polyglot as polyglotPropTypes } from '../propTypes';
import withInitialData from './withInitialData';
import { fromParsing, fromPublication, fromUpload } from './selectors';
import ParsingResult from './parsing/ParsingResult';
import PublicationPreview from './preview/publication/PublicationPreview';
import Upload from './upload/Upload';
import Loading from '../lib/components/Loading';
import { preLoadLoaders } from './loader/';
import { useTranslate } from '../i18n/I18NContext';

const styles = {
punchLine: {
Expand All @@ -27,15 +26,12 @@ const styles = {
},
};

export const AdminComponent = ({
loadingParsingResult,
canUploadFile,
p: polyglot,
}) => {
export const AdminComponent = ({ loadingParsingResult, canUploadFile }) => {
const { translate } = useTranslate();
if (loadingParsingResult) {
return (
<Loading className="admin">
{polyglot.t('loading_parsing_results')}
{translate('loading_parsing_results')}
</Loading>
);
}
Expand All @@ -48,9 +44,7 @@ export const AdminComponent = ({
<Card className="admin">
<ParsingResult />
<PublicationPreview />
<div style={styles.punchLine}>
{polyglot.t('publish-punchline')}
</div>
<div style={styles.punchLine}>{translate('publish-punchline')}</div>
</Card>
);
};
Expand All @@ -59,7 +53,6 @@ AdminComponent.propTypes = {
loadingParsingResult: PropTypes.bool.isRequired,
hasPublishedDataset: PropTypes.bool.isRequired,
canUploadFile: PropTypes.bool.isRequired,
p: polyglotPropTypes.isRequired,
};

const mapStateToProps = (state) => ({
Expand All @@ -82,5 +75,4 @@ export default compose(
this.props.preLoadLoaders();
},
}),
translate,
)(AdminComponent);
17 changes: 8 additions & 9 deletions src/app/js/admin/Appbar/CancelProcessDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,33 @@ import {
DialogContent,
DialogTitle,
} from '@mui/material';
import { polyglot as polyglotPropTypes } from '../../propTypes';
import translate from 'redux-polyglot/translate';
import CancelButton from '../../lib/components/CancelButton';
import { useTranslate } from '../../i18n/I18NContext';

const CancelProcessDialog = (props) => {
const { p: polyglot, isOpen, title, content, onConfirm, onCancel } = props;
const { isOpen, title, content, onConfirm, onCancel } = props;
const { translate } = useTranslate();
return (
<Dialog open={isOpen}>
<DialogTitle>{polyglot.t(title)}</DialogTitle>
<DialogContent>{polyglot.t(content)}</DialogContent>
<DialogTitle>{translate(title)}</DialogTitle>
<DialogContent>{translate(content)}</DialogContent>
<DialogActions>
<CancelButton >
{polyglot.t('Cancel')}
{translate('Cancel')}
</CancelButton>
<Button color="primary" variant="contained" >
{polyglot.t('Accept')}
{translate('Accept')}
</Button>
</DialogActions>
</Dialog>
);
};

CancelProcessDialog.propTypes = {
p: polyglotPropTypes.isRequired,
title: PropTypes.string.isRequired,
content: PropTypes.string.isRequired,
onConfirm: PropTypes.func.isRequired,
onCancel: PropTypes.func.isRequired,
isOpen: PropTypes.bool.isRequired,
};
export default translate(CancelProcessDialog);
export default CancelProcessDialog;
Loading
Loading
0