Skip to content

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

Improving usability

Ilian96d9f4d01d53
diff --git a/src/renderer/components/CommonIcons.tsx b/src/renderer/components/CommonIcons.tsx
index f3fb73d55..dc4ffa0c0 100644
--- a/src/renderer/components/CommonIcons.tsx
+++ b/src/renderer/components/CommonIcons.tsx
@@ -18,12 +18,17 @@
import React from 'react';
import KeyboardReturnIcon from '@mui/icons-material/KeyboardReturn';
+import MarkdownRawIcon from '@mui/icons-material/SimCardDownload';
export const ParentFolderIcon = (props) => (
<KeyboardReturnIcon style={{ transform: 'rotate(90deg)' }} />
// <ParentFolder {...props} />
);
+export const MarkdownFileIcon = (props) => (
+ <MarkdownRawIcon style={{ transform: 'scaleX(-1)' }} />
+);
+
export const NavigateToFolderIcon = (props) => <KeyboardReturnIcon />;
export { default as InfoTooltipIcon } from '@mui/icons-material/InfoOutlined';
@@ -139,3 +144,11 @@ export { default as DownloadIcon } from '@mui/icons-material/DownloadForOffline'
export { default as TagIcon } from '@mui/icons-material/LocalOffer';
export { default as IDIcon } from '@mui/icons-material/Abc';
+
+export { default as AudioFileIcon } from '@mui/icons-material/AudioFile';
+
+export { default as HTMLFileIcon } from '@mui/icons-material/Description';
+
+export { default as LinkFileIcon } from '@mui/icons-material/FileOpen';
+
+export { default as AccountIcon } from '@mui/icons-material/AccountCircle';
diff --git a/src/renderer/components/EntryProperties.tsx b/src/renderer/components/EntryProperties.tsx
index 53d662dfe..8c1fb433f 100644
--- a/src/renderer/components/EntryProperties.tsx
+++ b/src/renderer/components/EntryProperties.tsx
@@ -25,10 +25,7 @@ import React, {
} from 'react';
import { useSelector } from 'react-redux';
import { styled, useTheme } from '@mui/material/styles';
-import {
- getMetaFileLocationForFile,
- extractTitle,
-} from '@tagspaces/tagspaces-common/paths';
+import { extractTitle } from '@tagspaces/tagspaces-common/paths';
import L from 'leaflet';
import {
Grid,
@@ -43,18 +40,11 @@ import {
} from '@mui/material';
import Tooltip from '-/components/Tooltip';
import Stack from '@mui/material/Stack';
-import {
- LinkIcon,
- LocalLocationIcon,
- CloudLocationIcon,
- IDIcon,
-} from '-/components/CommonIcons';
import InfoIcon from '-/components/InfoIcon';
import QRCodeIcon from '@mui/icons-material/QrCode';
import ColorPaletteIcon from '@mui/icons-material/ColorLens';
import SetBackgroundIcon from '@mui/icons-material/OpacityOutlined';
import ClearBackgroundIcon from '@mui/icons-material/FormatColorResetOutlined';
-import RefreshIcon from '@mui/icons-material/Refresh';
import {
AttributionControl,
MapContainer,
@@ -580,6 +570,7 @@ function EntryProperties(props: Props) {
label={
openedEntry.isFile ? t('core:fileName') : t('core:folderName')
}
+ variant="filled"
InputProps={{
readOnly: editName === undefined,
endAdornment: (
@@ -591,6 +582,7 @@ function EntryProperties(props: Props) {
<Button
data-tid="cancelRenameEntryTID"
onClick={deactivateEditNameField}
+ size="small"
>
{t('core:cancel')}
</Button>
@@ -598,6 +590,7 @@ function EntryProperties(props: Props) {
data-tid="confirmRenameEntryTID"
color="primary"
onClick={renameEntry}
+ size="small"
disabled={disableConfirmButton.current}
>
{t('core:confirmSaveButton')}
@@ -607,6 +600,7 @@ function EntryProperties(props: Props) {
<Button
data-tid="startRenameEntryTID"
color="primary"
+ size="small"
onClick={activateEditNameField}
>
{t('core:rename')}
@@ -674,8 +668,8 @@ function EntryProperties(props: Props) {
width: '99%',
margin: 2,
marginTop: 8,
- borderRadius: 5,
- border: '1px solid rgba(0, 0, 0, 0.38)',
+ borderRadius: 3,
+ // border: '1px solid rgba(0, 0, 0, 0.38)',
}}
doubleClickZoom={true}
keyboard={false}
@@ -763,9 +757,10 @@ function EntryProperties(props: Props) {
)}
<Grid container item xs={12} spacing={1}>
- <Grid item xs={6}>
+ <Grid item xs={12}>
<TextField
margin="dense"
+ variant="filled"
fullWidth={true}
size={desktopMode ? 'small' : 'medium'}
value={ldtm}
@@ -775,7 +770,9 @@ function EntryProperties(props: Props) {
}}
/>
</Grid>
- <Grid item xs={6}>
+ </Grid>
+ <Grid container item xs={12} spacing={1}>
+ <Grid item xs={12}>
<Tooltip
title={
!location.haveObjectStoreSupport() &&
@@ -794,20 +791,24 @@ function EntryProperties(props: Props) {
margin="dense"
fullWidth={true}
value={fileSize()}
+ variant="filled"
size={desktopMode ? 'small' : 'medium'}
label={t('core:fileSize')}
InputProps={{
readOnly: true,
...(!openedEntry.isFile && {
endAdornment: (
- <RefreshIcon
+ <Button
+ size="small"
onClick={() =>
getOpenedDirProps().then((props) => {
dirProps.current = props;
forceUpdate();
})
}
- />
+ >
+ {t('core:calculate')}
+ </Button>
),
}),
}}
@@ -821,27 +822,28 @@ function EntryProperties(props: Props) {
<TextField
margin="dense"
name="path"
+ variant="filled"
title={openedEntry.url || openedEntry.path}
fullWidth={true}
- label={t('core:filePath')}
+ label={isCloudLocation ? t('cloudPath') : t('core:filePath')}
size={desktopMode ? 'small' : 'medium'}
data-tid="filePathProperties"
value={openedEntry.path || ''}
InputProps={{
readOnly: true,
- startAdornment: (
- <InputAdornment position="start">
- {isCloudLocation ? (
- <CloudLocationIcon
- style={{ color: theme.palette.text.secondary }}
- />
- ) : (
- <LocalLocationIcon
- style={{ color: theme.palette.text.secondary }}
- />
- )}
- </InputAdornment>
- ),
+ // startAdornment: (
+ // <InputAdornment position="start">
+ // {isCloudLocation ? (
+ // <CloudLocationIcon
+ // style={{ color: theme.palette.text.secondary }}
+ // />
+ // ) : (
+ // <LocalLocationIcon
+ // style={{ color: theme.palette.text.secondary }}
+ // />
+ // )}
+ // </InputAdornment>
+ // ),
endAdornment: (
<InputAdornment position="end">
{!readOnlyMode && !isEditMode && editName === undefined && (
@@ -849,6 +851,7 @@ function EntryProperties(props: Props) {
data-tid="moveCopyEntryTID"
color="primary"
onClick={toggleMoveCopyFilesDialog}
+ size="small"
>
{t('core:move')}
</Button>
@@ -864,37 +867,33 @@ function EntryProperties(props: Props) {
container
item
xs={12}
- spacing={1}
alignItems="center"
justifyContent="center"
>
- <Grid item xs={showLinkForDownloading ? 8 : 12}>
+ <Grid item xs={12}>
<TextField
data-tid="sharingLinkTID"
margin="dense"
+ variant="filled"
name="sharinglink"
size={desktopMode ? 'small' : 'medium'}
- label={
- <>
- {t('core:sharingLink')}
- <InfoIcon tooltip={t('core:sharingLinkTooltip')} />
- </>
- }
+ label={<>{t('core:sharingLink')}</>}
fullWidth={true}
value={sharingLink}
inputRef={sharingLinkRef}
InputProps={{
readOnly: true,
- startAdornment: (
- <InputAdornment position="start">
- <LinkIcon style={{ color: theme.palette.text.secondary }} />
- </InputAdornment>
- ),
+ // startAdornment: (
+ // <InputAdornment position="start">
+ // <LinkIcon style={{ color: theme.palette.text.secondary }} />
+ // </InputAdornment>
+ // ),
endAdornment: (
<InputAdornment position="end">
<Tooltip title={t('core:copyLinkToClipboard')}>
<Button
data-tid="copyLinkToClipboardTID"
+ size="small"
color="primary"
onClick={() => {
const entryTitle = extractTitle(
@@ -914,49 +913,40 @@ function EntryProperties(props: Props) {
{t('core:copy')}
</Button>
</Tooltip>
+ <InfoIcon tooltip={t('core:sharingLinkTooltip')} />
</InputAdornment>
),
}}
/>
</Grid>
-
{showLinkForDownloading && (
- <Grid item xs={4}>
+ <Grid item xs={12}>
<TextField
margin="dense"
name="downloadLink"
+ variant="filled"
size={desktopMode ? 'small' : 'medium'}
- label={
- <>
- {t('core:downloadLink')}
- <InfoIcon tooltip={t('core:downloadLinkTooltip')} />
- </>
- }
+ label={<>{t('core:downloadLink')}</>}
fullWidth
value={' '}
InputProps={{
readOnly: true,
- startAdornment: (
- <InputAdornment position="start" style={{ width: '100%' }}>
+ endAdornment: (
+ <InputAdornment position="end">
<Tooltip title={t('core:generateDownloadLink')}>
<Button
onClick={() => setShowSharingLinkDialog(true)}
+ size="small"
startIcon={
<QRCodeIcon
style={{ color: theme.palette.text.secondary }}
/>
}
>
- <span
- style={{
- overflow: 'hidden',
- textOverflow: 'ellipsis',
- }}
- >
- {t('core:generateDownloadLink')}
- </span>
+ {t('core:generateDownloadLink')}
</Button>
</Tooltip>
+ <InfoIcon tooltip={t('core:downloadLinkTooltip')} />
</InputAdornment>
),
}}
@@ -981,27 +971,20 @@ function EntryProperties(props: Props) {
<TextField
margin="dense"
name="path"
- label={
- <>
- {t('core:backgroundColor')}
- <InfoIcon
- tooltip={t(
- 'The background color will not be visible if you have set a background image',
- )}
- />
- </>
- }
+ variant="filled"
+ label={<>{t('core:backgroundColor')}</>}
fullWidth
InputProps={{
readOnly: true,
startAdornment: (
- <InputAdornment position="start" style={{ marginTop: 10 }}>
+ <InputAdornment position="start" style={{ marginTop: 14 }}>
<TransparentBackground>
<Tooltip title={t('editBackgroundColor')}>
<Button
fullWidth
style={{
- width: 140,
+ width: 160,
+ height: 25,
background: openedEntry.meta?.color,
}}
onClick={toggleBackgroundColorPicker}
@@ -1080,6 +1063,11 @@ function EntryProperties(props: Props) {
</ProTooltip>
</>
)}
+ <InfoIcon
+ tooltip={t(
+ 'The background color will not be visible if you have set a background image',
+ )}
+ />
</InputAdornment>
),
}}
@@ -1091,6 +1079,7 @@ function EntryProperties(props: Props) {
<ThumbnailTextField
margin="dense"
label={t('core:thumbnail')}
+ variant="filled"
fullWidth
InputProps={{
readOnly: true,
@@ -1098,7 +1087,7 @@ function EntryProperties(props: Props) {
<InputAdornment position="end">
<Stack
direction="column"
- spacing={1}
+ spacing={0}
style={{ alignItems: 'center' }}
>
{!readOnlyMode &&
@@ -1109,6 +1098,7 @@ function EntryProperties(props: Props) {
data-tid="changeThumbnailTID"
fullWidth
onClick={toggleThumbFilesDialog}
+ size="small"
>
{t('core:change')}
</Button>
@@ -1141,13 +1131,14 @@ function EntryProperties(props: Props) {
margin="dense"
label={t('core:backgroundImage')}
fullWidth
+ variant="filled"
InputProps={{
readOnly: true,
startAdornment: (
<InputAdornment position="end">
<Stack
direction="column"
- spacing={1}
+ spacing={0}
style={{ alignItems: 'center' }}
>
{!readOnlyMode &&
@@ -1158,6 +1149,7 @@ function EntryProperties(props: Props) {
data-tid="changeBackgroundImageTID"
fullWidth
onClick={toggleBgndImgDialog}
+ size="small"
>
{t('core:change')}
</Button>
@@ -1201,28 +1193,26 @@ function EntryProperties(props: Props) {
data-tid="entryIDTID"
margin="dense"
name="entryid"
+ variant="filled"
size={desktopMode ? 'small' : 'medium'}
- label={
- <>
- {t('core:entryId')}
- <InfoIcon tooltip={t('core:entryIdTooltip')} />
- </>
- }
+ label={t('core:entryId')}
fullWidth={true}
value={openedEntry?.meta?.id}
InputProps={{
readOnly: true,
- startAdornment: (
- <InputAdornment position="start">
- <IDIcon style={{ color: theme.palette.text.secondary }} />
- </InputAdornment>
- ),
+ // startAdornment: (
+ // <InputAdornment position="start">
+ // <InfoIcon tooltip={t('core:entryIdTooltip')} />
+ // {/* <IDIcon style={{ color: theme.palette.text.secondary }} /> */}
+ // </InputAdornment>
+ // ),
endAdornment: (
<InputAdornment position="end">
<Tooltip title={t('core:copyIdToClipboard')}>
<Button
data-tid="copyIdToClipboardTID"
color="primary"
+ size="small"
disabled={!openedEntry?.meta?.id}
onClick={() => {
const entryId = openedEntry?.meta?.id;
@@ -1240,6 +1230,7 @@ function EntryProperties(props: Props) {
{t('core:copy')}
</Button>
</Tooltip>
+ <InfoIcon tooltip={t('core:entryIdTooltip')} />
</InputAdornment>
),
}}
diff --git a/src/renderer/components/FileUploadContainer.tsx b/src/renderer/components/FileUploadContainer.tsx
index 5879fc767..7c5f3bdf8 100644
--- a/src/renderer/components/FileUploadContainer.tsx
+++ b/src/renderer/components/FileUploadContainer.tsx
@@ -16,9 +16,16 @@
*
*/
-import React, { forwardRef, Ref, useImperativeHandle, useRef } from 'react';
+import React, {
+ ChangeEvent,
+ forwardRef,
+ Ref,
+ useImperativeHandle,
+ useRef,
+} from 'react';
import { useDispatch } from 'react-redux';
import { TS } from '-/tagspaces.namespace';
+import AppConfig from '-/AppConfig';
import { actions as AppActions, AppDispatch } from '-/reducers/app';
import { useIOActionsContext } from '-/hooks/useIOActionsContext';
import { useEditedEntryMetaContext } from '-/hooks/useEditedEntryMetaContext';
@@ -27,29 +34,30 @@ import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
interface Props {
id?: string;
- directoryPath: string;
- //toggleProgressDialog: () => void;
+ //directoryPath: string;
}
export interface FileUploadContainerRef {
- onFileUpload: () => void;
+ onFileUpload: (directoryPath: string) => void;
}
const FileUploadContainer = forwardRef(
(props: Props, ref: Ref<FileUploadContainerRef>) => {
const dispatch: AppDispatch = useDispatch();
- const { id, directoryPath } = props;
+ const { id } = props;
const { findLocalLocation } = useCurrentLocationContext();
const { openFileUploadDialog } = useFileUploadDialogContext();
const { uploadFilesAPI } = useIOActionsContext();
const { setReflectMetaActions } = useEditedEntryMetaContext();
+ const directoryPath = useRef<string>(undefined);
const onUploadProgress = (progress, abort, fileName) => {
dispatch(AppActions.onUploadProgress(progress, abort, fileName));
};
useImperativeHandle(ref, () => ({
- onFileUpload() {
+ onFileUpload(dirPath: string) {
+ directoryPath.current = dirPath;
/* if (AppConfig.isCordovaAndroid) {
PlatformIO.selectFileDialog()
.then(file => {
@@ -88,16 +96,26 @@ const FileUploadContainer = forwardRef(
const fileInput = useRef<HTMLInputElement>(null);
- function handleFileInputChange(selection: any) {
+ function handleFileInputChange(selection: ChangeEvent<HTMLInputElement>) {
// console.log("Selected File: "+JSON.stringify(selection.currentTarget.files[0]));
// const file = selection.currentTarget.files[0];
dispatch(AppActions.resetProgress());
openFileUploadDialog();
const localLocation = findLocalLocation();
const sourceLocationId = localLocation ? localLocation.uuid : undefined;
+
+ let files = Array.from(selection.currentTarget.files);
+ if (AppConfig.isElectron) {
+ files = files.map((file) => {
+ if (!file.path) {
+ file.path = window.electronIO.ipcRenderer.getPathForFile(file);
+ }
+ return file;
+ });
+ }
uploadFilesAPI(
- Array.from(selection.currentTarget.files),
- directoryPath,
+ files,
+ directoryPath.current,
onUploadProgress,
true,
true,
diff --git a/src/renderer/components/InfoIcon.tsx b/src/renderer/components/InfoIcon.tsx
index 7db922631..727ed9adf 100644
--- a/src/renderer/components/InfoIcon.tsx
+++ b/src/renderer/components/InfoIcon.tsx
@@ -18,7 +18,9 @@
import React from 'react';
import { InfoTooltipIcon } from '-/components/CommonIcons';
+import NotListedLocationIcon from '@mui/icons-material/NotListedLocation';
import Tooltip from '-/components/Tooltip';
+import { opacity } from 'html2canvas/dist/types/css/property-descriptors/opacity';
interface Props {
tooltip?: string;
@@ -28,7 +30,7 @@ function InfoIcon(props: Props) {
const { tooltip } = props;
return (
<Tooltip title={tooltip}>
- <InfoTooltipIcon />
+ <NotListedLocationIcon style={{ opacity: '0.7' }} />
</Tooltip>
);
}
diff --git a/src/renderer/components/MobileNavigation.tsx b/src/renderer/components/MobileNavigation.tsx
index 10c1df782..19fffe63a 100644
--- a/src/renderer/components/MobileNavigation.tsx
+++ b/src/renderer/components/MobileNavigation.tsx
@@ -33,14 +33,21 @@ import RecentThingsIcon from '@mui/icons-material/BookmarksOutlined';
import HelpIcon from '@mui/icons-material/HelpOutline';
import { Divider } from '@mui/material';
import {
+ OpenLinkIcon,
OpenNewWindowIcon,
- AudioRecordIcon,
NewFileIcon,
NewFolderIcon,
LocalLocationIcon,
SettingsIcon,
+ CreateFileIcon,
+ MarkdownFileIcon,
+ AudioFileIcon,
+ HTMLFileIcon,
+ LinkFileIcon,
+ AccountIcon,
+ AddExistingFileIcon,
} from '-/components/CommonIcons';
-import AccountCircleIcon from '@mui/icons-material/AccountCircle';
+import InfoIcon from '-/components/InfoIcon';
import Popover from '@mui/material/Popover';
import { Pro } from '-/pro';
import CustomLogo from '-/components/CustomLogo';
@@ -57,7 +64,7 @@ import MenuItem from '@mui/material/MenuItem';
import MenuList from '@mui/material/MenuList';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
-import { AppDispatch } from '../reducers/app';
+import { AppDispatch } from '-/reducers/app';
import { ProLabel } from '-/components/HelperComponents';
import { actions as SettingsActions } from '-/reducers/settings';
import StoredSearches from '-/components/StoredSearches';
@@ -69,12 +76,14 @@ import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
import { createNewInstance } from '-/services/utils-io';
import { useCreateEditLocationDialogContext } from '-/components/dialogs/hooks/useCreateEditLocationDialogContext';
import { useCreateDirectoryDialogContext } from '-/components/dialogs/hooks/useCreateDirectoryDialogContext';
-import { useNewEntryDialogContext } from '-/components/dialogs/hooks/useNewEntryDialogContext';
import { useNewFileDialogContext } from '-/components/dialogs/hooks/useNewFileDialogContext';
import { useNewAudioDialogContext } from '-/components/dialogs/hooks/useNewAudioDialogContext';
import { useSettingsDialogContext } from '-/components/dialogs/hooks/useSettingsDialogContext';
import { usePanelsContext } from '-/hooks/usePanelsContext';
import { useUserContext } from '-/hooks/useUserContext';
+import { useFileUploadContext } from '-/hooks/useFileUploadContext';
+import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
+import { useLinkDialogContext } from '-/components/dialogs/hooks/useLinkDialogContext';
const PREFIX = 'MobileNavigation';
@@ -104,12 +113,14 @@ function MobileNavigation(props: Props) {
const dispatch: AppDispatch = useDispatch();
const { setSelectedLocation } = useCurrentLocationContext();
- const { openNewEntryDialog } = useNewEntryDialogContext();
+ const { currentDirectoryPath } = useDirectoryContentContext();
+ const { openFileUpload } = useFileUploadContext();
const { openCreateEditLocationDialog } = useCreateEditLocationDialogContext();
const { openCreateDirectoryDialog } = useCreateDirectoryDialogContext();
const { openNewFileDialog } = useNewFileDialogContext();
const { openNewAudioDialog } = useNewAudioDialogContext();
const { openSettingsDialog } = useSettingsDialogContext();
+ const { openLinkDialog } = useLinkDialogContext();
const { currentOpenedPanel, showPanel } = usePanelsContext();
const keyBindings = useSelector(getKeyBindingObject);
/* const isLocationManagerPanelOpenedSelector = useSelector(
@@ -185,20 +196,6 @@ function MobileNavigation(props: Props) {
}}
>
<Button
- size="small"
- data-tid="createNewFileTID"
- onClick={() => {
- openNewEntryDialog();
- if (hideDrawer) {
- hideDrawer();
- }
- }}
- >
- {t('core:createNewFile')}
- </Button>
-
- <Button
- size="small"
aria-controls={
openedCreateMenu ? 'split-button-menu' : undefined
}
@@ -206,9 +203,24 @@ function MobileNavigation(props: Props) {
aria-haspopup="menu"
data-tid="createNewDropdownButtonTID"
onClick={handleToggle}
+ size="small"
+ startIcon={<CreateFileIcon />}
+ // endIcon={<ArrowDropDownIcon />}
>
- <ArrowDropDownIcon />
+ {t('core:createNew')}
</Button>
+ <Tooltip title={t('core:openSharingLink')}>
+ <Button
+ size="small"
+ data-tid="openLinkTID"
+ onClick={() => {
+ openLinkDialog();
+ }}
+ startIcon={<OpenLinkIcon />}
+ >
+ {t('core:openLink')}
+ </Button>
+ </Tooltip>
</ButtonGroup>
</Box>
</Box>
@@ -233,31 +245,11 @@ function MobileNavigation(props: Props) {
<Paper>
<ClickAwayListener onClickAway={handleClose}>
<MenuList id="split-button-menu" autoFocusItem>
- {!AppConfig.isCordova && (
- <>
- <MenuItem
- key="createWindowTID"
- ata-tid="createWindowTID"
- onClick={() => {
- createNewInstance();
- setOpenCreateMenu(false);
- }}
- >
- <ListItemIcon>
- <OpenNewWindowIcon />
- </ListItemIcon>
- <ListItemText
- primary={t('core:newWindow')}
- ></ListItemText>
- </MenuItem>
- <Divider />
- </>
- )}
<MenuItem
key="createNewTextFileTID"
ata-tid="createNewTextFileTID"
onClick={() => {
- openNewFileDialog();
+ openNewFileDialog('txt');
setOpenCreateMenu(false);
if (hideDrawer) {
hideDrawer();
@@ -270,10 +262,10 @@ function MobileNavigation(props: Props) {
<ListItemText primary={t('core:createTextFile')} />
</MenuItem>
<MenuItem
- key="createNewFolderTID"
- ata-tid="createNewFolderTID"
+ key="createNewMarkdownFileTID"
+ ata-tid="createNewMarkdownFileTID"
onClick={() => {
- openCreateDirectoryDialog();
+ openNewFileDialog('md');
setOpenCreateMenu(false);
if (hideDrawer) {
hideDrawer();
@@ -281,11 +273,43 @@ function MobileNavigation(props: Props) {
}}
>
<ListItemIcon>
- <NewFolderIcon />
+ <MarkdownFileIcon />
</ListItemIcon>
- <ListItemText
- primary={t('core:createNewDirectoryTitle')}
- />
+ <ListItemText primary={t('core:createMarkdown')} />
+ <InfoIcon tooltip={t('core:createMarkdownTitle')} />
+ </MenuItem>
+ <MenuItem
+ key="createHTMLTextFileTID"
+ data-tid="createHTMLTextFileTID"
+ onClick={() => {
+ openNewFileDialog('html');
+ setOpenCreateMenu(false);
+ if (hideDrawer) {
+ hideDrawer();
+ }
+ }}
+ >
+ <ListItemIcon>
+ <HTMLFileIcon />
+ </ListItemIcon>
+ <ListItemText primary={t('core:createRichTextFile')} />
+ <InfoIcon tooltip={t('core:createNoteTitle')} />
+ </MenuItem>
+ <MenuItem
+ key="createNewLinkFileTID"
+ data-tid="createNewLinkFileTID"
+ onClick={() => {
+ openNewFileDialog('url');
+ setOpenCreateMenu(false);
+ if (hideDrawer) {
+ hideDrawer();
+ }
+ }}
+ >
+ <ListItemIcon>
+ <LinkFileIcon />
+ </ListItemIcon>
+ <ListItemText primary={t('core:createLinkFile')} />
</MenuItem>
<MenuItem
key="createNewAudio"
@@ -300,7 +324,7 @@ function MobileNavigation(props: Props) {
}}
>
<ListItemIcon>
- <AudioRecordIcon />
+ <AudioFileIcon />
</ListItemIcon>
<ListItemText
primary={
@@ -312,6 +336,40 @@ function MobileNavigation(props: Props) {
/>
</MenuItem>
<Divider />
+ <MenuItem
+ key="addUploadFilesTID"
+ data-tid="addUploadFilesTID"
+ onClick={() => {
+ openFileUpload(currentDirectoryPath);
+ setOpenCreateMenu(false);
+ if (hideDrawer) {
+ hideDrawer();
+ }
+ }}
+ >
+ <ListItemIcon>
+ <AddExistingFileIcon />
+ </ListItemIcon>
+ <ListItemText primary={t('core:addFiles')} />
+ </MenuItem>
+ <Divider />
+ <MenuItem
+ key="createNewFolderTID"
+ ata-tid="createNewFolderTID"
+ onClick={() => {
+ openCreateDirectoryDialog();
+ setOpenCreateMenu(false);
+ if (hideDrawer) {
+ hideDrawer();
+ }
+ }}
+ >
+ <ListItemIcon>
+ <NewFolderIcon />
+ </ListItemIcon>
+ <ListItemText primary={t('core:createDirectory')} />
+ </MenuItem>
+ <Divider />
<MenuItem
key="createNewLocationTID"
ata-tid="createNewFolderTID"
@@ -327,8 +385,28 @@ function MobileNavigation(props: Props) {
<ListItemIcon>
<LocalLocationIcon />
</ListItemIcon>
- <ListItemText primary={t('core:createLocationTitle')} />
+ <ListItemText primary={t('core:createLocation')} />
</MenuItem>
+ {!AppConfig.isCordova && (
+ <>
+ {/* <Divider /> */}
+ <MenuItem
+ key="createWindowTID"
+ ata-tid="createWindowTID"
+ onClick={() => {
+ createNewInstance();
+ setOpenCreateMenu(false);
+ }}
+ >
+ <ListItemIcon>
+ <OpenNewWindowIcon />
+ </ListItemIcon>
+ <ListItemText
+ primary={t('core:newWindow')}
+ ></ListItemText>
+ </MenuItem>
+ </>
+ )}
</MenuList>
</ClickAwayListener>
</Paper>
@@ -449,7 +527,7 @@ function MobileNavigation(props: Props) {
style={{ marginTop: -15, marginRight: 2 }}
size="large"
>
- <AccountCircleIcon />
+ <AccountIcon />
</IconButton>
</Tooltip>
<Popover
diff --git a/src/renderer/components/PerspectiveSelector.tsx b/src/renderer/components/PerspectiveSelector.tsx
index 92aa96ca7..a46a23b13 100644
--- a/src/renderer/components/PerspectiveSelector.tsx
+++ b/src/renderer/components/PerspectiveSelector.tsx
@@ -83,6 +83,7 @@ function PerspectiveSelector(props: Props) {
<TextField
data-tid={testId}
defaultValue={defaultValue}
+ variant="filled"
onChange={onChange}
select
label={label}
diff --git a/src/renderer/components/TagsSelect.tsx b/src/renderer/components/TagsSelect.tsx
index bccf227c4..f7757267a 100644
--- a/src/renderer/components/TagsSelect.tsx
+++ b/src/renderer/components/TagsSelect.tsx
@@ -200,7 +200,7 @@ function TagsSelect(props: Props) {
<>
<TextField
{...params}
- // variant="filled"
+ variant="filled"
label={label}
placeholder={placeholderText}
margin="normal"
diff --git a/src/renderer/components/TransparentBackground.tsx b/src/renderer/components/TransparentBackground.tsx
index adb80ac85..c8eb56c36 100644
--- a/src/renderer/components/TransparentBackground.tsx
+++ b/src/renderer/components/TransparentBackground.tsx
@@ -25,6 +25,7 @@ function TransparentBackground(props: Props) {
return (
<span
style={{
+ minHeight: 25,
borderRadius: 5,
background:
'url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAMUlEQVQ4T2NkYGAQYcAP3uCTZhw1gGGYhAGBZIA/nYDCgBDAm9BGDWAAJyRCgLaBCAAgXwixzAS0pgAAAABJRU5ErkJggg==")',
diff --git a/src/renderer/components/dialogs/CreateDirectoryDialog.tsx b/src/renderer/components/dialogs/CreateDirectoryDialog.tsx
index 9275c1949..9ab02cc01 100644
--- a/src/renderer/components/dialogs/CreateDirectoryDialog.tsx
+++ b/src/renderer/components/dialogs/CreateDirectoryDialog.tsx
@@ -16,15 +16,24 @@
*
*/
-import React, { useState, useEffect, useRef } from 'react';
-import Button from '@mui/material/Button';
-import TextField from '@mui/material/TextField';
-import DialogActions from '@mui/material/DialogActions';
-import DialogContent from '@mui/material/DialogContent';
-import DialogTitle from '@mui/material/DialogTitle';
-import FormControl from '@mui/material/FormControl';
-import FormHelperText from '@mui/material/FormHelperText';
-import Dialog from '@mui/material/Dialog';
+import React, { useState, useEffect, useRef, useReducer } from 'react';
+import { styled, useTheme } from '@mui/material/styles';
+import {
+ Dialog,
+ DialogActions,
+ FormControl,
+ DialogContent,
+ TextField,
+ DialogTitle,
+ Button,
+ FormHelperText,
+ IconButton,
+ FormLabel,
+ Box,
+ InputAdornment,
+ inputBaseClasses,
+} from '@mui/material';
+import SetBackgroundIcon from '@mui/icons-material/OpacityOutlined';
import { joinPaths } from '@tagspaces/tagspaces-common/paths';
import DialogCloseButton from '-/components/dialogs/DialogCloseButton';
import { useTranslation } from 'react-i18next';
@@ -32,6 +41,14 @@ import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
import { useIOActionsContext } from '-/hooks/useIOActionsContext';
import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
import { useNotificationContext } from '-/hooks/useNotificationContext';
+import { TS } from '-/tagspaces.namespace';
+import { dirNameValidation } from '-/services/utils-io';
+
+const FolderColorTextField = styled(TextField)(({ theme }) => ({
+ [`& .${inputBaseClasses.root}`]: {
+ height: 100,
+ },
+}));
interface Props {
open: boolean;
@@ -42,29 +59,62 @@ interface Props {
function CreateDirectoryDialog(props: Props) {
const { t } = useTranslation();
- const { createDirectory } = useIOActionsContext();
+ const { createDirectory, setBackgroundColorChange } = useIOActionsContext();
const { currentLocation } = useCurrentLocationContext();
- const { currentDirectoryPath } = useDirectoryContentContext();
+ const { currentDirectoryPath, getAllPropertiesPromise } =
+ useDirectoryContentContext();
const { showNotification } = useNotificationContext();
const [inputError, setInputError] = useState(false);
- const isFirstRun = useRef(true);
+ //const isFirstRun = useRef(true);
+ const backgroundColor = useRef<string>('transparent');
const [disableConfirmButton, setDisableConfirmButton] = useState(true);
const [name, setName] = useState('');
+
+ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);
const { open, onClose, selectedDirectoryPath } = props;
- useEffect(() => {
+ /*useEffect(() => {
if (isFirstRun.current) {
isFirstRun.current = false;
return;
}
handleValidation();
- });
+ });*/
+
+ const defaultBackgrounds = [
+ 'transparent',
+ // '#00000044',
+ '#ac725e44',
+ '#f83a2244',
+ // '#ff753744',
+ '#ffad4644',
+ '#42d69244',
+ // '#00800044',
+ '#7bd14844',
+ '#fad16544',
+ '#92e1c044',
+ '#9fe1e744',
+ '#9fc6e744',
+ // '#4986e744',
+ // '#9a9cff44',
+ // '#c2c2c244',
+ // '#cca6ac44',
+ // '#f691b244',
+ // '#cd74e644',
+ // '#a47ae244',
+ // '#845EC260',
+ // '#D65DB160',
+ // '#FF6F9160',
+ // '#FF967160',
+ // '#FFC75F60',
+ // '#F9F87160',
+ // '#008E9B60',
+ // '#008F7A60',
+ ];
- function handleValidation() {
- // const pathRegex = '^((\.\./|[a-zA-Z0-9_/\-\\])*\.[a-zA-Z0-9]+)$';
- // const nameRegex = '^[A-Z][-a-zA-Z]+$';
- if (name.length > 0) {
+ function handleValidation(dirName) {
+ if (!dirNameValidation(dirName)) {
setInputError(false);
setDisableConfirmButton(false);
} else {
@@ -74,6 +124,7 @@ function CreateDirectoryDialog(props: Props) {
}
function onConfirm() {
+ handleValidation(name);
if (!disableConfirmButton && name) {
const dirPath = joinPaths(
currentLocation.getDirSeparator(),
@@ -88,6 +139,12 @@ function CreateDirectoryDialog(props: Props) {
if (props.callback) {
props.callback(dirPath);
}
+ if (backgroundColor.current !== 'transparent') {
+ getAllPropertiesPromise(dirPath).then(
+ (fsEntry: TS.FileSystemEntry) =>
+ setBackgroundColorChange(fsEntry, backgroundColor.current),
+ );
+ }
});
} else {
showNotification('Directory ' + dirPath + ' exist!');
@@ -120,13 +177,13 @@ function CreateDirectoryDialog(props: Props) {
keepMounted
scroll="paper"
onKeyDown={(event) => {
- if (event.key === 'Enter' || event.keyCode === 13) {
+ if (event.key === 'Enter') {
event.preventDefault();
event.stopPropagation();
onConfirm();
- } /*else if (event.key === 'Escape') {
+ } else if (event.key === 'Escape') {
onClose();
- }*/
+ }
}}
>
<DialogTitle>
@@ -138,19 +195,65 @@ function CreateDirectoryDialog(props: Props) {
<TextField
fullWidth
error={inputError}
+ variant="filled"
margin="dense"
autoFocus
name="name"
- label={t('core:createNewDirectoryTitleName')}
+ label={t('core:folderName')}
onChange={(event) => {
const { target } = event;
+ handleValidation(target.value);
setName(target.value);
}}
value={name}
data-tid="directoryName"
id="directoryName"
/>
- <FormHelperText>{t('core:directoryNameHelp')}</FormHelperText>
+ {inputError && (
+ <FormHelperText>{t('core:directoryNameHelp')}</FormHelperText>
+ )}
+ </FormControl>
+ <FormControl>
+ <FolderColorTextField
+ data-tid="folderColorTID"
+ margin="dense"
+ variant="filled"
+ size="medium"
+ label={t('backgroundColor')}
+ fullWidth={true}
+ value={' '}
+ style={{ height: 100 }}
+ InputProps={{
+ readOnly: true,
+ endAdornment: (
+ <InputAdornment position="end">
+ {defaultBackgrounds.map((background, cnt) => (
+ <>
+ <IconButton
+ key={cnt}
+ data-tid={'bgTID' + cnt}
+ aria-label="changeFolderBackground"
+ onClick={() => {
+ backgroundColor.current = background;
+ forceUpdate();
+ }}
+ style={{
+ backgroundColor: background,
+ backgroundImage: background,
+ margin: 5,
+ ...(backgroundColor.current === background && {
+ border: '0.5rem outset ' + background,
+ }),
+ }}
+ >
+ <SetBackgroundIcon />
+ </IconButton>
+ </>
+ ))}
+ </InputAdornment>
+ ),
+ }}
+ />
</FormControl>
</DialogContent>
<DialogActions>
diff --git a/src/renderer/components/dialogs/NewEntryDialog.tsx b/src/renderer/components/dialogs/NewEntryDialog.tsx
index b59536371..a8e6dc265 100644
--- a/src/renderer/components/dialogs/NewEntryDialog.tsx
+++ b/src/renderer/components/dialogs/NewEntryDialog.tsx
@@ -1,4 +1,5 @@
-/**
+/*
+/!**
* TagSpaces - universal file and folder organizer
* Copyright (C) 2017-present TagSpaces GmbH
*
@@ -14,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
- */
+ *!/
import React from 'react';
import Typography from '@mui/material/Typography';
@@ -97,3 +98,4 @@ function NewEntryDialog(props: Props) {
}
export default NewEntryDialog;
+*/
diff --git a/src/renderer/components/dialogs/NewFileDialog.tsx b/src/renderer/components/dialogs/NewFileDialog.tsx
index 64183eeed..10346d4cc 100644
--- a/src/renderer/components/dialogs/NewFileDialog.tsx
+++ b/src/renderer/components/dialogs/NewFileDialog.tsx
@@ -16,7 +16,11 @@
*
*/
-import React from 'react';
+import React, { useReducer, useRef } from 'react';
+import {
+ locationType,
+ formatDateTime4Tag,
+} from '@tagspaces/tagspaces-common/misc';
import DialogContent from '@mui/material/DialogContent';
import DialogTitle from '@mui/material/DialogTitle';
import Dialog from '@mui/material/Dialog';
@@ -27,49 +31,174 @@ import { useTheme } from '@mui/material/styles';
import useMediaQuery from '@mui/material/useMediaQuery';
import CreateFile from '-/components/dialogs/components/CreateFile';
import TargetPath from '-/components/dialogs/components/TargetPath';
-import { TargetPathContextProvider } from '-/components/dialogs/hooks/TargetPathContextProvider';
import { useTranslation } from 'react-i18next';
+import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
+import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
+import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
+import { useTargetPathContext } from '-/components/dialogs/hooks/useTargetPathContext';
+import Button from '@mui/material/Button';
+import DialogActions from '@mui/material/DialogActions';
+import AppConfig from '-/AppConfig';
+import versionMeta from '-/version.json';
+import { TS } from '-/tagspaces.namespace';
+import CreateLink from '-/components/dialogs/components/CreateLink';
interface Props {
open: boolean;
onClose: (event?: Object, reason?: string) => void;
+ fileType?: TS.FileType;
}
function NewFileDialog(props: Props) {
- const { open, onClose } = props;
+ const { open, onClose, fileType } = props;
const { t } = useTranslation();
+ const { createFileAdvanced } = useOpenedEntryContext();
+ const { currentLocation, openLocation, getFirstRWLocation } =
+ useCurrentLocationContext();
+ const { currentDirectoryPath } = useDirectoryContentContext();
+ const { targetDirectoryPath } = useTargetPathContext();
+ const firstRWLocation = getFirstRWLocation();
+
+ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);
const theme = useTheme();
const fullScreen = useMediaQuery(theme.breakpoints.down('md'));
+ const fileName = useRef<string>(
+ (fileType === 'url' ? 'link' : 'note') +
+ AppConfig.beginTagContainer +
+ formatDateTime4Tag(new Date(), true) +
+ AppConfig.endTagContainer,
+ );
+
+ const haveError = useRef<boolean>(false);
+ const fileContent = useRef<string>(
+ fileType === 'txt' || fileType === 'md'
+ ? 'Created in ' +
+ versionMeta.name +
+ ' on ' +
+ new Date().toISOString().substring(0, 10) +
+ '.'
+ : '',
+ );
+
+ function getFileType() {
+ if (fileType === 'txt') {
+ return t('createTXTFile');
+ }
+ if (fileType === 'md') {
+ return t('createMarkdown');
+ }
+ if (fileType === 'html') {
+ return t('createRichTextFile');
+ }
+ if (fileType === 'url') {
+ return t('createLinkFile');
+ }
+ return '...';
+ }
+
+ function loadLocation() {
+ const isCloudLocation =
+ currentLocation && currentLocation.type === locationType.TYPE_CLOUD;
+ // no currentDirectoryPath in root cloud location
+ if (!isCloudLocation && !currentDirectoryPath && firstRWLocation) {
+ openLocation(firstRWLocation);
+ }
+ }
+
+ function createFile(fileType, targetPath) {
+ if (targetPath) {
+ loadLocation();
+ createFileAdvanced(
+ targetPath,
+ fileName.current,
+ fileContent.current,
+ fileType,
+ );
+ onClose();
+ }
+ }
+
return (
- <TargetPathContextProvider>
- <Dialog
- open={open}
- onClose={onClose}
- fullScreen={fullScreen}
- keepMounted
- aria-labelledby="draggable-dialog-title"
- PaperComponent={fullScreen ? Paper : DraggablePaper}
- scroll="paper"
+ <Dialog
+ open={open}
+ onClose={onClose}
+ fullScreen={fullScreen}
+ keepMounted
+ aria-labelledby="draggable-dialog-title"
+ PaperComponent={fullScreen ? Paper : DraggablePaper}
+ scroll="paper"
+ >
+ <DialogTitle style={{ cursor: 'move' }} id="draggable-dialog-title">
+ {getFileType()}
+ <DialogCloseButton testId="closeCreateDialogTID" onClose={onClose} />
+ </DialogTitle>
+ <DialogContent
+ style={{
+ minWidth: 200,
+ minHeight: 200,
+ marginBottom: 20,
+ overflow: 'overlay',
+ }}
+ data-tid="newFileDialog"
>
- <DialogTitle style={{ cursor: 'move' }} id="draggable-dialog-title">
- {t('core:create') + '...'}
- <DialogCloseButton testId="closeCreateDialogTID" onClose={onClose} />
- </DialogTitle>
- <DialogContent
- style={{
- minWidth: 200,
- minHeight: 200,
- marginBottom: 20,
- overflow: 'overlay',
- }}
- data-tid="newFileDialog"
+ {fileType === 'url' ? (
+ <CreateLink
+ createFile={(type) => createFile(type, targetDirectoryPath)}
+ handleFileNameChange={(name) => (fileName.current = name)}
+ handleFileContentChange={(content) =>
+ (fileContent.current = content)
+ }
+ haveError={(error) => {
+ haveError.current = error;
+ forceUpdate();
+ }}
+ fileName={fileName.current}
+ />
+ ) : (
+ <CreateFile
+ fileType={fileType}
+ createFile={(type) => createFile(type, targetDirectoryPath)}
+ handleFileNameChange={(name) => (fileName.current = name)}
+ handleFileContentChange={(content) =>
+ (fileContent.current = content)
+ }
+ haveError={(error) => {
+ haveError.current = error;
+ forceUpdate();
+ }}
+ fileName={fileName.current}
+ />
+ )}
+ <TargetPath />
+ </DialogContent>
+ {fileType && (
+ <DialogActions
+ style={fullScreen ? { padding: '10px 30px 30px 30px' } : {}}
>
- <CreateFile onClose={onClose} />
- <TargetPath />
- </DialogContent>
- </Dialog>
- </TargetPathContextProvider>
+ <Button
+ data-tid="backTID"
+ onClick={() => {
+ onClose();
+ }}
+ color="primary"
+ >
+ {t('core:cancel')}
+ </Button>
+ <Button
+ data-tid="createTID"
+ variant="contained"
+ onClick={() => {
+ createFile(fileType, targetDirectoryPath);
+ }}
+ color="primary"
+ disabled={haveError.current}
+ >
+ {t('core:ok')}
+ </Button>
+ </DialogActions>
+ )}
+ </Dialog>
);
}
diff --git a/src/renderer/components/dialogs/OpenLinkDialog.tsx b/src/renderer/components/dialogs/OpenLinkDialog.tsx
index 81045e507..6e29851d2 100644
--- a/src/renderer/components/dialogs/OpenLinkDialog.tsx
+++ b/src/renderer/components/dialogs/OpenLinkDialog.tsx
@@ -90,7 +90,6 @@ function OpenLinkDialog(props: Props) {
<Dialog
open={open}
onClose={onClose}
- style={{ minWidth: 300 }}
// fullScreen={fullScreen}
onKeyDown={(event) => {
if (event.key === 'Enter' || event.keyCode === 13) {
@@ -104,7 +103,7 @@ function OpenLinkDialog(props: Props) {
{t('core:openLink')}
<DialogCloseButton testId="closeOpenLinkTID" onClose={onClose} />
</DialogTitle>
- <DialogContent>
+ <DialogContent style={{ minWidth: 300 }}>
<FormControl fullWidth={true} error={inputError}>
<TextField
fullWidth
diff --git a/src/renderer/components/dialogs/components/CreateDirectory.tsx b/src/renderer/components/dialogs/components/CreateDirectory.tsx
index bf9e9fe3d..acc2632ec 100644
--- a/src/renderer/components/dialogs/components/CreateDirectory.tsx
+++ b/src/renderer/components/dialogs/components/CreateDirectory.tsx
@@ -29,9 +29,6 @@ import Tooltip from '-/components/Tooltip';
import TextField from '@mui/material/TextField';
import { useTargetPathContext } from '-/components/dialogs/hooks/useTargetPathContext';
import Typography from '@mui/material/Typography';
-import FileUploadContainer, {
- FileUploadContainerRef,
-} from '-/components/FileUploadContainer';
import { useTranslation } from 'react-i18next';
import { useIOActionsContext } from '-/hooks/useIOActionsContext';
import { useNotificationContext } from '-/hooks/useNotificationContext';
@@ -42,6 +39,7 @@ import { useFileUploadDialogContext } from '-/components/dialogs/hooks/useFileUp
import { useCreateEditLocationDialogContext } from '-/components/dialogs/hooks/useCreateEditLocationDialogContext';
import { useCreateDirectoryDialogContext } from '-/components/dialogs/hooks/useCreateDirectoryDialogContext';
import { useNewAudioDialogContext } from '-/components/dialogs/hooks/useNewAudioDialogContext';
+import { useFileUploadContext } from '-/hooks/useFileUploadContext';
const PREFIX = 'CreateDirectory';
@@ -71,7 +69,7 @@ function CreateDirectory(props: Props) {
const { openCreateEditLocationDialog } = useCreateEditLocationDialogContext();
const { openCreateDirectoryDialog } = useCreateDirectoryDialogContext();
const { openNewAudioDialog } = useNewAudioDialogContext();
- const fileUploadContainerRef = useRef<FileUploadContainerRef>(null);
+ const { openFileUpload } = useFileUploadContext();
const dispatch: AppDispatch = useDispatch();
const { targetDirectoryPath } = useTargetPathContext();
@@ -87,8 +85,7 @@ function CreateDirectory(props: Props) {
}*/
function addFile() {
- // loadLocation();
- fileUploadContainerRef.current.onFileUpload();
+ openFileUpload(targetDirectoryPath);
onClose();
}
@@ -264,11 +261,6 @@ function CreateDirectory(props: Props) {
</Button>
</ButtonGroup>
</Grid>
- <FileUploadContainer
- id="createDirId"
- ref={fileUploadContainerRef}
- directoryPath={targetDirectoryPath}
- />
</Root>
);
}
diff --git a/src/renderer/components/dialogs/components/CreateFile.tsx b/src/renderer/components/dialogs/components/CreateFile.tsx
index cbace1f86..43559a340 100644
--- a/src/renderer/components/dialogs/components/CreateFile.tsx
+++ b/src/renderer/components/dialogs/components/CreateFile.tsx
@@ -16,17 +16,12 @@
*
*/
-import React, { useReducer, useRef, useState } from 'react';
+import React, { useEffect, useReducer, useState } from 'react';
import { styled } from '@mui/material/styles';
import Button from '@mui/material/Button';
import ButtonGroup from '@mui/material/ButtonGroup';
import Typography from '@mui/material/Typography';
import Grid from '@mui/material/Grid';
-import {
- formatDateTime4Tag,
- locationType,
-} from '@tagspaces/tagspaces-common/misc';
-import AppConfig from '-/AppConfig';
import Tooltip from '-/components/Tooltip';
import TextField from '@mui/material/TextField';
import FormHelperText from '@mui/material/FormHelperText';
@@ -34,9 +29,7 @@ import { FormControl } from '@mui/material';
import { fileNameValidation } from '-/services/utils-io';
import { useTargetPathContext } from '-/components/dialogs/hooks/useTargetPathContext';
import { useTranslation } from 'react-i18next';
-import { useOpenedEntryContext } from '-/hooks/useOpenedEntryContext';
-import { useCurrentLocationContext } from '-/hooks/useCurrentLocationContext';
-import { useDirectoryContentContext } from '-/hooks/useDirectoryContentContext';
+import { TS } from '-/tagspaces.namespace';
const PREFIX = 'CreateFile';
@@ -52,37 +45,38 @@ const StyledGrid = styled(Grid)(() => ({
}));
interface Props {
- //open: boolean;
- onClose: () => void;
+ fileName: string;
+ handleFileNameChange: (fileName: string) => void;
+ handleFileContentChange: (fileContent: string) => void;
+ createFile: (fileType: TS.FileType) => void;
+ haveError: (error: boolean) => void;
tidPrefix?: string;
+ fileType?: TS.FileType;
}
function CreateFile(props: Props) {
- const { onClose, tidPrefix } = props;
+ const {
+ tidPrefix,
+ fileType,
+ createFile,
+ fileName,
+ handleFileNameChange,
+ handleFileContentChange,
+ haveError,
+ } = props;
const { t } = useTranslation();
-
- //const dispatch: AppDispatch = useDispatch();
- const { currentLocation, openLocation, getFirstRWLocation } =
- useCurrentLocationContext();
- const { currentDirectoryPath } = useDirectoryContentContext();
const { targetDirectoryPath } = useTargetPathContext();
- const firstRWLocation = getFirstRWLocation();
-
- const fileName = useRef<string>(
- 'note' +
- AppConfig.beginTagContainer +
- formatDateTime4Tag(new Date(), true) +
- AppConfig.endTagContainer,
- );
const [inputError, setInputError] = useState<boolean>(false);
- const { createFileAdvanced } = useOpenedEntryContext();
const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);
- const fileContent = '';
const noSuitableLocation = !targetDirectoryPath;
+ useEffect(() => {
+ haveError(inputError);
+ }, [inputError]);
+
function tid(tid) {
if (tidPrefix) {
return tidPrefix + tid;
@@ -90,63 +84,15 @@ function CreateFile(props: Props) {
return tid;
}
- function loadLocation() {
- const isCloudLocation =
- currentLocation && currentLocation.type === locationType.TYPE_CLOUD;
- // no currentDirectoryPath in root cloud location
- if (!isCloudLocation && !currentDirectoryPath && firstRWLocation) {
- openLocation(firstRWLocation);
- }
- }
-
- function createRichTextFile() {
- if (targetDirectoryPath && !fileNameValidation(fileName.current)) {
- loadLocation();
- createFileAdvanced(
- targetDirectoryPath,
- fileName.current,
- fileContent,
- 'html',
- );
- onClose();
- }
- }
-
- function createTextFile() {
- if (targetDirectoryPath && !fileNameValidation(fileName.current)) {
- loadLocation();
- createFileAdvanced(
- targetDirectoryPath,
- fileName.current,
- fileContent,
- 'txt',
- );
- onClose();
- }
- }
-
- function createMarkdownFile() {
- if (targetDirectoryPath && !fileNameValidation(fileName.current)) {
- loadLocation();
- createFileAdvanced(
- targetDirectoryPath,
- fileName.current,
- fileContent,
- 'md',
- );
- onClose();
- }
- }
-
const onInputFocus = (event) => {
- if (fileName.current) {
+ if (fileName) {
event.preventDefault();
const { target } = event;
target.focus();
/*const indexOfBracket = fileName.current.indexOf(
AppConfig.beginTagContainer
);*/
- let endRange = fileName.current.length;
+ let endRange = fileName.length;
// if (indexOfBracket > 0) {
// endRange = indexOfBracket;
// }
@@ -155,12 +101,15 @@ function CreateFile(props: Props) {
};
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
- fileName.current = event.target.value;
- handleValidation();
+ handleFileNameChange(event.target.value);
+ handleValidation(event.target.value);
+ };
+ const handleContentChange = (event: React.ChangeEvent<HTMLInputElement>) => {
+ handleFileContentChange(event.target.value);
};
- const handleValidation = () => {
- let noValid = fileNameValidation(fileName.current);
+ const handleValidation = (file) => {
+ let noValid = fileNameValidation(file);
if (noValid) {
if (inputError !== noValid) {
@@ -175,86 +124,101 @@ function CreateFile(props: Props) {
return (
<StyledGrid style={{ flexGrow: 1, width: '100%' }} container spacing={1}>
- <Grid item xs={12}>
- <FormControl fullWidth={true} error={inputError}>
+ <FormControl fullWidth={true} error={inputError}>
+ <TextField
+ error={inputError}
+ margin="dense"
+ name="entryName"
+ variant="filled"
+ label={t('core:fileName')}
+ onChange={handleInputChange}
+ onFocus={onInputFocus}
+ onKeyDown={(event) => {
+ if (event.key === 'Enter' || event.code === 'Enter') {
+ event.preventDefault();
+ event.stopPropagation();
+ createFile(fileType);
+ }
+ }}
+ defaultValue={fileName}
+ disabled={noSuitableLocation}
+ fullWidth={true}
+ data-tid={tid('newEntryDialogInputTID')}
+ />
+ {inputError && (
+ <FormHelperText>{t('core:fileNameHelp')}</FormHelperText>
+ )}
+ </FormControl>
+ {fileType ? (
+ <FormControl fullWidth={true}>
<TextField
autoFocus
- error={inputError}
+ id="fileContentID"
+ label={t('core:fileContent')}
+ multiline
+ fullWidth
+ variant="filled"
+ // value={fileContent}
+ rows={5}
margin="dense"
- name="entryName"
- label={t('core:newFileName')}
- onChange={handleInputChange}
- onFocus={onInputFocus}
- onKeyDown={(event) => {
- if (event.key === 'Enter' || event.keyCode === 13) {
- event.preventDefault();
- event.stopPropagation();
- createMarkdownFile();
- }
- }}
- defaultValue={fileName.current}
- disabled={noSuitableLocation}
- fullWidth={true}
- data-tid={tid('newEntryDialogInputTID')}
+ onChange={handleContentChange}
/>
- {inputError && (
- <FormHelperText>{t('core:fileNameHelp')}</FormHelperText>
- )}
</FormControl>
- </Grid>
- <Grid item xs={12}>
- <ButtonGroup
- style={{
- textAlign: 'center',
- width: '100%',
- }}
- >
- <Button
- // variant="contained"
- onClick={createMarkdownFile}
- className={classes.createButton}
- data-tid={tid('createMarkdownButton')}
- disabled={noSuitableLocation}
- >
- <Tooltip title={t('createMarkdownTitle')}>
- <Typography
- variant="button"
- style={{ fontWeight: 'bold' }}
- display="block"
- gutterBottom
- >
- {t('createMarkdown')}
- </Typography>
- </Tooltip>
- </Button>
- <Button
- // variant="contained"
- onClick={createRichTextFile}
- className={classes.createButton}
- data-tid={tid('createRichTextFileButton')}
- disabled={noSuitableLocation}
- >
- <Tooltip title={t('createNoteTitle')}>
- <Typography variant="button" display="block" gutterBottom>
- {t('createRichTextFile')}
- </Typography>
- </Tooltip>
- </Button>
- <Button
- // variant="contained"
- onClick={createTextFile}
- className={classes.createButton}
- data-tid={tid('createTextFileButton')}
- disabled={noSuitableLocation}
+ ) : (
+ <Grid item xs={12}>
+ <ButtonGroup
+ style={{
+ textAlign: 'center',
+ width: '100%',
+ }}
>
- <Tooltip title={t('createTextFileTitle')}>
- <Typography variant="button" display="block" gutterBottom>
- {t('createTextFile')}
- </Typography>
- </Tooltip>
- </Button>
- </ButtonGroup>
- </Grid>
+ <Button
+ // variant="contained"
+ onClick={() => createFile('md')}
+ className={classes.createButton}
+ data-tid={tid('createMarkdownButton')}
+ disabled={noSuitableLocation}
+ >
+ <Tooltip title={t('createMarkdownTitle')}>
+ <Typography
+ variant="button"
+ style={{ fontWeight: 'bold' }}
+ display="block"
+ gutterBottom
+ >
+ {t('createMarkdown')}
+ </Typography>
+ </Tooltip>
+ </Button>
+ <Button
+ // variant="contained"
+ onClick={() => createFile('html')}
+ className={classes.createButton}
+ data-tid={tid('createRichTextFileButton')}
+ disabled={noSuitableLocation}
+ >
+ <Tooltip title={t('createNoteTitle')}>
+ <Typography variant="button" display="block" gutterBottom>
+ {t('createRichTextFile')}
+ </Typography>
+ </Tooltip>
+ </Button>
+ <Button
+ // variant="contained"
+ onClick={() => createFile('txt')}
+ className={classes.createButton}
+ data-tid={tid('createTextFileButton')}
+ disabled={noSuitableLocation}
+ >
+ <Tooltip title={t('createTextFileTitle')}>
+ <Typography variant="button" display="block" gutterBottom>
+ {t('createTextFile')}
+ </Typography>
+ </Tooltip>
+ </Button>
+ </ButtonGroup>
+ </Grid>
+ )}
</StyledGrid>
);
}
diff --git a/src/renderer/components/dialogs/components/CreateLink.tsx b/src/renderer/components/dialogs/components/CreateLink.tsx
new file mode 100644
index 000000000..20d4d4516
--- /dev/null
+++ b/src/renderer/components/dialogs/components/CreateLink.tsx
@@ -0,0 +1,171 @@
+/**
+ * TagSpaces - universal file and folder organizer
+ * Copyright (C) 2017-present TagSpaces GmbH
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License (version 3) as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+import React, { useEffect, useReducer, useState } from 'react';
+import { styled } from '@mui/material/styles';
+import Grid from '@mui/material/Grid';
+import TextField from '@mui/material/TextField';
+import FormHelperText from '@mui/material/FormHelperText';
+import { FormControl } from '@mui/material';
+import { fileNameValidation, urlValidation } from '-/services/utils-io';
+import { useTargetPathContext } from '-/components/dialogs/hooks/useTargetPathContext';
+import { useTranslation } from 'react-i18next';
+import { TS } from '-/tagspaces.namespace';
+
+const PREFIX = 'CreateLink';
+
+const classes = {
+ createButton: `${PREFIX}-createButton`,
+};
+
+const StyledGrid = styled(Grid)(() => ({
+ [`& .${classes.createButton}`]: {
+ width: '100%',
+ textAlign: 'center',
+ },
+}));
+
+interface Props {
+ fileName: string;
+ handleFileNameChange: (fileName: string) => void;
+ handleFileContentChange: (fileContent: string) => void;
+ createFile: (fileType: TS.FileType) => void;
+ haveError: (error: boolean) => void;
+ tidPrefix?: string;
+}
+
+function CreateLink(props: Props) {
+ const {
+ tidPrefix,
+ createFile,
+ fileName,
+ handleFileNameChange,
+ handleFileContentChange,
+ haveError,
+ } = props;
+ const { t } = useTranslation();
+ const { targetDirectoryPath } = useTargetPathContext();
+
+ const [inputError, setInputError] = useState<boolean>(false);
+ const [urlError, setUrlError] = useState<boolean>(false);
+
+ const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);
+
+ const noSuitableLocation = !targetDirectoryPath;
+
+ useEffect(() => {
+ haveError(inputError || urlError);
+ }, [inputError, urlError]);
+
+ function tid(tid) {
+ if (tidPrefix) {
+ return tidPrefix + tid;
+ }
+ return tid;
+ }
+
+ const onInputFocus = (event) => {
+ if (fileName) {
+ event.preventDefault();
+ const { target } = event;
+ target.focus();
+ let endRange = fileName.length;
+ target.setSelectionRange(0, endRange);
+ }
+ };
+
+ const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
+ handleFileNameChange(event.target.value);
+ handleValidation(fileNameValidation(event.target.value));
+ };
+ const handleUrlChange = (event: React.ChangeEvent<HTMLInputElement>) => {
+ handleFileContentChange(event.target.value);
+ handleUrlValidation(!urlValidation(event.target.value));
+ };
+
+ const handleValidation = (noValid) => {
+ if (noValid) {
+ if (inputError !== noValid) {
+ setInputError(noValid);
+ } else {
+ forceUpdate();
+ }
+ } else {
+ setInputError(noValid);
+ }
+ };
+
+ const handleUrlValidation = (noValid) => {
+ if (noValid) {
+ if (urlError !== noValid) {
+ setUrlError(noValid);
+ } else {
+ forceUpdate();
+ }
+ } else {
+ setUrlError(noValid);
+ }
+ };
+
+ return (
+ <StyledGrid style={{ flexGrow: 1, width: '100%' }} container spacing={1}>
+ <FormControl fullWidth={true} error={inputError}>
+ <TextField
+ error={inputError}
+ margin="dense"
+ name="entryName"
+ variant="filled"
+ label={t('core:fileName')}
+ onChange={handleInputChange}
+ onFocus={onInputFocus}
+ onKeyDown={(event) => {
+ if (event.key === 'Enter' || event.code === 'Enter') {
+ event.preventDefault();
+ event.stopPropagation();
+ createFile('url');
+ }
+ }}
+ defaultValue={fileName}
+ disabled={noSuitableLocation}
+ fullWidth={true}
+ data-tid={tid('newEntryDialogInputTID')}
+ />
+ {inputError && (
+ <FormHelperText>{t('core:fileNameHelp')}</FormHelperText>
+ )}
+ </FormControl>
+ <FormControl fullWidth={true} error={urlError}>
+ <TextField
+ autoFocus
+ error={urlError}
+ id="fileLinkID"
+ label={t('core:linkURL')}
+ fullWidth
+ variant="filled"
+ margin="dense"
+ onChange={handleUrlChange}
+ />
+ {urlError && (
+ <FormHelperText>{t('core:urlValidationHelp')}</FormHelperText>
+ )}
+ </FormControl>
+ </StyledGrid>
+ );
+}
+
+export default CreateLink;
diff --git a/src/renderer/components/dialogs/hooks/NewEntryDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/NewEntryDialogContextProvider.tsx
index 98dc22231..87846671c 100644
--- a/src/renderer/components/dialogs/hooks/NewEntryDialogContextProvider.tsx
+++ b/src/renderer/components/dialogs/hooks/NewEntryDialogContextProvider.tsx
@@ -1,4 +1,5 @@
-/**
+/*
+/!**
* TagSpaces - universal file and folder organizer
* Copyright (C) 2017-present TagSpaces GmbH
*
@@ -14,7 +15,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
- */
+ *!/
import React, { createContext, useMemo, useReducer, useRef } from 'react';
import LoadingLazy from '-/components/LoadingLazy';
@@ -34,7 +35,7 @@ export type NewEntryDialogContextProviderProps = {
};
const NewEntryDialog = React.lazy(
- () => import(/* webpackChunkName: "NewEntryDialog" */ '../NewEntryDialog'),
+ () => import(/!* webpackChunkName: "NewEntryDialog" *!/ '../NewEntryDialog'),
);
export const NewEntryDialogContextProvider = ({
@@ -83,3 +84,4 @@ export const NewEntryDialogContextProvider = ({
</NewEntryDialogContext.Provider>
);
};
+*/
diff --git a/src/renderer/components/dialogs/hooks/NewFileDialogContextProvider.tsx b/src/renderer/components/dialogs/hooks/NewFileDialogContextProvider.tsx
index 9af96cbcc..7089a8637 100644
--- a/src/renderer/components/dialogs/hooks/NewFileDialogContextProvider.tsx
+++ b/src/renderer/components/dialogs/hooks/NewFileDialogContextProvider.tsx
@@ -25,10 +25,11 @@ import React, {
} from 'react';
import LoadingLazy from '-/components/LoadingLazy';
import AppConfig from '-/AppConfig';
-import { actions as SettingsActions } from '-/reducers/settings';
+import { TargetPathContextProvider } from '-/components/dialogs/hooks/TargetPathContextProvider';
+import { TS } from '-/tagspaces.namespace';
type NewFileDialogContextData = {
- openNewFileDialog: () => void;
+ openNewFileDialog: (entryType?: TS.FileType) => void;
closeNewFileDialog: () => void;
};
@@ -49,6 +50,7 @@ export const NewFileDialogContextProvider = ({
children,
}: NewFileDialogContextProviderProps) => {
const open = useRef<boolean>(false);
+ const fileType = useRef<TS.FileType>(undefined);
const [ignored, forceUpdate] = useReducer((x) => x + 1, 0, undefined);
@@ -66,8 +68,9 @@ export const NewFileDialogContextProvider = ({
}
}, []);
- function openDialog() {
+ function openDialog(fType = undefined) {
open.current = true;
+ fileType.current = fType;
forceUpdate();
}
@@ -92,16 +95,19 @@ export const NewFileDialogContextProvider = ({
}, []);
return (
- <NewFileDialogContext.Provider value={context}>
- <NewFileDialogAsync
- open={open.current}
- onClose={(event, reason) => {
- if (reason !== 'backdropClick') {
- closeDialog();
- }
- }}
- />
- {children}
- </NewFileDialogContext.Provider>
+ <TargetPathContextProvider>
+ <NewFileDialogContext.Provider value={context}>
+ <NewFileDialogAsync
+ open={open.current}
+ onClose={(event, reason) => {
+ if (reason !== 'backdropClick') {
+ closeDialog();
+ }
+ }}
+ fileType={fileType.current}
+ />
+ {children}
+ </NewFileDialogContext.Provider>
+ </TargetPathContextProvider>
);
};
diff --git a/src/renderer/components/dialogs/hooks/useNewEntryDialogContext.tsx b/src/renderer/components/dialogs/hooks/useNewEntryDialogContext.tsx
index 2f59f7bc4..5f40d35ad 100644
--- a/src/renderer/components/dialogs/hooks/useNewEntryDialogContext.tsx
+++ b/src/renderer/components/dialogs/hooks/useNewEntryDialogContext.tsx
@@ -1,5 +1,7 @@
+/*
import { useContext } from 'react';
import { NewEntryDialogContext } from '-/components/dialogs/hooks/NewEntryDialogContextProvider';
export const useNewEntryDialogContext = () => useContext(NewEntryDialogContext);
+*/
diff --git a/src/renderer/components/menus/DirectoryMenu.tsx b/src/renderer/components/menus/DirectoryMenu.tsx
index 9682e96ce..deb5ff0fd 100644
--- a/src/renderer/components/menus/DirectoryMenu.tsx
+++ b/src/renderer/components/menus/DirectoryMenu.tsx
@@ -17,7 +17,6 @@
*/
import React, { useRef } from 'react';
-import { useDispatch } from 'react-redux';
import { Menu, MenuList } from '@mui/material';
import { formatDateTime4Tag } from '@tagspaces/tagspaces-common/misc';
import AppConfig from '-/AppConfig';
@@ -29,10 +28,6 @@ import {
generateSharingLink,
} from '@tagspaces/tagspaces-common/paths';
import { Pro } from '-/pro';
-import { actions as AppActions, AppDispatch } from '-/reducers/app';
-import FileUploadContainer, {
- FileUploadContainerRef,
-} from '-/components/FileUploadContainer';
import {
createNewInstance,
getRelativeEntryPath,
@@ -60,6 +55,7 @@ import { useNewFileDialogContext } from '-/components/dialogs/hooks/useNewFileDi
import { useNewAudioDialogContext } from '-/components/dialogs/hooks/useNewAudioDialogContext';
import { useProTeaserDialogContext } from '-/components/dialogs/hooks/useProTeaserDialogContext';
import { useDeleteMultipleEntriesDialogContext } from '-/components/dialogs/hooks/useDeleteMultipleEntriesDialogContext';
+import { useFileUploadContext } from '-/hooks/useFileUploadContext';
interface Props {
open: boolean;
@@ -87,6 +83,7 @@ function DirectoryMenu(props: Props) {
useCurrentLocationContext();
const { setThumbnailImageChange } = useIOActionsContext();
const { showNotification } = useNotificationContext();
+ const { openFileUpload } = useFileUploadContext();
const { openCreateDirectoryDialog } = useCreateDirectoryDialogContext();
const {
openDirectory,
@@ -102,7 +99,6 @@ function DirectoryMenu(props: Props) {
const { openProTeaserDialog } = useProTeaserDialogContext();
const { openDeleteMultipleEntriesDialog } =
useDeleteMultipleEntriesDialogContext();
- const fileUploadContainerRef = useRef<FileUploadContainerRef>(null);
const {
open,
onClose,
@@ -218,7 +214,7 @@ function DirectoryMenu(props: Props) {
}
function addExistingFile() {
- fileUploadContainerRef.current.onFileUpload();
+ openFileUpload(directoryPath);
}
function importMacTags() {
@@ -447,11 +443,6 @@ Do you want to continue?`)
>
<MenuList>{menuItems}</MenuList>
</Menu>
- <FileUploadContainer
- /*id="dirMenuId"*/
- ref={fileUploadContainerRef}
- directoryPath={directoryPath}
- />
</>
);
}
diff --git a/src/renderer/components/menus/LocationManagerMenu.tsx b/src/renderer/components/menus/LocationManagerMenu.tsx
index cd859f644..4cc7af1b6 100644
--- a/src/renderer/components/menus/LocationManagerMenu.tsx
+++ b/src/renderer/components/menus/LocationManagerMenu.tsx
@@ -83,21 +83,21 @@ function LocationManagerMenu(props: Props) {
);
}
- menuItems.push(
- <MenuItem
- key="locationManagerMenuOpenLink"
- data-tid="locationManagerMenuOpenLink"
- onClick={() => {
- setLocationManagerMenuAnchorEl(null);
- openLinkDialog();
- }}
- >
- <ListItemIcon>
- <OpenLinkIcon />
- </ListItemIcon>
- <ListItemText primary={t('core:openLink')} />
- </MenuItem>,
- );
+ // menuItems.push(
+ // <MenuItem
+ // key="locationManagerMenuOpenLink"
+ // data-tid="locationManagerMenuOpenLink"
+ // onClick={() => {
+ // setLocationManagerMenuAnchorEl(null);
+ // openLinkDialog();
+ // }}
+ // >
+ // <ListItemIcon>
+ // <OpenLinkIcon />
+ // </ListItemIcon>
+ // <ListItemText primary={t('core:openLink')} />
+ // </MenuItem>,
+ // );
if (!AppConfig.locationsReadOnly) {
// https://trello.com/c/z6ESlqxz/697-exports-to-json-or-csv-do-not-work-on-android
diff --git a/src/renderer/containers/DialogsRoot.tsx b/src/renderer/containers/DialogsRoot.tsx
index ad61365f5..4e4ef4ee2 100644
--- a/src/renderer/containers/DialogsRoot.tsx
+++ b/src/renderer/containers/DialogsRoot.tsx
@@ -23,7 +23,6 @@ import { CreateEditLocationDialogContextProvider } from '-/components/dialogs/ho
import { MoveOrCopyFilesDialogContextProvider } from '-/components/dialogs/hooks/MoveOrCopyFilesDialogContextProvider';
import { CreateDirectoryDialogContextProvider } from '-/components/dialogs/hooks/CreateDirectoryDialogContextProvider';
import { ProgressDialogContextProvider } from '-/components/dialogs/hooks/ProgressDialogContextProvider';
-import { NewEntryDialogContextProvider } from '-/components/dialogs/hooks/NewEntryDialogContextProvider';
import { NewFileDialogContextProvider } from '-/components/dialogs/hooks/NewFileDialogContextProvider';
import { NewAudioDialogContextProvider } from '-/components/dialogs/hooks/NewAudioDialogContextProvider';
import { LicenseDialogContextProvider } from '-/components/dialogs/hooks/LicenseDialogContextProvider';
@@ -36,6 +35,7 @@ import { ProTeaserDialogContextProvider } from '-/components/dialogs/hooks/ProTe
import { SettingsDialogContextProvider } from '-/components/dialogs/hooks/SettingsDialogContextProvider';
import { DeleteMultipleEntriesDialogContextProvider } from '-/components/dialogs/hooks/DeleteMultipleEntriesDialogContextProvider';
import { ResolveConflictContextProvider } from '-/components/dialogs/hooks/ResolveConflictContextProvider';
+import { FileUploadContextProvider } from '-/hooks/FileUploadContextProvider';
export type DialogsRootProps = {
children: React.ReactNode;
@@ -46,11 +46,11 @@ function DialogsRoot({ children }: DialogsRootProps) {
<EntryExistDialogContextProvider>
<DeleteMultipleEntriesDialogContextProvider>
<FileUploadDialogContextProvider>
- <CreateEditLocationDialogContextProvider>
- <MoveOrCopyFilesDialogContextProvider>
- <CreateDirectoryDialogContextProvider>
- <ProgressDialogContextProvider>
- <NewEntryDialogContextProvider>
+ <FileUploadContextProvider>
+ <CreateEditLocationDialogContextProvider>
+ <MoveOrCopyFilesDialogContextProvider>
+ <CreateDirectoryDialogContextProvider>
+ <ProgressDialogContextProvider>
<NewFileDialogContextProvider>
<NewAudioDialogContextProvider>
<LicenseDialogContextProvider>
@@ -74,11 +74,11 @@ function DialogsRoot({ children }: DialogsRootProps) {
</LicenseDialogContextProvider>
</NewAudioDialogContextProvider>
</NewFileDialogContextProvider>
- </NewEntryDialogContextProvider>
- </ProgressDialogContextProvider>
- </CreateDirectoryDialogContextProvider>
- </MoveOrCopyFilesDialogContextProvider>
- </CreateEditLocationDialogContextProvider>
+ </ProgressDialogContextProvider>
+ </CreateDirectoryDialogContextProvider>
+ </MoveOrCopyFilesDialogContextProvider>
+ </CreateEditLocationDialogContextProvider>
+ </FileUploadContextProvider>
</FileUploadDialogContextProvider>
</DeleteMultipleEntriesDialogContextProvider>
</EntryExistDialogContextProvider>
diff --git a/src/renderer/hooks/FileUploadContextProvider.tsx b/src/renderer/hooks/FileUploadContextProvider.tsx
new file mode 100644
index 000000000..87e255c5f
--- /dev/null
+++ b/src/renderer/hooks/FileUploadContextProvider.tsx
@@ -0,0 +1,57 @@
+/**
+ * TagSpaces - universal file and folder organizer
+ * Copyright (C) 2023-present TagSpaces GmbH
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License (version 3) as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+import React, { createContext, useMemo, useRef } from 'react';
+import FileUploadContainer, {
+ FileUploadContainerRef,
+} from '-/components/FileUploadContainer';
+
+type FileUploadContextData = {
+ openFileUpload: (dPath: string) => void;
+};
+
+export const FileUploadContext = createContext<FileUploadContextData>({
+ openFileUpload: undefined,
+});
+
+export type FileUploadContextProviderProps = {
+ children: React.ReactNode;
+};
+
+export const FileUploadContextProvider = ({
+ children,
+}: FileUploadContextProviderProps) => {
+ const fileUploadContainerRef = useRef<FileUploadContainerRef>(null);
+
+ function openFileUpload(dPath: string) {
+ fileUploadContainerRef.current.onFileUpload(dPath);
+ }
+
+ const context = useMemo(() => {
+ return {
+ openFileUpload: openFileUpload,
+ };
+ }, []);
+
+ return (
+ <FileUploadContext.Provider value={context}>
+ {children}
+ <FileUploadContainer ref={fileUploadContainerRef} />
+ </FileUploadContext.Provider>
+ );
+};
diff --git a/src/renderer/hooks/OpenedEntryContextProvider.tsx b/src/renderer/hooks/OpenedEntryContextProvider.tsx
index 1bf9df618..96896ec01 100644
--- a/src/renderer/hooks/OpenedEntryContextProvider.tsx
+++ b/src/renderer/hooks/OpenedEntryContextProvider.tsx
@@ -99,7 +99,7 @@ type OpenedEntryContextData = {
targetPath: string,
fileName: string,
content: string,
- fileType: 'md' | 'txt' | 'html',
+ fileType: TS.FileType,
) => void;
createFile: () => void;
getOpenedDirProps: () => Promise<TS.DirProp>;
@@ -850,7 +850,7 @@ export const OpenedEntryContextProvider = ({
targetPath: string,
fileName: string,
content: string,
- fileType: 'md' | 'txt' | 'html',
+ fileType: TS.FileType = 'md',
) {
const creationDate = new Date().toISOString();
const fileNameAndExt = fileName + '.' + fileType;
@@ -882,6 +882,8 @@ export const OpenedEntryContextProvider = ({
'</body>' + newHTMLFileContent.split('<body></body>')[1];
} else if (fileType === 'md') {
fileContent = content + ' \n\n' + creationMeta + '\n';
+ } else if (fileType === 'url') {
+ fileContent = '[InternetShortcut]\n' + 'URL=' + content + '\n';
}
saveFilePromise({ path: filePath }, fileContent, false, true)
.then((fsEntry: TS.FileSystemEntry) => {
diff --git a/src/renderer/hooks/useFileUploadContext.tsx b/src/renderer/hooks/useFileUploadContext.tsx
new file mode 100644
index 000000000..78bc8aca2
--- /dev/null
+++ b/src/renderer/hooks/useFileUploadContext.tsx
@@ -0,0 +1,23 @@
+/**
+ * TagSpaces - universal file and folder organizer
+ * Copyright (C) 2023-present TagSpaces GmbH
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License (version 3) as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+import { useContext } from 'react';
+
+import { FileUploadContext } from '-/hooks/FileUploadContextProvider';
+
+export const useFileUploadContext = () => useContext(FileUploadContext);
diff --git a/src/renderer/locales/en/core.json b/src/renderer/locales/en/core.json
index 24ab64b96..4778ddbb8 100644
--- a/src/renderer/locales/en/core.json
+++ b/src/renderer/locales/en/core.json
@@ -51,7 +51,7 @@
"filePropertiesTitle": "File Details",
"openEntryDetails": "Open Entry Details",
"createLocationTitle": "Connect a Location",
- "createLocation": "New location",
+ "createLocation": "New Location",
"exportLocationTitle": "Export Location Configuration",
"importLocationTitle": "Import Location Configuration",
"closeAllLocations": "Close All Locations",
@@ -266,12 +266,13 @@
"createNewColumn": "Create new column",
"createFileTitle": "Create new files, folders or locations",
"createNote": "Create Note",
- "createNoteTitle": "Use to create a document with rich text formatting.",
- "createTextFile": "Create Text File",
- "createTextFileTitle": "Use to create a plain text file with no formatting.",
- "createMarkdown": "Create Markdown File",
- "createMarkdownTitle": "Use to create a digital note or just a text file with simple formatting.",
- "createRichTextFile": "Create HTML File",
+ "createNoteTitle": "Create a document with rich text (HTML based) formatting",
+ "createTextFile": "New Plain Text File",
+ "createTextFileTitle": "Creates a plain text file with no formatting",
+ "createMarkdown": "New Markdown File",
+ "createMarkdownTitle": "Creates a text file with simple (markdown based) formatting, recommended for digital notes",
+ "createRichTextFile": "New HTML File",
+ "createLinkFile": "New Link File",
"createDirectory": "New Folder",
"addFiles": "Add Files",
"addFilesTitle": "Add or upload files from your computer.",
@@ -781,7 +782,7 @@
"resolveConflictTitle": "File was modified externally",
"resolveConflictDesc": "For saving your changes as new file click on 'Save As' button, for override the external changes click the 'Override' button.",
"create": "Create",
- "newWindow": "New window",
+ "newWindow": "New Window",
"entriesWillBeCreatedIn": "Files and folders will be created in:",
"noSuitableLocation": "Files or folders can't be created. No suitable location found!",
"openEntry": "Open entry",
@@ -817,7 +818,7 @@
"details": "Details",
"editDisabled": "Editing the description is disabled while editing the current file",
"togglePreviewSize": "Toggle file preview size",
- "newAudioRecording": "Record Audio",
+ "newAudioRecording": "New Audio File",
"audioRecorder": "Audio Recorder",
"startRecording": "Start Recording",
"pauseRecording": "Pause Recording",
@@ -856,5 +857,12 @@
"dragMode": "Enable dragging files outside of the application",
"dragOutsideApp": "Drag outside the app",
"exitEditMode": "Exit editing",
+ "cloudPath": "Path in the cloud",
+ "calculate": "Calculate",
+ "createNew": "Create New",
+ "fileContent": "File Content",
+ "linkURL": "URL",
+ "urlValidationHelp": "not valid URL",
+ "openSharingLink": "Open sharing links created with the TagSpaces (ts:// links)",
"-": "-"
}
diff --git a/src/renderer/perspectives/list/components/RowCell.tsx b/src/renderer/perspectives/list/components/RowCell.tsx
index d516aa364..841bf7f19 100644
--- a/src/renderer/perspectives/list/components/RowCell.tsx
+++ b/src/renderer/perspectives/list/components/RowCell.tsx
@@ -29,6 +29,7 @@ import {
SelectedIcon,
UnSelectedIcon,
FolderOutlineIcon,
+ MoreMenuIcon,
} from '-/components/CommonIcons';
import {
formatFileSize,
@@ -485,6 +486,21 @@ function RowCell(props: Props) {
/>
</Grid>
)}
+ <Grid
+ item
+ style={{
+ display: 'flex',
+ alignItems: 'center',
+ }}
+ >
+ <IconButton
+ aria-label="entry context menu"
+ size="small"
+ onClick={(event) => handleGridContextMenu(event, fsEntry)}
+ >
+ <MoreMenuIcon />
+ </IconButton>
+ </Grid>
</Grid>
</RowPaper>
);
diff --git a/src/renderer/services/utils-io.ts b/src/renderer/services/utils-io.ts
index 1bf5bc790..b4dbef7b2 100644
--- a/src/renderer/services/utils-io.ts
+++ b/src/renderer/services/utils-io.ts
@@ -567,6 +567,18 @@ export function getDescriptionPreview(mdContent, maxLength = 200) {
// return marked.parse(DOMPurify.sanitize(mdContent));
// }
+/**
+ * @param url
+ * return true if valid; false otherwise
+ */
+export function urlValidation(url: string): boolean {
+ if (url.length > 0) {
+ const urlRegex = /^(https?|ftp|ts):\/\/([^\s/$.?#].[^\s]*|\?[^ ]*)$/i;
+ return urlRegex.test(url);
+ }
+ return false;
+}
+
/**
* forbidden characters # \ / * ? " < > | & %
* @param tagTitle
@@ -586,10 +598,11 @@ export function tagsValidation(tagTitle: string): boolean {
/**
* forbidden characters # \ / * ? " < > |
* @param dirName
+ * return notValid
*/
export function dirNameValidation(dirName): boolean {
if (dirName.length > 0) {
- const rg1 = /^[^#\\/*?"<>|]+$/; // forbidden characters # \ / * ? " < > |
+ const rg1 = /^[^#\\/*?"<>|&%]+$/; // forbidden characters # \ / * ? " < > | & %
return !rg1.test(dirName);
}
return true;
diff --git a/src/renderer/tagspaces.namespace.d.ts b/src/renderer/tagspaces.namespace.d.ts
index 2fe1d9ee1..a3998c31e 100644
--- a/src/renderer/tagspaces.namespace.d.ts
+++ b/src/renderer/tagspaces.namespace.d.ts
@@ -115,6 +115,7 @@ export namespace TS {
type Uuid = string;
export type ActionSource = 'local' | 'upload' | 'thumbgen' | 'fsWatcher';
+ export type FileType = 'txt' | 'md' | 'html' | 'url';
interface EditAction {
action: 'add' | 'delete' | 'update' | 'move' | 'edit';