Creating isEmpty function to check if dict/array have some contents.

This commit is contained in:
Roland 2022-11-04 09:58:38 -06:00
parent 92bd1de8a0
commit dad276d6ec
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
10 changed files with 189 additions and 159 deletions

View file

@ -1,5 +1,5 @@
import React, {useContext} from "react";
import {HelpPopup, humanFileSize, PageContainer, TabLinks, useTitle, WROLModeMessage} from "./Common";
import {HelpPopup, humanFileSize, isEmpty, PageContainer, TabLinks, useTitle, WROLModeMessage} from "./Common";
import {Route, Routes} from "react-router-dom";
import {getMapImportStatus, importMapFiles} from "../api";
import {
@ -131,7 +131,7 @@ class ManageMap extends React.Component {
this.setState({'ready': false});
const {files, selectedPaths} = this.state;
if (!selectedPaths || selectedPaths.length === 0) {
if (isEmpty(selectedPaths)) {
// No files are selected, import all.
let paths = [];
for (let i = 0; i < files.length; i++) {
@ -192,13 +192,13 @@ class ManageMap extends React.Component {
pending.length > 1 ? 'Importing...' : `Importing ${pending[0]}`
: null;
let disabled = dockerized || !files || files.length === 0 || import_running;
let disabled = dockerized || isEmpty(files) || import_running;
let importButton = <Button
primary
disabled={disabled}
onClick={this.import}
>
{selectedPaths.length > 0 ? 'Import Selected' : 'Import All'}
{!isEmpty(selectedPaths) ? 'Import Selected' : 'Import All'}
</Button>;
let rows;
@ -213,7 +213,7 @@ class ManageMap extends React.Component {
</Placeholder>
</TableCell>
</TableRow>;
} else if (files.length === 0) {
} else if (isEmpty(files)) {
rows = <TableRow>
<TableCell/><TableCell colSpan={5}>No PBF map files were found in <b>map/pbf</b></TableCell>
</TableRow>;