Skip to content
Open
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
14,953 changes: 9,961 additions & 4,992 deletions package-lock.json

Large diffs are not rendered by default.

17 changes: 8 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"description": "OpenBoxes Web App",
"main": "index.js",
"engines": {
"node": "^14",
"npm": "^6 || ^7"
"node": "^20",
"npm": "^10"
},
"directories": {
"doc": "docs",
Expand Down Expand Up @@ -78,13 +78,13 @@
"popper.js": "1.16.1",
"prop-types": "15.8.1",
"query-string": "6.14.1",
"react": "16.8.6",
"react": "18.3.1",
"react-chartjs-2": "2.9.0",
"react-color": "2.19.3",
"react-confirm-alert": "2.6.1",
"react-datepicker": "1.8.0",
"react-datepicker-6": "npm:react-datepicker@6.9.0",
"react-dom": "16.8.6",
"react-dom": "18.3.1",
"react-dropzone": "14.2.3",
"react-final-form": "3.6.5",
"react-final-form-arrays": "1.0.6",
Expand All @@ -98,7 +98,7 @@
"react-meta-tags": "0.7.4",
"react-modal": "3.5.1",
"react-overlays": "0.8.3",
"react-redux": "7.1.3",
"react-redux": "8.1.3",
"react-router-dom": "5.3.4",
"react-s-alert": "1.4.1",
"react-select": "2.4.4",
Expand All @@ -124,10 +124,9 @@
"@babel/preset-env": "7.24.4",
"@babel/preset-react": "7.18.6",
"@testing-library/jest-dom": "5.16.5",
"@testing-library/react": "12.1.5",
"@testing-library/react-hooks": "8.0.1",
"@testing-library/react": "14.3.1",
"@types/jest": "29.5.14",
"@types/react-dom": "16.8.5",
"@types/react-dom": "18.3.7",
"babel-loader": "9.1.2",
"css-loader": "3.6.0",
"css-minimizer-webpack-plugin": "4.2.2",
Expand All @@ -149,7 +148,7 @@
"mock-local-storage": "1.1.23",
"postcss": "8.5.6",
"react-styleguidist": "12.0.1",
"react-test-renderer": "16.8.6",
"react-test-renderer": "18.3.1",
"sass": "1.62.1",
"sass-loader": "13.2.2",
"url-loader": "4.1.1",
Expand Down
12 changes: 6 additions & 6 deletions src/js/MainRouter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { renderToStaticMarkup } from 'react-dom/server';
import { withLocalize } from 'react-localize-redux';
import connect from 'react-redux/es/connect/connect';
import { connect } from 'react-redux';

import { fetchMenuConfig, fetchSessionInfo, fetchTranslations } from 'actions';
import Router from 'components/Router';
Expand All @@ -17,7 +17,7 @@ const TRANSLATION_PREFIXES = ['default', 'dashboard', 'combinedShipments', 'prod
// TODO: Refactor fetching menu config
// TODO: Refactor fetching localizations (react-localize-redux)

class MainRouter extends React.Component {
export class MainRouter extends React.Component {
componentDidMount() {
this.props.fetchSessionInfo().then(() => {
this.props.initialize({
Expand All @@ -33,11 +33,11 @@ class MainRouter extends React.Component {
});
}

componentWillReceiveProps(nextProps) {
if (this.props.locale !== nextProps.locale) {
this.props.setActiveLanguage(nextProps.locale);
componentDidUpdate(prevProps) {
if (prevProps.locale !== this.props.locale) {
this.props.setActiveLanguage(this.props.locale);

if (this.props.locale) {
if (prevProps.locale) {
TRANSLATION_PREFIXES.forEach((prefix) => this.props.fetchTranslations('', prefix));
}

Expand Down
33 changes: 15 additions & 18 deletions src/js/components/Filter/FilterForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const FilterForm = ({
disableAutoUpdateFilterParams,
onSubmit,
}) => {
const [amountFilled, setAmountFilled] = useState(0);
const [filtersHidden, setFiltersHidden] = useState(hidden);
const formRef = useRef(null);

Expand Down Expand Up @@ -73,22 +72,20 @@ const FilterForm = ({
useTranslation('button');

// Calculate which object's values are not empty
const countFilled = (values) => {
setAmountFilled(Object.entries(values)
.filter(([key, value]) => {
// Ignore accounting for filter that is disabled
const dynamicAttributes = _.invoke(filterFields, `${key}.getDynamicAttr`, formProps);
const attributes = _.get(filterFields, `${key}.attributes`);
if (dynamicAttributes?.disabled || attributes?.disabled) return false;

// Ignore filter that is not specified in filterFields config
// and that is not a search field
if (!filterFields[key] && key !== searchFieldId) return false;
// evaluate filter value
if (typeof value === 'object') return !_.isEmpty(value);
return !!value;
}).length);
};
const countFilled = (values) => Object.entries(values)
.filter(([key, value]) => {
// Ignore accounting for filter that is disabled
const dynamicAttributes = _.invoke(filterFields, `${key}.getDynamicAttr`, formProps);
const attributes = _.get(filterFields, `${key}.attributes`);
if (dynamicAttributes?.disabled || attributes?.disabled) return false;

// Ignore filter that is not specified in filterFields config
// and that is not a search field
if (!filterFields[key] && key !== searchFieldId) return false;
// evaluate filter value
if (typeof value === 'object') return !_.isEmpty(value);
return !!value;
}).length;

const onClearHandler = (form) => {
if (onClear && typeof onClear === 'function') {
Expand Down Expand Up @@ -141,7 +138,7 @@ const FilterForm = ({
initialValues={{ ...defaultValues }}
render={({ values, handleSubmit, form }) => {
formRef.current = form;
countFilled(values);
const amountFilled = countFilled(values);
return (
<form onSubmit={handleSubmit} className="w-100 m-0">
<div className="classic-form with-description align-items-center flex-wrap">
Expand Down
12 changes: 10 additions & 2 deletions src/js/components/GlobalSearch/GlobalSearch.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';

import PropTypes from 'prop-types';
import { RiCloseLine, RiSearchLine } from 'react-icons/ri';
Expand All @@ -24,10 +24,16 @@ const ValueContainer = ({ children, ...props }) => (
);

const GlobalSearch = ({
className, visible, renderButton, debounceTime, minSearchLength, translate,
className, visible, renderButton, debounceTime, minSearchLength, translate, onVisibilityChange,
}) => {
const [isVisible, setIsVisible] = useState(visible);

useEffect(() => {
if (onVisibilityChange) {
onVisibilityChange(isVisible);
}
}, [isVisible]);

const searchItems = debounceGlobalSearch(debounceTime, minSearchLength);

const showSearchbar = () => setIsVisible(true);
Expand Down Expand Up @@ -154,10 +160,12 @@ GlobalSearch.propTypes = {
minSearchLength: PropTypes.number.isRequired,
className: PropTypes.string,
translate: PropTypes.func.isRequired,
onVisibilityChange: PropTypes.func,
};

GlobalSearch.defaultProps = {
renderButton: undefined,
visible: false,
className: '',
onVisibilityChange: undefined,
};
22 changes: 10 additions & 12 deletions src/js/components/Layout/NavbarIcons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,16 @@ const NavbarIcons = ({
tooltip: translate('react.default.navbar.search', 'Search'),
component: (renderProps) => (
<GlobalSearch
renderButton={({ showSearchbar, isVisible }) => {
renderProps.setIsTooltipDisabled(isVisible);
return (
<button
type="button"
onClick={showSearchbar}
className="menu-icon"
>
<RiSearchLine />
</button>
);
}}
onVisibilityChange={renderProps.setIsTooltipDisabled}
renderButton={({ showSearchbar }) => (
<button
type="button"
onClick={showSearchbar}
className="menu-icon"
>
<RiSearchLine />
</button>
)}
/>
),
},
Expand Down
7 changes: 4 additions & 3 deletions src/js/components/Layout/VerticalTabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ class VerticalTabs extends Component {
};
}

componentWillReceiveProps(nextProps) {
if (Object.keys(this.props.tabs).length !== Object.keys(nextProps.tabs).length) {
this.setState({ activeTab: Object.keys(nextProps.tabs)[0] });
componentDidUpdate(prevProps) {
if (Object.keys(prevProps.tabs).length !== Object.keys(this.props.tabs).length) {
// eslint-disable-next-line react/no-did-update-set-state
this.setState({ activeTab: Object.keys(this.props.tabs)[0] });
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/js/components/dashboard/StockRequestDashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ class StockRequestDashboard extends Component {
this.props.fetchTranslations('', 'stockMovement');
}

componentWillReceiveProps(nextProps) {
if (this.props.locale && this.props.locale !== nextProps.locale) {
this.props.fetchTranslations(nextProps.locale, 'stockMovement');
componentDidUpdate(prevProps) {
if (prevProps.locale && prevProps.locale !== this.props.locale) {
this.props.fetchTranslations(this.props.locale, 'stockMovement');
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/js/components/invoice/create/InvoiceWizard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ class InvoiceWizard extends Component {
}
}

componentWillReceiveProps(nextProps) {
if (this.props.locale && this.props.locale !== nextProps.locale) {
this.props.fetchTranslations(nextProps.locale, 'invoice');
componentDidUpdate(prevProps) {
if (prevProps.locale && prevProps.locale !== this.props.locale) {
this.props.fetchTranslations(this.props.locale, 'invoice');
}

if (nextProps.invoiceTranslationsFetched && !this.dataFetched) {
if (this.props.invoiceTranslationsFetched && !this.dataFetched) {
this.dataFetched = true;
this.fetchInitialValues();
}
Expand Down
6 changes: 3 additions & 3 deletions src/js/components/load-demo-data/LoadDemoDataPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class LoadDemoDataPage extends Component {
});
}

componentWillReceiveProps(nextProps) {
if (this.props.locale && this.props.locale !== nextProps.locale) {
this.props.fetchTranslations(nextProps.locale, 'loadData');
componentDidUpdate(prevProps) {
if (prevProps.locale && prevProps.locale !== this.props.locale) {
this.props.fetchTranslations(this.props.locale, 'loadData');
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/js/components/locations-configuration/LocationDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ class LocationDetails extends Component {
}
}

componentWillReceiveProps(nextProps) {
if (!this.dataFetched && nextProps.locConfTranslationsFetched) {
componentDidUpdate() {
if (!this.dataFetched && this.props.locConfTranslationsFetched) {
this.dataFetched = true;
this.fetchSupportedActivities();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ class LocationsConfigurationWizard extends Component {
this.props.fetchTranslations('', 'locationsConfiguration');
}

componentWillReceiveProps(nextProps) {
if (this.props.locale && this.props.locale !== nextProps.locale) {
this.props.fetchTranslations(nextProps.locale, 'locationsConfiguration');
componentDidUpdate(prevProps) {
if (prevProps.locale && prevProps.locale !== this.props.locale) {
this.props.fetchTranslations(this.props.locale, 'locationsConfiguration');
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/js/components/locations-configuration/WelcomePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class WelcomePage extends Component {
this.props.fetchTranslations('', 'locationsConfiguration');
}

componentWillReceiveProps(nextProps) {
if (this.props.locale && this.props.locale !== nextProps.locale) {
this.props.fetchTranslations(nextProps.locale, 'locationsConfiguration');
componentDidUpdate(prevProps) {
if (prevProps.locale && prevProps.locale !== this.props.locale) {
this.props.fetchTranslations(this.props.locale, 'locationsConfiguration');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class ProductsConfigurationWizard extends Component {
this.props.fetchTranslations('', 'productsConfiguration');
}

componentWillReceiveProps(nextProps) {
if (this.props.locale && this.props.locale !== nextProps.locale) {
this.props.fetchTranslations(nextProps.locale, 'productsConfiguration');
componentDidUpdate(prevProps) {
if (prevProps.locale && prevProps.locale !== this.props.locale) {
this.props.fetchTranslations(this.props.locale, 'productsConfiguration');
}
}

Expand Down
34 changes: 19 additions & 15 deletions src/js/components/put-away/PutAwayCheckPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,25 @@ class PutAwayCheckPage extends Component {
this.save = this.save.bind(this);
}

componentWillReceiveProps(nextProps) {
showLocationChangedAlert(
this.props.translate, this.state.location, nextProps.location,
() => { window.location = `${ORDER_URL.list()}?orderType=PUTAWAY_ORDER&status=PENDING`; },
);

this.setState((prev) => ({
putAway: {
...nextProps.initialValues.putAway,
putawayItems: PutAwayCheckPage
.processSplitLines(nextProps.initialValues.putAway.putawayItems),
},
completed: nextProps.initialValues.putAway.putawayStatus === 'COMPLETED',
location: prev.location.id ? prev.location : nextProps.location,
}));
componentDidUpdate(prevProps) {
if (!_.isEqual(prevProps.initialValues, this.props.initialValues)
|| !_.isEqual(prevProps.location, this.props.location)) {
showLocationChangedAlert(
this.props.translate, this.state.location, this.props.location,
() => { window.location = `${ORDER_URL.list()}?orderType=PUTAWAY_ORDER&status=PENDING`; },
);

// eslint-disable-next-line react/no-did-update-set-state
this.setState((prev) => ({
putAway: {
...this.props.initialValues.putAway,
putawayItems: PutAwayCheckPage
.processSplitLines(this.props.initialValues.putAway.putawayItems),
},
completed: this.props.initialValues.putAway.putawayStatus === 'COMPLETED',
location: prev.location.id ? prev.location : this.props.location,
}));
}
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/js/components/put-away/PutAwayMainPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ class PutAwayMainPage extends Component {
}
}

componentWillReceiveProps(nextProps) {
if (this.props.locale && this.props.locale !== nextProps.locale) {
this.props.fetchTranslations(nextProps.locale, 'putAway');
componentDidUpdate(prevProps) {
if (prevProps.locale && prevProps.locale !== this.props.locale) {
this.props.fetchTranslations(this.props.locale, 'putAway');
}

if (nextProps.putAwayTranslationsFetched && !this.dataFetched) {
if (this.props.putAwayTranslationsFetched && !this.dataFetched) {
this.dataFetched = true;

this.fetchPutAway();
Expand Down
8 changes: 4 additions & 4 deletions src/js/components/put-away/PutAwayPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ class PutAwayPage extends Component {
}
}

componentWillReceiveProps(nextProps) {
if (nextProps.putAwayTranslationsFetched) {
componentDidUpdate(prevProps) {
if (this.props.putAwayTranslationsFetched) {
if (!this.dataFetched) {
this.dataFetched = true;

this.fetchPutAwayCandidates(this.props.locationId);
} else if (this.props.locationId !== nextProps.locationId) {
this.fetchPutAwayCandidates(nextProps.locationId);
} else if (prevProps.locationId !== this.props.locationId) {
this.fetchPutAwayCandidates(this.props.locationId);
}
}
}
Expand Down
Loading
Loading