Skip to content

TagSpaces is an offline, open source, document manager with tagging support

settings dialog fixes improvements design changes

stanimirc77de9ded5a2
diff --git a/app/components/SplitButton.tsx b/app/components/SplitButton.tsx
new file mode 100644
index 000000000..073f4440a
--- /dev/null
+++ b/app/components/SplitButton.tsx
@@ -0,0 +1,118 @@
+import React from 'react';
+import Grid from '@material-ui/core/Grid';
+import Button from '@material-ui/core/Button';
+import ButtonGroup from '@material-ui/core/ButtonGroup';
+import ArrowDropDownIcon from '@material-ui/icons/ArrowDropDown';
+import ClickAwayListener from '@material-ui/core/ClickAwayListener';
+import Grow from '@material-ui/core/Grow';
+import Paper from '@material-ui/core/Paper';
+import Popper from '@material-ui/core/Popper';
+import MenuItem from '@material-ui/core/MenuItem';
+import MenuList from '@material-ui/core/MenuList';
+
+interface Props {
+ options: Array<any>;
+ selected: string;
+ onChange: (selected: string) => void;
+}
+
+/**
+ * https://material-ui.com/components/button-group/#split-button
+ * @param props
+ * @constructor
+ */
+export default function SplitButton(props: Props) {
+ const { options, selected, onChange } = props;
+ const [open, setOpen] = React.useState(false);
+ const anchorRef = React.useRef<HTMLDivElement>(null);
+ const sel = options.findIndex(option => option.key === selected);
+ const [selectedIndex, setSelectedIndex] = React.useState(sel);
+
+ const handleClick = () => {
+ console.info(`You clicked ${options[selectedIndex].key}`);
+ };
+
+ const handleMenuItemClick = (
+ event: React.MouseEvent<HTMLLIElement, MouseEvent>,
+ index: number
+ ) => {
+ setSelectedIndex(index);
+ onChange(options[index].key);
+ setOpen(false);
+ };
+
+ const handleToggle = () => {
+ setOpen(prevOpen => !prevOpen);
+ };
+
+ const handleClose = (event: React.MouseEvent<Document, MouseEvent>) => {
+ if (
+ anchorRef.current &&
+ anchorRef.current.contains(event.target as HTMLElement)
+ ) {
+ return;
+ }
+
+ setOpen(false);
+ };
+
+ return (
+ <Grid container direction="column" alignItems="center">
+ <Grid item xs={12}>
+ <ButtonGroup
+ variant="contained"
+ color="primary"
+ ref={anchorRef}
+ aria-label="split button"
+ >
+ <Button onClick={handleToggle}>{options[selectedIndex].value}</Button>
+ <Button
+ color="primary"
+ size="small"
+ aria-controls={open ? 'split-button-menu' : undefined}
+ aria-expanded={open ? 'true' : undefined}
+ aria-label="select merge strategy"
+ aria-haspopup="menu"
+ onClick={handleToggle}
+ >
+ <ArrowDropDownIcon />
+ </Button>
+ </ButtonGroup>
+ <Popper
+ open={open}
+ anchorEl={anchorRef.current}
+ role={undefined}
+ transition
+ disablePortal
+ >
+ {({ TransitionProps, placement }) => (
+ <Grow
+ {...TransitionProps}
+ style={{
+ transformOrigin:
+ placement === 'bottom' ? 'center top' : 'center bottom'
+ }}
+ >
+ <Paper>
+ {/*<ClickAwayListener onClickAway={handleClose}>*/}
+ <MenuList id="split-button-menu">
+ {options.map((option, index) => (
+ <MenuItem
+ key={option.key}
+ disabled={index === 2}
+ selected={index === selectedIndex}
+ onClick={event => handleMenuItemClick(event, index)}
+ >
+ {option.value}
+ </MenuItem>
+ ))}
+ </MenuList>
+ {/*</ClickAwayListener>*/}
+ </Paper>
+ </Grow>
+ )}
+ </Popper>
+ </Grid>
+ </Grid>
+ );
+}
diff --git a/app/locales/en/core.json b/app/locales/en/core.json
index 371fa46d8..020650ba3 100644
--- a/app/locales/en/core.json
+++ b/app/locales/en/core.json
@@ -397,9 +397,11 @@
"entrySizeSmall": "Compact mode",
"entrySizeNormal": "Default mode",
"entrySizeBig": "Large mode",
+ "singleClick": "Single Click",
"singleClickOpenInternally": "Single click opens file internally",
"singleClickOpenExternally": "Single click opens file externally",
"singleClickSelects": "Single click selects only",
+ "entriesSize": "Entries Size",
"parentDirNotInLocation": "Unable to navigate! Parent folder not in the current location.",
"mustContainTheseTags": "Must contain all of these tags",
"atLeastOneOfTheseTags": "At least one of these tags",
diff --git a/app/services/utils-io.ts b/app/services/utils-io.ts
index b47b462de..35cb7e36b 100644
--- a/app/services/utils-io.ts
+++ b/app/services/utils-io.ts
@@ -32,7 +32,6 @@ import {
// import { formatDateTime4Tag } from '../utils/misc';
import versionMeta from '../version.json';
import { Tag } from '../reducers/taglibrary';
-import { getLocation, Location, locationType } from '-/reducers/locations';
import { getThumbnailURLPromise } from '-/services/thumbsgenerator';
export interface FileSystemEntry {
@@ -69,7 +68,8 @@ export function enhanceDirectoryContent(
isCloudLocation,
showUnixHiddenEntries,
useGenerateThumbnails,
- showDirs = true
+ showDirs = true,
+ limit = undefined
) {
const directoryContent = [];
const tmbGenerationPromises = [];
@@ -85,6 +85,10 @@ export function enhanceDirectoryContent(
return true;
}
+ if (limit !== undefined && directoryContent.length >= limit) {
+ return true;
+ }
+
if (isCloudLocation) {
// eslint-disable-next-line no-param-reassign
entry.url = PlatformIO.getURLforPath(entry.path);