Skip to content

Commit

Permalink
chore: Remove unused/obsolete dependencies and code, render fewer HTM…
Browse files Browse the repository at this point in the history
…L tags (#2223)

* Remove unused react-svg-inline dependency

* Remove obsolete immutability-helper dependency

* Remove unused SvgWithModal component

* Remove unused `showReport` prop passed to ElementAllCheckbox

* Render SampleTaskInbox drag container only when shown

* Render SearchModal drag container only when shown
  • Loading branch information
maiwald authored Oct 22, 2024
1 parent 44556cd commit ab5b190
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 163 deletions.
57 changes: 24 additions & 33 deletions app/packs/src/apps/mydb/collections/CollectionTree.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { Button, OverlayTrigger, Tooltip } from 'react-bootstrap';
import update from 'immutability-helper';
import Aviator from 'aviator';
import CollectionStore from 'src/stores/alt/stores/CollectionStore';
import CollectionActions from 'src/stores/alt/actions/CollectionActions';
Expand Down Expand Up @@ -86,14 +85,10 @@ export default class CollectionTree extends React.Component {
let { sharedRoots, sharedToCollectionVisible } = this.state
sharedRoots = this.removeOrphanRoots(sharedRoots)

let labelledRoots = sharedRoots.map(e => {
return update(e, {
label: {
$set:
<span>{this.labelRoot('shared_to', e)}</span>
}
})
})
let labelledRoots = sharedRoots.map(e => ({
...e,
label: <span>{this.labelRoot('shared_to', e)}</span>
}));

let subTreeLabels = (
<div className="tree-view">
Expand All @@ -114,18 +109,16 @@ export default class CollectionTree extends React.Component {
let { remoteRoots, sharedWithCollectionVisible } = this.state
remoteRoots = this.removeOrphanRoots(remoteRoots)

let labelledRoots = remoteRoots.map(e => {
return update(e, {
label: {
$set:
<span>
{this.labelRoot('shared_by', e)}
{' '}
{this.labelRoot('shared_to', e)}
</span>
}
})
})
let labelledRoots = remoteRoots.map(e => ({
...e,
label: (
<span>
{this.labelRoot('shared_by', e)}
{' '}
{this.labelRoot('shared_to', e)}
</span>
)
}));

let subTreeLabels = (
<div className="tree-view">
Expand All @@ -149,18 +142,16 @@ export default class CollectionTree extends React.Component {
let { syncInRoots, syncCollectionVisible } = this.state
syncInRoots = this.removeOrphanRoots(syncInRoots)

let labelledRoots = syncInRoots.map(e => {
return update(e, {
label: {
$set:
<span>
{this.labelRoot('shared_by', e)}
{' '}
{this.labelRoot('shared_to', e)}
</span>
}
})
})
let labelledRoots = syncInRoots.map(e => ({
...e,
label: (
<span>
{this.labelRoot('shared_by', e)}
{' '}
{this.labelRoot('shared_to', e)}
</span>
)
}));

let subTreeLabels = (
<div className="tree-view">
Expand Down
2 changes: 0 additions & 2 deletions app/packs/src/apps/mydb/elements/Elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,13 @@ export default class Elements extends Component {
const { currentElement } = this.state;
const hasCurrentElement = currentElement !== null;

const showReport = currentElement?.type === 'report';
const listWidth = hasCurrentElement ? 5 : 12;

return (
<Row className='w-100'>
<Col xs={listWidth}>
<ElementsList
overview={!hasCurrentElement}
showReport={showReport}
/>
</Col>
{hasCurrentElement && (
Expand Down
4 changes: 1 addition & 3 deletions app/packs/src/apps/mydb/elements/list/ElementsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export default class ElementsList extends React.Component {
const {
visible, hidden, totalCheckedElements, totalElements
} = this.state;
const { overview, showReport } = this.props;
const { overview } = this.props;

const constEls = Immutable.Set([
'sample',
Expand Down Expand Up @@ -241,7 +241,6 @@ export default class ElementsList extends React.Component {
>
<ElementsTable
overview={overview}
showReport={showReport}
type={value}
genericEl={genericEl}
/>
Expand Down Expand Up @@ -282,5 +281,4 @@ export default class ElementsList extends React.Component {

ElementsList.propTypes = {
overview: PropTypes.bool.isRequired,
showReport: PropTypes.bool.isRequired,
};
4 changes: 1 addition & 3 deletions app/packs/src/apps/mydb/elements/list/ElementsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ export default class ElementsTable extends React.Component {

renderHeader = () => {
const { filterCreatedAt, ui } = this.state;
const { type, showReport, genericEl } = this.props;
const { type, genericEl } = this.props;
const { fromDate, toDate, userLabel } = ui;

let searchLabel = <span />;
Expand Down Expand Up @@ -576,7 +576,6 @@ export default class ElementsTable extends React.Component {
<ElementAllCheckbox
type={type}
ui={ui}
showReport={showReport}
/>
</div>
<div
Expand Down Expand Up @@ -701,7 +700,6 @@ ElementsTable.defaultProps = {

ElementsTable.propTypes = {
overview: PropTypes.bool.isRequired,
showReport: PropTypes.bool.isRequired,
type: PropTypes.string.isRequired,
// eslint-disable-next-line react/forbid-prop-types
genericEl: PropTypes.object,
Expand Down
101 changes: 0 additions & 101 deletions app/packs/src/components/common/SvgWithModal.js

This file was deleted.

5 changes: 4 additions & 1 deletion app/packs/src/components/sampleTaskInbox/SampleTaskInbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ const SampleTaskInbox = ({}) => {
};
const [_colProps1, singleScanDropRef] = useDrop(dropConfig(1));
const [_colProps2, doubleScanDropRef] = useDrop(dropConfig(2));

if (!sampleTasksStore.inboxVisible) return null;

const sendErrorNotification = (message) => {
const notification = {
title: message,
Expand Down Expand Up @@ -101,7 +104,7 @@ const SampleTaskInbox = ({}) => {
<Draggable handle=".modal-header" onDrag={handleDrag}>
<div>
<Modal
show={sampleTasksStore.inboxVisible}
show={true}
onHide={sampleTasksStore.hideSampleTaskInbox}
backdrop={false}
keyboard={false}
Expand Down
8 changes: 5 additions & 3 deletions app/packs/src/components/searchModal/SearchModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const SearchModal = () => {
const searchStore = useContext(StoreContext).search;
const [deltaPosition, setDeltaPosition] = useState({ x: 0, y: 0 });

if (!searchStore.searchModalVisible) return null;

let FormData = [
{
value: 'advanced',
Expand Down Expand Up @@ -73,7 +75,7 @@ const SearchModal = () => {
<Draggable handle=".modal-header" onDrag={handleDrag}>
<div>
<Modal
show={searchStore.searchModalVisible}
show={true}
onHide={() => searchStore.handleCancel()}
backdrop={false}
keyboard={false}
Expand All @@ -85,7 +87,7 @@ const SearchModal = () => {
transform: `translate(${deltaPosition.x}px, ${deltaPosition.y}px)`,
}}
>

<Modal.Header className="ps-0 border-bottom border-gray-600 bg-gray-300" closeButton>
<Stack direction="horizontal" className="draggable-modal-stack" gap={3}>
<Modal.Title className="draggable-modal-stack-title">
Expand Down Expand Up @@ -125,7 +127,7 @@ const SearchModal = () => {
</Button>
</Stack>
</Modal.Header>

<Modal.Body className="p-0">
<React.Suspense fallback={<Spinner />}>
<div className={`draggable-modal-form-container${minimizedClass}`}>
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"factory-bot": "^6.3.1",
"html2pdf.js": "^0.10.1",
"humps": "^2.0.1",
"immutability-helper": "^2.8.1",
"immutable": "^4.0.0-rc.12",
"jcampconverter": "^2.11.0",
"js-yaml": "^3.13.1",
Expand Down Expand Up @@ -91,7 +90,6 @@
"react-select": "^5.8.1",
"react-svg-file-zoom-pan": "0.1.5",
"react-svg-file-zoom-pan-latest": "npm:@complat/[email protected]",
"react-svg-inline": "^1.2.0",
"react-ui-tree": "3.1.0",
"react-vis": "1.12.1",
"reactflow": "^11.7.2",
Expand Down
16 changes: 1 addition & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9142,13 +9142,6 @@ ignore@^5.2.0:
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.0.tgz#6d3bac8fa7fe0d45d9f9be7bac2fc279577e345a"
integrity sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==

immutability-helper@^2.8.1:
version "2.9.1"
resolved "https://registry.npmjs.org/immutability-helper/-/immutability-helper-2.9.1.tgz"
integrity sha512-r/RmRG8xO06s/k+PIaif2r5rGc3j4Yhc01jSBfwPCXDLYZwp/yxralI37Df1mwmuzcCsen/E/ITKcTEvc1PQmQ==
dependencies:
invariant "^2.2.0"

immutable@^3.7.4:
version "3.8.2"
resolved "https://registry.npmjs.org/immutable/-/immutable-3.8.2.tgz"
Expand Down Expand Up @@ -9265,7 +9258,7 @@ interpret@^3.1.1:
resolved "https://registry.yarnpkg.com/interpret/-/interpret-3.1.1.tgz#5be0ceed67ca79c6c4bc5cf0d7ee843dcea110c4"
integrity sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ==

invariant@^2.2.0, invariant@^2.2.4:
invariant@^2.2.4:
version "2.2.4"
resolved "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz"
integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==
Expand Down Expand Up @@ -13191,13 +13184,6 @@ [email protected]:
d3 "^3.5.15"
prop-types "^15.6.2"

react-svg-inline@^1.2.0:
version "1.2.0"
resolved "https://registry.npmjs.org/react-svg-inline/-/react-svg-inline-1.2.0.tgz"
integrity sha1-oCv4Gg7XYV4xlKAUtY2YrqVSH9U=
dependencies:
classnames "^2.2.1"

react-test-renderer@^17.0.0:
version "17.0.2"
resolved "https://registry.npmjs.org/react-test-renderer/-/react-test-renderer-17.0.2.tgz"
Expand Down

0 comments on commit ab5b190

Please sign in to comment.