diff --git a/package.json b/package.json index 80a6cf45db..553e39e416 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "file-saver": "^2.0.5", "flux": "^4.0.1", "immutability-helper": "^3.1.1", - "immutable": "^4.0.0-rc.12", + "immutable": "^5.0.0", "jquery": "^3.7.1", "js-base64": "^3.6.1", "js-cookie": "^3.0.0", diff --git a/public/js/cat_source/es6/components/header/Header.js b/public/js/cat_source/es6/components/header/Header.js index b7a0335dd6..9df7facb74 100644 --- a/public/js/cat_source/es6/components/header/Header.js +++ b/public/js/cat_source/es6/components/header/Header.js @@ -7,7 +7,7 @@ import FilterProjects from './manage/FilterProjects' import {ActionMenu} from './ActionMenu' import {UserMenu} from './UserMenu' import {ComponentExtendInterface} from '../../utils/ComponentExtendInterface' -import Immutable from 'immutable' +import {fromJS} from 'immutable' import {TeamDropdown} from './TeamDropdown' export class HeaderInterface extends ComponentExtendInterface { @@ -57,7 +57,7 @@ const Header = ({ {showFilterProjects && (
- +
)} diff --git a/public/js/cat_source/es6/components/header/manage/FilterProjects.test.js b/public/js/cat_source/es6/components/header/manage/FilterProjects.test.js index 7341749747..28a2891825 100644 --- a/public/js/cat_source/es6/components/header/manage/FilterProjects.test.js +++ b/public/js/cat_source/es6/components/header/manage/FilterProjects.test.js @@ -1,7 +1,7 @@ import {render, screen, act} from '@testing-library/react' import userEvent from '@testing-library/user-event' import React from 'react' -import Immutable from 'immutable' +import {fromJS} from 'immutable' import {http, HttpResponse} from 'msw' import FilterProjects from './FilterProjects' @@ -50,7 +50,7 @@ const fakeFilterData = { const getFakeProperties = (fakeProperties) => { const {data} = fakeProperties - const team = Immutable.fromJS(data) + const team = fromJS(data) return { team, diff --git a/public/js/cat_source/es6/components/outsource/OutsourceVendor.js b/public/js/cat_source/es6/components/outsource/OutsourceVendor.js index 2e26daafbc..d7fad4b5af 100644 --- a/public/js/cat_source/es6/components/outsource/OutsourceVendor.js +++ b/public/js/cat_source/es6/components/outsource/OutsourceVendor.js @@ -1,5 +1,5 @@ import React from 'react' -import Immutable from 'immutable' +import {fromJS} from 'immutable' import Cookies from 'js-cookie' import {isUndefined} from 'lodash' import {isNull} from 'lodash/lang' @@ -109,7 +109,7 @@ class OutsourceVendor extends React.Component { } self.quoteResponse = quoteData.data[0] - let chunk = Immutable.fromJS(quoteData.data[0][0]) + let chunk = fromJS(quoteData.data[0][0]) self.url_ok = quoteData.return_url.url_ok self.url_ko = quoteData.return_url.url_ko diff --git a/public/js/cat_source/es6/components/projects/JobContainer.test.js b/public/js/cat_source/es6/components/projects/JobContainer.test.js index a6ca8c26aa..480339a9a8 100644 --- a/public/js/cat_source/es6/components/projects/JobContainer.test.js +++ b/public/js/cat_source/es6/components/projects/JobContainer.test.js @@ -2,7 +2,7 @@ import {render, screen, act, waitFor} from '@testing-library/react' import userEvent from '@testing-library/user-event' import '@testing-library/jest-dom' import React from 'react' -import Immutable from 'immutable' +import {fromJS} from 'immutable' import JobContainer from './JobContainer' import ProjectsStore from '../../stores/ProjectsStore' import ManageConstants from '../../constants/ManageConstants' @@ -849,7 +849,7 @@ const fakeProjectsData = { const getFakeProperties = (fakeProperties) => { const {data, props} = fakeProperties - const project = Immutable.fromJS(data) + const project = fromJS(data) const jobs = project.get('jobs') const job = jobs.first() diff --git a/public/js/cat_source/es6/components/projects/JobMenu.test.js b/public/js/cat_source/es6/components/projects/JobMenu.test.js index bb614b1322..7a706cae61 100644 --- a/public/js/cat_source/es6/components/projects/JobMenu.test.js +++ b/public/js/cat_source/es6/components/projects/JobMenu.test.js @@ -2,7 +2,7 @@ import {render, screen, waitFor} from '@testing-library/react' import userEvent from '@testing-library/user-event' import React from 'react' import JobMenu from './JobMenu' -import Immutable from 'immutable' +import {fromJS} from 'immutable' import {http, HttpResponse} from 'msw' import {mswServer} from '../../../../../mocks/mswServer' import ProjectsStore from '../../stores/ProjectsStore' @@ -100,7 +100,7 @@ const fakeProjectsData = { const getFakeProperties = (fakeProperties) => { const {data, props} = fakeProperties - const project = Immutable.fromJS(data) + const project = fromJS(data) const jobs = project.get('jobs') const job = jobs.first() diff --git a/public/js/cat_source/es6/components/projects/ProjectContainer.js b/public/js/cat_source/es6/components/projects/ProjectContainer.js index d05536e519..ca237a986c 100644 --- a/public/js/cat_source/es6/components/projects/ProjectContainer.js +++ b/public/js/cat_source/es6/components/projects/ProjectContainer.js @@ -8,11 +8,9 @@ import UserActions from '../../actions/UserActions' import ManageActions from '../../actions/ManageActions' import ProjectsStore from '../../stores/ProjectsStore' import {getLastProjectActivityLogAction} from '../../api/getLastProjectActivityLogAction' -import CommonUtils from '../../utils/commonUtils' import CatToolActions from '../../actions/CatToolActions' import ModalsActions from '../../actions/ModalsActions' import ConfirmMessageModal from '../modals/ConfirmMessageModal' -import Immutable from 'immutable' import UserStore from '../../stores/UserStore' import { DROPDOWN_MENU_ALIGN, diff --git a/public/js/cat_source/es6/components/projects/ProjectContainer.test.js b/public/js/cat_source/es6/components/projects/ProjectContainer.test.js index 9f050d3068..ddc30e6129 100644 --- a/public/js/cat_source/es6/components/projects/ProjectContainer.test.js +++ b/public/js/cat_source/es6/components/projects/ProjectContainer.test.js @@ -1,8 +1,8 @@ -import {render, screen, waitFor} from '@testing-library/react' +import {render, screen} from '@testing-library/react' import React from 'react' import {createRoot} from 'react-dom/client' import ProjectContainer from './ProjectContainer' -import Immutable from 'immutable' +import {fromJS} from 'immutable' import {http, HttpResponse} from 'msw' import {mswServer} from '../../../../../mocks/mswServer' @@ -349,9 +349,9 @@ const fakeProjectsData = { const getFakeProperties = (fakeProperties) => { const {data, dataTeam, dataTeams, props} = fakeProperties - const project = Immutable.fromJS(data) - const team = Immutable.fromJS(dataTeam) - const teams = Immutable.fromJS(dataTeams) + const project = fromJS(data) + const team = fromJS(dataTeam) + const teams = fromJS(dataTeams) return { project, diff --git a/public/js/cat_source/es6/components/projects/ProjectsContainer.js b/public/js/cat_source/es6/components/projects/ProjectsContainer.js index 65b3ffddf3..0fdd7972b9 100644 --- a/public/js/cat_source/es6/components/projects/ProjectsContainer.js +++ b/public/js/cat_source/es6/components/projects/ProjectsContainer.js @@ -6,12 +6,12 @@ import ManageConstants from '../../constants/ManageConstants' import ProjectsStore from '../../stores/ProjectsStore' import UserStore from '../../stores/UserStore' import ManageActions from '../../actions/ManageActions' -import Immutable from 'immutable' +import {fromJS} from 'immutable' class ProjectsContainer extends React.Component { constructor(props) { super(props) this.state = { - projects: Immutable.fromJS([]), + projects: fromJS([]), more_projects: false, reloading_projects: false, team: this.props.team, diff --git a/public/js/cat_source/es6/components/projects/ProjectsContainer.test.js b/public/js/cat_source/es6/components/projects/ProjectsContainer.test.js index 73333b92ad..6ed7dc6c62 100644 --- a/public/js/cat_source/es6/components/projects/ProjectsContainer.test.js +++ b/public/js/cat_source/es6/components/projects/ProjectsContainer.test.js @@ -1,6 +1,6 @@ import {render, screen, waitFor, act} from '@testing-library/react' import React from 'react' -import Immutable from 'immutable' +import {fromJS} from 'immutable' import {http, HttpResponse} from 'msw' import ProjectsContainer from './ProjectsContainer' @@ -8,7 +8,6 @@ import ManageActions from '../../actions/ManageActions' import {mswServer} from '../../../../../mocks/mswServer' import userMock from '../../../../../mocks/userMock' import {ApplicationWrapperContext} from '../common/ApplicationWrapper' -import ProjectContainer from './ProjectContainer' // create modal div const modalElement = document.createElement('div') @@ -615,9 +614,9 @@ const fakeProjectsData = { const getFakeProperties = (fakeProperties) => { const {data, dataTeam, dataTeams, props} = fakeProperties - const projects = Immutable.fromJS(data) - const team = Immutable.fromJS(dataTeam) - const teams = Immutable.fromJS(dataTeams) + const projects = fromJS(data) + const team = fromJS(dataTeam) + const teams = fromJS(dataTeams) return { projects, @@ -773,7 +772,7 @@ test('No projects found with team type general', () => { const {dataTeam} = fakeProjectsData.projects const dataTeamCopy = {...dataTeam, type: 'general'} - const team = Immutable.fromJS(dataTeamCopy) + const team = fromJS(dataTeamCopy) render() diff --git a/public/js/cat_source/es6/components/segments/Editarea.js b/public/js/cat_source/es6/components/segments/Editarea.js index ea66a61dd8..2ee468884d 100644 --- a/public/js/cat_source/es6/components/segments/Editarea.js +++ b/public/js/cat_source/es6/components/segments/Editarea.js @@ -1,5 +1,5 @@ import React, {createRef} from 'react' -import Immutable from 'immutable' +import {fromJS} from 'immutable' import { Modifier, Editor, @@ -380,9 +380,7 @@ class Editarea extends React.Component { const lexiqaChanged = prevLexiqaTarget && currentLexiqaTarget && - !Immutable.fromJS(prevLexiqa.target).equals( - Immutable.fromJS(lexiqa.target), - ) + !fromJS(prevLexiqa.target).equals(fromJS(lexiqa.target)) if ( //Condition to understand if the job has tm keys or if the check glossary request has been made (blacklist must take precedence over lexiqa) @@ -414,8 +412,8 @@ class Editarea extends React.Component { (!prevProps || !prevProps.segment.inSearch || //Before was not active (prevProps.segment.inSearch && - !Immutable.fromJS(prevProps.segment.searchParams).equals( - Immutable.fromJS(this.props.segment.searchParams), + !fromJS(prevProps.segment.searchParams).equals( + fromJS(this.props.segment.searchParams), )) || //Before was active but some params change (prevProps.segment.inSearch && prevProps.segment.currentInSearch !== diff --git a/public/js/cat_source/es6/components/segments/Segment.js b/public/js/cat_source/es6/components/segments/Segment.js index 8f9c0d70f2..5e2f810c18 100644 --- a/public/js/cat_source/es6/components/segments/Segment.js +++ b/public/js/cat_source/es6/components/segments/Segment.js @@ -1,5 +1,5 @@ import {forEach, isUndefined} from 'lodash' -import Immutable from 'immutable' +import {fromJS} from 'immutable' import React from 'react' import {union} from 'lodash/array' @@ -636,8 +636,8 @@ class Segment extends React.Component { shouldComponentUpdate(nextProps, nextState) { return ( !nextProps.segImmutable.equals(this.props.segImmutable) || - !Immutable.fromJS(nextState.segment_classes).equals( - Immutable.fromJS(this.state.segment_classes), + !fromJS(nextState.segment_classes).equals( + fromJS(this.state.segment_classes), ) || nextState.autopropagated !== this.state.autopropagated || nextState.readonly !== this.state.readonly || diff --git a/public/js/cat_source/es6/components/segments/SegmentFooterMultiMatches.js b/public/js/cat_source/es6/components/segments/SegmentFooterMultiMatches.js index 997fb20cac..f24d920f7b 100644 --- a/public/js/cat_source/es6/components/segments/SegmentFooterMultiMatches.js +++ b/public/js/cat_source/es6/components/segments/SegmentFooterMultiMatches.js @@ -1,5 +1,5 @@ import React from 'react' -import Immutable from 'immutable' +import {fromJS} from 'immutable' import {isUndefined} from 'lodash' import TextUtils from '../../utils/textUtils' @@ -157,8 +157,8 @@ class SegmentFooterMultiMatches extends React.Component { !isUndefined(this.props.segment.cl_contributions)) && ((!isUndefined(nextProps.segment.cl_contributions) && isUndefined(this.props.segment.cl_contributions)) || - !Immutable.fromJS(this.props.segment.cl_contributions).equals( - Immutable.fromJS(nextProps.segment.cl_contributions), + !fromJS(this.props.segment.cl_contributions).equals( + fromJS(nextProps.segment.cl_contributions), ))) || this.props.active_class !== nextProps.active_class || this.props.tab_class !== nextProps.tab_class diff --git a/public/js/cat_source/es6/components/segments/SegmentFooterTabConflicts.js b/public/js/cat_source/es6/components/segments/SegmentFooterTabConflicts.js index bee335fac9..e8061736f2 100644 --- a/public/js/cat_source/es6/components/segments/SegmentFooterTabConflicts.js +++ b/public/js/cat_source/es6/components/segments/SegmentFooterTabConflicts.js @@ -1,6 +1,6 @@ import React from 'react' import {isUndefined, size} from 'lodash' -import Immutable from 'immutable' +import {fromJS} from 'immutable' import TextUtils from '../../utils/textUtils' import SegmentActions from '../../actions/SegmentActions' @@ -143,8 +143,8 @@ class SegmentFooterTabConflicts extends React.Component { !isUndefined(this.props.segment.alternatives)) && ((!isUndefined(nextProps.segment.alternatives) && isUndefined(this.props.segment.alternatives)) || - !Immutable.fromJS(this.props.segment.alternatives).equals( - Immutable.fromJS(nextProps.segment.alternatives), + !fromJS(this.props.segment.alternatives).equals( + fromJS(nextProps.segment.alternatives), ))) ) } diff --git a/public/js/cat_source/es6/components/segments/SegmentFooterTabMatches.js b/public/js/cat_source/es6/components/segments/SegmentFooterTabMatches.js index 3b3c7af2e6..7fd07f6e40 100644 --- a/public/js/cat_source/es6/components/segments/SegmentFooterTabMatches.js +++ b/public/js/cat_source/es6/components/segments/SegmentFooterTabMatches.js @@ -1,6 +1,6 @@ import React from 'react' import {isUndefined} from 'lodash' -import Immutable from 'immutable' +import {fromJS} from 'immutable' import SegmentConstants from '../../constants/SegmentConstants' import SegmentStore from '../../stores/SegmentStore' @@ -229,8 +229,8 @@ class SegmentFooterTabMatches extends React.Component { !isUndefined(this.props.segment.contributions)) && ((!isUndefined(nextProps.segment.contributions) && isUndefined(this.props.segment.contributions)) || - !Immutable.fromJS(this.props.segment.contributions).equals( - Immutable.fromJS(nextProps.segment.contributions), + !fromJS(this.props.segment.contributions).equals( + fromJS(nextProps.segment.contributions), ))) || this.props.active_class !== nextProps.active_class || this.props.tab_class !== nextProps.tab_class || diff --git a/public/js/cat_source/es6/components/segments/SegmentFooterTabMessages.js b/public/js/cat_source/es6/components/segments/SegmentFooterTabMessages.js index c78c83b29d..d8d9c266ab 100644 --- a/public/js/cat_source/es6/components/segments/SegmentFooterTabMessages.js +++ b/public/js/cat_source/es6/components/segments/SegmentFooterTabMessages.js @@ -1,5 +1,5 @@ import React from 'react' -import Immutable from 'immutable' +import {fromJS} from 'immutable' import {isUndefined} from 'lodash' import TEXT_UTILS from '../../utils/textUtils' @@ -151,9 +151,7 @@ class SegmentFooterTabMessages extends React.Component { return ( isUndefined(nextProps.notes) || isUndefined(this.props.note) || - !Immutable.fromJS(this.props.notes).equals( - Immutable.fromJS(nextProps.notes), - ) || + !fromJS(this.props.notes).equals(fromJS(nextProps.notes)) || this.props.loading !== nextProps.loading || this.props.active_class !== nextProps.active_class || this.props.tab_class !== nextProps.tab_class diff --git a/public/js/cat_source/es6/components/segments/SegmentSource.js b/public/js/cat_source/es6/components/segments/SegmentSource.js index 3c5e9b54d4..9c6c38c94b 100644 --- a/public/js/cat_source/es6/components/segments/SegmentSource.js +++ b/public/js/cat_source/es6/components/segments/SegmentSource.js @@ -1,5 +1,5 @@ import React, {createRef} from 'react' -import Immutable from 'immutable' +import {fromJS} from 'immutable' import {remove, cloneDeep, size, isUndefined} from 'lodash' import {CompositeDecorator, Editor, EditorState, Modifier} from 'draft-js' @@ -271,8 +271,8 @@ class SegmentSource extends React.Component { missingGlossaryItems && missingGlossaryItems.length > 0 && (isUndefined(prevMissingGlossaryItems) || - !Immutable.fromJS(prevMissingGlossaryItems).equals( - Immutable.fromJS(missingGlossaryItems), + !fromJS(prevMissingGlossaryItems).equals( + fromJS(missingGlossaryItems), )) ) { this.addQaCheckGlossaryDecorator() @@ -292,7 +292,7 @@ class SegmentSource extends React.Component { glossary && size(glossary) > 0 && (isUndefined(prevGlossary) || - !Immutable.fromJS(prevGlossary).equals(Immutable.fromJS(glossary)) || + !fromJS(prevGlossary).equals(fromJS(glossary)) || !prevActiveDecorators[DraftMatecatConstants.GLOSSARY_DECORATOR]) ) { activeDecorators[DraftMatecatConstants.GLOSSARY_DECORATOR] = true @@ -315,9 +315,7 @@ class SegmentSource extends React.Component { const lexiqaChanged = prevLexiqaSource && currentLexiqaSource && - !Immutable.fromJS(prevLexiqa.source).equals( - Immutable.fromJS(lexiqa.source), - ) + !fromJS(prevLexiqa.source).equals(fromJS(lexiqa.source)) if ( currentLexiqaSource && @@ -347,8 +345,8 @@ class SegmentSource extends React.Component { (!prevProps || // was not mounted !prevProps.segment.inSearch || //Before was not active (prevProps.segment.inSearch && - !Immutable.fromJS(prevProps.segment.searchParams).equals( - Immutable.fromJS(searchParams), + !fromJS(prevProps.segment.searchParams).equals( + fromJS(searchParams), )) || //Before was active but some params change (prevProps.segment.inSearch && prevProps.segment.currentInSearch !== currentInSearch) || //Before was the current diff --git a/public/js/cat_source/es6/components/segments/SegmentWarnings.js b/public/js/cat_source/es6/components/segments/SegmentWarnings.js index 022426f351..7e95075265 100644 --- a/public/js/cat_source/es6/components/segments/SegmentWarnings.js +++ b/public/js/cat_source/es6/components/segments/SegmentWarnings.js @@ -3,7 +3,7 @@ */ import React from 'react' -import Immutable from 'immutable' +import {fromJS} from 'immutable' import {forOwn} from 'lodash' class SegmentWarnings extends React.Component { @@ -17,9 +17,7 @@ class SegmentWarnings extends React.Component { componentWillUnmount() {} shouldComponentUpdate(nextProps) { - return !Immutable.fromJS(this.props.warnings).equals( - Immutable.fromJS(nextProps.warnings), - ) + return !fromJS(this.props.warnings).equals(fromJS(nextProps.warnings)) } render() { diff --git a/public/js/cat_source/es6/components/segments/SegmentsContainer.js b/public/js/cat_source/es6/components/segments/SegmentsContainer.js index c87df10e54..092398e88f 100644 --- a/public/js/cat_source/es6/components/segments/SegmentsContainer.js +++ b/public/js/cat_source/es6/components/segments/SegmentsContainer.js @@ -9,7 +9,7 @@ import React, { useState, } from 'react' import PropTypes from 'prop-types' -import Immutable from 'immutable' +import {fromJS} from 'immutable' import ReactDOMServer from 'react-dom/server' import {useHotkeys} from 'react-hotkeys-hook' import {Shortcuts} from '../../utils/shortcuts' @@ -146,7 +146,7 @@ function SegmentsContainer({isReview, startSegmentId, firstJobSegment}) { const {userInfo} = useContext(ApplicationWrapperContext) - const [segments, setSegments] = useState(Immutable.fromJS([])) + const [segments, setSegments] = useState(fromJS([])) const [rows, setRows] = useState([]) const [essentialRows, setEssentialRows] = useState([]) const [hasCachedRows, setHasCachedRows] = useState(false) diff --git a/public/js/cat_source/es6/components/segments/utils/DraftMatecatUtils/DraftSource/randomizeBlockMapKeys.js b/public/js/cat_source/es6/components/segments/utils/DraftMatecatUtils/DraftSource/randomizeBlockMapKeys.js index 4dad5fa1ac..ce2707ebc7 100644 --- a/public/js/cat_source/es6/components/segments/utils/DraftMatecatUtils/DraftSource/randomizeBlockMapKeys.js +++ b/public/js/cat_source/es6/components/segments/utils/DraftMatecatUtils/DraftSource/randomizeBlockMapKeys.js @@ -2,12 +2,10 @@ * Duplicated from draft-js - not part of the public API */ -import Immutable from 'immutable' +import {OrderedMap} from 'immutable' import {genKey} from 'draft-js' import ContentBlockNode from './src/model/immutable/ContentBlockNode' -const {OrderedMap} = Immutable - const randomizeContentBlockNodeKeys = (blockMap) => { const newKeysRef = {} diff --git a/public/js/cat_source/es6/components/segments/utils/DraftMatecatUtils/DraftSource/src/model/immutable/ContentBlockNode.js b/public/js/cat_source/es6/components/segments/utils/DraftMatecatUtils/DraftSource/src/model/immutable/ContentBlockNode.js index 3ba602ee91..817f73f393 100644 --- a/public/js/cat_source/es6/components/segments/utils/DraftMatecatUtils/DraftSource/src/model/immutable/ContentBlockNode.js +++ b/public/js/cat_source/es6/components/segments/utils/DraftMatecatUtils/DraftSource/src/model/immutable/ContentBlockNode.js @@ -9,9 +9,8 @@ */ import findRangesImmutable from './findRangesimmutable' -import Immutable from 'immutable' +import {List, Map, OrderedSet, Record, Repeat} from 'immutable' import {CharacterMetadata} from 'draft-js' -const {List, Map, OrderedSet, Record, Repeat} = Immutable const EMPTY_SET = OrderedSet() const defaultRecord = { diff --git a/public/js/cat_source/es6/components/segments/utils/DraftMatecatUtils/buildFragmentFromJson.js b/public/js/cat_source/es6/components/segments/utils/DraftMatecatUtils/buildFragmentFromJson.js index 42650ad55e..0334b3528c 100644 --- a/public/js/cat_source/es6/components/segments/utils/DraftMatecatUtils/buildFragmentFromJson.js +++ b/public/js/cat_source/es6/components/segments/utils/DraftMatecatUtils/buildFragmentFromJson.js @@ -1,9 +1,7 @@ import {ContentBlock, BlockMapBuilder, CharacterMetadata} from 'draft-js' -import Immutable from 'immutable' +import {OrderedMap, List, OrderedSet} from 'immutable' const buildFragmentFromJson = (fragmentObject) => { - const {OrderedMap, List, OrderedSet} = Immutable - //const fragmentContent = JSON.parse(text); const fragmentMap = OrderedMap(fragmentObject) diff --git a/public/js/cat_source/es6/pages/AnalyzePage.js b/public/js/cat_source/es6/pages/AnalyzePage.js index 0fba91b9f7..64be2bce65 100644 --- a/public/js/cat_source/es6/pages/AnalyzePage.js +++ b/public/js/cat_source/es6/pages/AnalyzePage.js @@ -2,12 +2,11 @@ import React, {useContext, useEffect, useRef, useState} from 'react' import UserStore from '../stores/UserStore' import Header from '../components/header/Header' import AnalyzeMain from '../components/analyze/AnalyzeMain' -import NotificationBox from '../components/notificationsComponent/NotificationBox' import {CookieConsent} from '../components/common/CookieConsent' import {getJobVolumeAnalysis} from '../api/getJobVolumeAnalysis' import {getProject} from '../api/getProject' import {getVolumeAnalysis} from '../api/getVolumeAnalysis' -import Immutable from 'immutable' +import {fromJS} from 'immutable' import {ANALYSIS_STATUS} from '../constants/Constants' import {mountPage} from './mountPage' import {ApplicationWrapperContext} from '../components/common/ApplicationWrapper' @@ -96,8 +95,8 @@ const AnalyzePage = () => {
diff --git a/public/js/cat_source/es6/pages/Dashboard.js b/public/js/cat_source/es6/pages/Dashboard.js index 9b60ef0fd8..ebf73744f2 100644 --- a/public/js/cat_source/es6/pages/Dashboard.js +++ b/public/js/cat_source/es6/pages/Dashboard.js @@ -1,5 +1,5 @@ import React from 'react' -import Immutable from 'immutable' +import {fromJS} from 'immutable' import {isEmpty} from 'lodash' import {debounce} from 'lodash/function' import ReactDOM, {flushSync} from 'react-dom' @@ -467,8 +467,8 @@ class Dashboard extends React.Component { {this.state.selectedTeam && this.state.teams ? ( diff --git a/public/js/cat_source/es6/stores/ProjectsStore.js b/public/js/cat_source/es6/stores/ProjectsStore.js index acd33c2dd0..9e6ea5cd95 100644 --- a/public/js/cat_source/es6/stores/ProjectsStore.js +++ b/public/js/cat_source/es6/stores/ProjectsStore.js @@ -6,7 +6,7 @@ import AppDispatcher from './AppDispatcher' import {EventEmitter} from 'events' import ManageConstants from '../constants/ManageConstants' import assign from 'object-assign' -import Immutable from 'immutable' +import {fromJS} from 'immutable' EventEmitter.prototype.setMaxListeners(0) @@ -14,7 +14,7 @@ const ProjectsStore = assign({}, EventEmitter.prototype, { projects: null, setProjects: function (projects) { - this.projects = Immutable.fromJS(projects) + this.projects = fromJS(projects) }, /** * Update all @@ -22,16 +22,16 @@ const ProjectsStore = assign({}, EventEmitter.prototype, { updateAll: function (projects) { /*this.projects = this.projects.mergeWith((oldProject, newProject, index) => { return (newProject.get('id') === newProject.get('id')) ? oldProject : newProject - },Immutable.fromJS(projects));*/ - // this.projects = this.projects.toSet().union(Immutable.fromJS(projects).toSet()).toList(); + },fromJS(projects));*/ + // this.projects = this.projects.toSet().union(fromJS(projects).toSet()).toList(); // - this.projects = Immutable.fromJS(projects) + this.projects = fromJS(projects) }, /** * Add Projects (pagination) */ addProjects: function (projects) { - this.projects = this.projects.concat(Immutable.fromJS(projects)) + this.projects = this.projects.concat(fromJS(projects)) }, removeProject: function (project) { @@ -149,7 +149,7 @@ const ProjectsStore = assign({}, EventEmitter.prototype, { let indexJob = project.get('jobs').indexOf(job) this.projects = this.projects.setIn( [indexProject, 'jobs', indexJob, 'outsource'], - Immutable.fromJS(outsource), + fromJS(outsource), ) } }, @@ -165,7 +165,7 @@ const ProjectsStore = assign({}, EventEmitter.prototype, { let indexJob = project.get('jobs').indexOf(job) this.projects = this.projects.setIn( [indexProject, 'jobs', indexJob, 'translator'], - Immutable.fromJS(translator), + fromJS(translator), ) }, @@ -181,7 +181,7 @@ const ProjectsStore = assign({}, EventEmitter.prototype, { // let url = config.hostpath + '/revise2/' + project.get('name') + '/'+ job.get('source') +'-'+ job.get('target') +'/'+ jobId +'-'+ secondPassPassword; this.projects = this.projects.setIn( [indexProject, 'jobs', indexJob, 'revise_passwords', 1], - Immutable.fromJS({revision_number: 2, password: secondPassPassword}), + fromJS({revision_number: 2, password: secondPassPassword}), ) }, @@ -206,8 +206,8 @@ AppDispatcher.register(function (action) { ProjectsStore.emitChange( action.actionType, ProjectsStore.projects, - Immutable.fromJS(action.team), - Immutable.fromJS(action.teams), + fromJS(action.team), + fromJS(action.teams), action.hideSpinner, action.filtering, ) @@ -217,7 +217,7 @@ AppDispatcher.register(function (action) { ProjectsStore.emitChange( action.actionType, ProjectsStore.projects, - Immutable.fromJS(action.teams), + fromJS(action.teams), action.hideSpinner, ) break @@ -315,10 +315,7 @@ AppDispatcher.register(function (action) { ) break case ManageConstants.HIDE_PROJECT: - ProjectsStore.emitChange( - action.actionType, - Immutable.fromJS(action.project), - ) + ProjectsStore.emitChange(action.actionType, fromJS(action.project)) break case ManageConstants.ENABLE_DOWNLOAD_BUTTON: case ManageConstants.DISABLE_DOWNLOAD_BUTTON: diff --git a/public/js/cat_source/es6/stores/QualityReportStore.js b/public/js/cat_source/es6/stores/QualityReportStore.js index 6f0ab01859..335188bbdc 100644 --- a/public/js/cat_source/es6/stores/QualityReportStore.js +++ b/public/js/cat_source/es6/stores/QualityReportStore.js @@ -1,6 +1,6 @@ import {EventEmitter} from 'events' import assign from 'object-assign' -import Immutable from 'immutable' +import {fromJS} from 'immutable' import {forEach} from 'lodash' import AppDispatcher from './AppDispatcher' @@ -9,9 +9,9 @@ import QRConstants from '../constants/QualityReportConstants' EventEmitter.prototype.setMaxListeners(0) let QualityReportStore = assign({}, EventEmitter.prototype, { - _segmentsFiles: Immutable.fromJS({}), - _files: Immutable.fromJS({}), - _jobInfo: Immutable.fromJS({}), + _segmentsFiles: fromJS({}), + _files: fromJS({}), + _jobInfo: fromJS({}), _lastSegment: null, storeSegments: function (segmentsData) { const files = {} @@ -22,8 +22,8 @@ let QualityReportStore = assign({}, EventEmitter.prototype, { : (segmentsFiles[segment.file.id] = [segment]) files[segment.file.id] = segment.file }) - this._segmentsFiles = Immutable.fromJS(segmentsFiles) - this._files = Immutable.fromJS(files) + this._segmentsFiles = fromJS(segmentsFiles) + this._files = fromJS(files) this._lastSegment = segmentsData.segments.length > 0 ? segmentsData._links.last_segment_id @@ -31,24 +31,21 @@ let QualityReportStore = assign({}, EventEmitter.prototype, { }, storeJobInfo: function (job) { - this._jobInfo = Immutable.fromJS(job) + this._jobInfo = fromJS(job) }, addSegments: function (segmentsData) { forEach(segmentsData.segments, (segment) => { const fileId = segment.file.id.toString() if (this._segmentsFiles.get(fileId)) { - let immFiles = Immutable.fromJS(segment) + let immFiles = fromJS(segment) this._segmentsFiles = this._segmentsFiles.set( fileId, this._segmentsFiles.get(fileId).push(immFiles), ) } else { - this._segmentsFiles = this._segmentsFiles.set( - fileId, - Immutable.fromJS([segment]), - ) - this._files = this._files.set(fileId, Immutable.fromJS(segment.file)) + this._segmentsFiles = this._segmentsFiles.set(fileId, fromJS([segment])) + this._files = this._files.set(fileId, fromJS(segment.file)) } }) this._lastSegment = segmentsData._links.last_segment_id diff --git a/public/js/cat_source/es6/stores/SegmentStore.js b/public/js/cat_source/es6/stores/SegmentStore.js index 2516f9d6a8..90dc09bd52 100644 --- a/public/js/cat_source/es6/stores/SegmentStore.js +++ b/public/js/cat_source/es6/stores/SegmentStore.js @@ -31,7 +31,7 @@ */ import {isUndefined, uniq, each} from 'lodash' import {EventEmitter} from 'events' -import Immutable from 'immutable' +import {fromJS} from 'immutable' import assign from 'object-assign' import AppDispatcher from './AppDispatcher' @@ -73,7 +73,7 @@ const normalizeSetUpdateGlossary = (terms) => { } const SegmentStore = assign({}, EventEmitter.prototype, { - _segments: Immutable.fromJS([]), + _segments: fromJS([]), _globalWarnings: { lexiqa: [], matecat: { @@ -92,7 +92,7 @@ const SegmentStore = assign({}, EventEmitter.prototype, { }, }, segmentsInBulk: [], - _footerTabsConfig: Immutable.fromJS({}), + _footerTabsConfig: fromJS({}), searchOccurrences: [], searchResultsDictionary: {}, currentInSearch: 0, @@ -112,16 +112,14 @@ const SegmentStore = assign({}, EventEmitter.prototype, { updateAll: function (segments, where) { if (this._segments.size > 0 && where === 'before') { this._segments = this._segments.unshift( - ...Immutable.fromJS(this.normalizeSplittedSegments(segments)), + ...fromJS(this.normalizeSplittedSegments(segments)), ) } else if (this._segments.size > 0 && where === 'after') { this._segments = this._segments.push( - ...Immutable.fromJS(this.normalizeSplittedSegments(segments)), + ...fromJS(this.normalizeSplittedSegments(segments)), ) } else { - this._segments = Immutable.fromJS( - this.normalizeSplittedSegments(segments), - ) + this._segments = fromJS(this.normalizeSplittedSegments(segments)) } if (this.segmentsInBulk.length > 0) { @@ -129,7 +127,7 @@ const SegmentStore = assign({}, EventEmitter.prototype, { } }, removeAllSegments: function () { - this._segments = Immutable.fromJS([]) + this._segments = fromJS([]) }, normalizeSplittedSegments: function (segments) { let newSegments = [] @@ -443,16 +441,10 @@ const SegmentStore = assign({}, EventEmitter.prototype, { versions[0].translation == '' ) { // TODO Remove this if - this._segments = this._segments.setIn( - [index, 'versions'], - Immutable.fromJS([]), - ) + this._segments = this._segments.setIn([index, 'versions'], fromJS([])) return this._segments.get(index) } - this._segments = this._segments.setIn( - [index, 'versions'], - Immutable.fromJS(versions), - ) + this._segments = this._segments.setIn([index, 'versions'], fromJS(versions)) return this._segments.get(index) }, addSegmentPreloadedIssues(sid, issues) { @@ -463,10 +455,7 @@ const SegmentStore = assign({}, EventEmitter.prototype, { versions.push({ issues: issues, }) - this._segments = this._segments.setIn( - [index, 'versions'], - Immutable.fromJS(versions), - ) + this._segments = this._segments.setIn([index, 'versions'], fromJS(versions)) return this._segments.get(index) }, lockUnlockEditArea(sid) { @@ -568,7 +557,7 @@ const SegmentStore = assign({}, EventEmitter.prototype, { if (index === -1) return this._segments = this._segments.setIn( [index, 'concordance'], - Immutable.fromJS(matches), + fromJS(matches), ) }, setContributionsToCache: function (sid, contributions, errors) { @@ -576,7 +565,7 @@ const SegmentStore = assign({}, EventEmitter.prototype, { if (index === -1) return this._segments = this._segments.setIn( [index, 'contributions'], - Immutable.fromJS({ + fromJS({ matches: contributions, errors: errors, }), @@ -590,7 +579,7 @@ const SegmentStore = assign({}, EventEmitter.prototype, { } else { this._segments = this._segments.setIn( [index, 'alternatives'], - Immutable.fromJS(alternatives), + fromJS(alternatives), ) } }, @@ -629,7 +618,7 @@ const SegmentStore = assign({}, EventEmitter.prototype, { this._segments = this._segments.setIn( [index, 'glossary'], - Immutable.fromJS( + fromJS( adaptedTerms.map((term) => ({ ...term, missingTerm: glossary.find(({term_id}) => term_id === term.term_id) @@ -651,7 +640,7 @@ const SegmentStore = assign({}, EventEmitter.prototype, { this._segments = this._segments.setIn( [index, 'glossary_search_results'], - Immutable.fromJS(terms ? terms : segment.get('glossary')), + fromJS(terms ? terms : segment.get('glossary')), ) }, deleteFromGlossary: function (sid, term) { @@ -665,7 +654,7 @@ const SegmentStore = assign({}, EventEmitter.prototype, { ) this._segments = this._segments.setIn( [index, 'glossary'], - Immutable.fromJS(updatedGlossary), + fromJS(updatedGlossary), ) this.setGlossarySearchToCache(sid) }, @@ -708,7 +697,7 @@ const SegmentStore = assign({}, EventEmitter.prototype, { this._segments = this._segments.setIn( [index, isGlossaryAlreadyExist ? 'glossary' : 'pendingGlossaryUpdates'], - Immutable.fromJS(updatedGlossary), + fromJS(updatedGlossary), ) this.setGlossarySearchToCache(sid, updatedGlossary) }, @@ -820,13 +809,10 @@ const SegmentStore = assign({}, EventEmitter.prototype, { setSegmentWarnings(sid, warning, tagMismatch) { let index = this.getSegmentIndex(sid) if (index === -1) return - this._segments = this._segments.setIn( - [index, 'warnings'], - Immutable.fromJS(warning), - ) + this._segments = this._segments.setIn([index, 'warnings'], fromJS(warning)) this._segments = this._segments.setIn( [index, 'tagMismatch'], - Immutable.fromJS(tagMismatch), + fromJS(tagMismatch), ) }, setQACheck(sid, data) { @@ -865,18 +851,15 @@ const SegmentStore = assign({}, EventEmitter.prototype, { if (type === 1) { this._segments = this._segments.setIn( [index, 'lexiqa', 'source'], - Immutable.fromJS(matches), + fromJS(matches), ) } else if (type === 2) { this._segments = this._segments.setIn( [index, 'lexiqa', 'target'], - Immutable.fromJS(matches), + fromJS(matches), ) } else { - this._segments = this._segments.setIn( - [index, 'lexiqa'], - Immutable.fromJS(matches), - ) + this._segments = this._segments.setIn([index, 'lexiqa'], fromJS(matches)) } }, updateGlobalWarnings: function (warnings) { diff --git a/public/js/cat_source/es6/stores/UserStore.js b/public/js/cat_source/es6/stores/UserStore.js index cb69834edd..879b1ab013 100644 --- a/public/js/cat_source/es6/stores/UserStore.js +++ b/public/js/cat_source/es6/stores/UserStore.js @@ -7,21 +7,21 @@ import {EventEmitter} from 'events' import ManageConstants from '../constants/ManageConstants' import UserConstants from '../constants/UserConstants' import assign from 'object-assign' -import Immutable from 'immutable' +import {fromJS} from 'immutable' EventEmitter.prototype.setMaxListeners(0) const UserStore = assign({}, EventEmitter.prototype, { - teams: Immutable.fromJS([]), + teams: fromJS([]), selectedTeam: {}, userInfo: null, updateTeams: function (teams) { - this.teams = Immutable.fromJS(teams) + this.teams = fromJS(teams) }, addTeam: function (team) { - this.teams = this.teams.concat(Immutable.fromJS([team])) + this.teams = this.teams.concat(fromJS([team])) }, updateUser: function (user) { this.userInfo = user @@ -36,7 +36,7 @@ const UserStore = assign({}, EventEmitter.prototype, { return org.get('id') == team.id }) let index = this.teams.indexOf(teamOld) - this.teams = this.teams.setIn([index], Immutable.fromJS(team)) + this.teams = this.teams.setIn([index], fromJS(team)) return this.teams.get(index) }, @@ -54,10 +54,10 @@ const UserStore = assign({}, EventEmitter.prototype, { return org.get('id') == team.get('id') }) let index = this.teams.indexOf(teamOld) - this.teams = this.teams.setIn([index, 'members'], Immutable.fromJS(members)) + this.teams = this.teams.setIn([index, 'members'], fromJS(members)) this.teams = this.teams.setIn( [index, 'pending_invitations'], - Immutable.fromJS(pendingInvitations), + fromJS(pendingInvitations), ) return this.teams.get(index) }, @@ -174,7 +174,7 @@ AppDispatcher.register(function (action) { case ManageConstants.OPEN_MODIFY_TEAM_MODAL: UserStore.emitChange( action.actionType, - Immutable.fromJS(action.team), + fromJS(action.team), action.hideChangeName, ) break diff --git a/yarn.lock b/yarn.lock index f9e06026fd..5a248503d3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5093,12 +5093,7 @@ immutability-helper@^3.1.1: resolved "https://registry.yarnpkg.com/immutability-helper/-/immutability-helper-3.1.1.tgz#2b86b2286ed3b1241c9e23b7b21e0444f52f77b7" integrity sha512-Q0QaXjPjwIju/28TsugCHNEASwoCcJSyJV3uO1sOIQGI0jKgm9f41Lvz0DZj3n46cNCyAZTsEYoY4C2bVRUzyQ== -immutable@^4.0.0-rc.12: - version "4.3.7" - resolved "https://registry.yarnpkg.com/immutable/-/immutable-4.3.7.tgz#c70145fc90d89fb02021e65c84eb0226e4e5a381" - integrity sha512-1hqclzwYwjRDFLjcFxOM5AYkkG0rpFPpr1RLPMEuGczoS7YA8gLhy8SWXYRAA/XwfEHpfo3cw5JGioS32fnMRw== - -immutable@^5.0.2: +immutable@^5.0.0, immutable@^5.0.2: version "5.0.3" resolved "https://registry.yarnpkg.com/immutable/-/immutable-5.0.3.tgz#aa037e2313ea7b5d400cd9298fa14e404c933db1" integrity sha512-P8IdPQHq3lA1xVeBRi5VPqUm5HDgKnx0Ru51wZz5mjxHr5n3RWhjIpOFU7ybkUxfB+5IToy+OLaHYDBIWsv+uw==