TagSpaces is an offline, open source, document manager with tagging support
fix: removing flow
Ilian Sapundshiev93b1689e2113
diff --git a/app/components/AppOnboarding.tsx b/app/components/AppOnboarding.tsxindex c47642249..226052a71 100644--- a/app/components/AppOnboarding.tsx+++ b/app/components/AppOnboarding.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React, { Component } from 'react';diff --git a/app/components/CustomLogo.tsx b/app/components/CustomLogo.tsxindex dd6d1f78c..369fdcd2a 100644--- a/app/components/CustomLogo.tsx+++ b/app/components/CustomLogo.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/DragItemTypes.tsx b/app/components/DragItemTypes.tsxindex cdc683de5..9eabb0096 100644--- a/app/components/DragItemTypes.tsx+++ b/app/components/DragItemTypes.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/export default {diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsxindex e448615c0..0b7bc8ed3 100644--- a/app/components/EntryContainer.tsx+++ b/app/components/EntryContainer.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';@@ -66,7 +65,7 @@ import {} from '../reducers/settings';import TaggingActions from '../reducers/tagging-actions';import {- type OpenedEntry,+ OpenedEntry,NotificationTypes,getOpenedFiles,isReadOnlyMode,diff --git a/app/components/EntryProperties.tsx b/app/components/EntryProperties.tsxindex 201867909..d8b5f0c4e 100644--- a/app/components/EntryProperties.tsx+++ b/app/components/EntryProperties.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React, { Component } from 'react';diff --git a/app/components/FileSourceDnd.tsx b/app/components/FileSourceDnd.tsxindex c5e2d2ef5..433c6380f 100644--- a/app/components/FileSourceDnd.tsx+++ b/app/components/FileSourceDnd.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/FolderContainer.tsx b/app/components/FolderContainer.tsxindex ceab5b4a1..9e6e6d2cb 100644--- a/app/components/FolderContainer.tsx+++ b/app/components/FolderContainer.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/HelpFeedbackPanel.tsx b/app/components/HelpFeedbackPanel.tsxindex 30f4dba27..45aea5f47 100644--- a/app/components/HelpFeedbackPanel.tsx+++ b/app/components/HelpFeedbackPanel.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/LoadingLazy.tsx b/app/components/LoadingLazy.tsxindex 9d47e05f5..e420aaae9 100644--- a/app/components/LoadingLazy.tsx+++ b/app/components/LoadingLazy.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/LocationManager.tsx b/app/components/LocationManager.tsxindex 1e0b90c05..4d4b480e8 100644--- a/app/components/LocationManager.tsx+++ b/app/components/LocationManager.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/MobileNavigation.tsx b/app/components/MobileNavigation.tsxindex 5b70b901e..ee16bf3c2 100644--- a/app/components/MobileNavigation.tsx+++ b/app/components/MobileNavigation.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/PerspectiveManager.tsx b/app/components/PerspectiveManager.tsxindex 5f2b9cad7..a911405d7 100644--- a/app/components/PerspectiveManager.tsx+++ b/app/components/PerspectiveManager.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/Search.tsx b/app/components/Search.tsxindex 5a1a0a395..e0c1e3127 100644--- a/app/components/Search.tsx+++ b/app/components/Search.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/SidePanels.css.tsx b/app/components/SidePanels.css.tsxindex 721ddf51b..fe3731907 100644--- a/app/components/SidePanels.css.tsx+++ b/app/components/SidePanels.css.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import AppConfig from '../config';diff --git a/app/components/TagContainer.tsx b/app/components/TagContainer.tsxindex 3cd48db68..31828a7da 100644--- a/app/components/TagContainer.tsx+++ b/app/components/TagContainer.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';@@ -25,189 +24,189 @@ import MoreVertIcon from '@material-ui/icons/MoreVert';import PlaceIcon from '@material-ui/icons/Place';import DateIcon from '@material-ui/icons/DateRange';import RemoveTagIcon from '@material-ui/icons/Close';-import { type TagGroup, type Tag, getAllTags } from '../reducers/taglibrary';+import { TagGroup, Tag, getAllTags } from '../reducers/taglibrary';import { getTagColor, getTagTextColor } from '../reducers/settings';import { isPlusCode } from '../utils/misc';import { isDateTimeTag } from '../utils/dates';type Props = {- tag: Tag,- allTags: Array<Tag>,- key: string,- defaultTextColor: string,- defaultBackgroundColor: string,- tagGroup: TagGroup,- handleTagMenu: (event: Object, tag: Tag, tagGroup: TagGroup) => void, // TODO refactor- handleTagMenu: (event: Object, tag: Tag, entryPath: string) => void,- handleRemoveTag: (event: Object, tag: Tag) => void,- isDragging: boolean,- tagMode: 'default' | 'display' | 'remove',- entryPath: string,- deleteIcon: Object,- addTags: (paths: Array<string>, tags: Array<Tag>) => void,- // removeTags: (paths: Array<string>, tags: Array<Tag>) => void,- selectedEntries: Array<Object>+ tag: Tag;+ allTags: Array<Tag>;+ key: string;+ defaultTextColor: string;+ defaultBackgroundColor: string;+ tagGroup: TagGroup;+ handleTagMenu: (event: Object, tag: Tag, tagGroup: TagGroup) => void; // TODO refactor+ handleTagMenu: (event: Object, tag: Tag, entryPath: string) => void;+ handleRemoveTag: (event: Object, tag: Tag) => void;+ isDragging: boolean;+ tagMode: 'default' | 'display' | 'remove';+ entryPath: string;+ deleteIcon: Object;+ addTags: (paths: Array<string>, tags: Array<Tag>) => void;+ // removeTags: (paths: Array<string>, tags: Array<Tag>) => void,+ selectedEntries: Array<Object>;};const TagContainer = React.memo((props: Props) => {- const {- key,- tag,- deleteIcon,- isDragging,- defaultTextColor,- defaultBackgroundColor,- tagGroup,- entryPath,- allTags,- handleRemoveTag,- handleTagMenu,- selectedEntries,- addTags,- tagMode- } = props;+ const {+ key,+ tag,+ deleteIcon,+ isDragging,+ defaultTextColor,+ defaultBackgroundColor,+ tagGroup,+ entryPath,+ allTags,+ handleRemoveTag,+ handleTagMenu,+ selectedEntries,+ addTags,+ tagMode+ } = props;- let textColor = tag.textcolor || defaultTextColor;- let backgroundColor = tag.color || defaultBackgroundColor;- const titleOrig = tag.title;- let title = titleOrig;+ let textColor = tag.textcolor || defaultTextColor;+ let backgroundColor = tag.color || defaultBackgroundColor;+ const titleOrig = tag.title;+ let title = titleOrig;- // Check if tag is plus code- let isGeoTag = false;- let isTagDate = false;- if (!tagGroup) {- isGeoTag = isPlusCode(title); // || isLatLong- isTagDate = !isGeoTag && isDateTimeTag(title);- }- if (isTagDate && title.length > 8) {- title = title.substr(0, 8) + '...';- }+ // Check if tag is plus code+ let isGeoTag = false;+ let isTagDate = false;+ if (!tagGroup) {+ isGeoTag = isPlusCode(title); // || isLatLong+ isTagDate = !isGeoTag && isDateTimeTag(title);+ }+ if (isTagDate && title.length > 8) {+ title = title.substr(0, 8) + '...';+ }- allTags.some((currentTag: Tag) => {- if (currentTag.title === title) {- textColor = currentTag.textcolor;- backgroundColor = currentTag.color;- return true;- }- return false;- });+ allTags.some((currentTag: Tag) => {+ if (currentTag.title === title) {+ textColor = currentTag.textcolor;+ backgroundColor = currentTag.color;+ return true;+ }+ return false;+ });- let description = tag.title;- if (tag.description) {- description = tag.title + ' - ' + tag.description;- }+ let description = tag.title;+ if (tag.description) {+ description = tag.title + ' - ' + tag.description;+ }- return (- <div- role="presentation"- data-tid={'tagContainer_' + title.replace(/ /g, '_')}- key={key || tag.id || uuidv1()}- onClick={event => {- if (event.ctrlKey && addTags) {- const selectedEntryPaths = [];- selectedEntries.map(entry => selectedEntryPaths.push(entry.path));- addTags(selectedEntryPaths, [tag]);- // Removing tags doesn't seem to work correctly here, yet. Using sidecar tagging, but the removeTagsFromEntry function in tagging.actions.js- // doesn't recignize it correctly, thinking it's a plain tag and thus tries to rename the files- // } else if (event.shiftKey) {- // const selectedEntryPaths = [];- // selectedEntries.map(entry => selectedEntryPaths.push(entry.path));- // removeTags(selectedEntryPaths, [tag]);- } else if (handleTagMenu) {- handleTagMenu(event, tag, entryPath || tagGroup);- }- }}- onContextMenu={event => {- if (handleTagMenu) {- handleTagMenu(event, tag, entryPath || tagGroup);- }- }}- onDoubleClick={event => {- if (handleTagMenu) {- handleTagMenu(event, tag, entryPath || tagGroup);- }- }}- style={{- backgroundColor: 'transparent',- display: 'inline-block'- }}- >- <Button- title={description}- size="small"- style={{- opacity: isDragging ? 0.5 : 1,- fontSize: 13,- textTransform: 'none',- color: textColor,- backgroundColor,- minHeight: 0,- minWidth: 0,- margin: 2,- paddingTop: 0,- paddingBottom: 0,- paddingRight: 0,- paddingLeft: 5,- borderRadius: 5- }}- >- <span style={{ flexGrow: '1' }}>- {isGeoTag && (- <PlaceIcon- style={{- color: tag.textColor,- fontSize: 18,- marginBottom: -5- }}- />- )}- {isTagDate && (- <DateIcon- style={{- color: tag.textColor,- fontSize: 18,- marginBottom: -5,- marginRight: 4- }}- />- )}- {!isGeoTag && title}- </span>- {tagMode === 'remove' ? (- deleteIcon || (- <RemoveTagIcon- data-tid={'tagRemoveButton_' + title.replace(/ /g, '_')}- style={{- color: tag.textColor,- fontSize: 20,- marginBottom: -5- }}- onClick={event => handleRemoveTag(event, tag)}- />- )- ) : (- <MoreVertIcon- data-tid={'tagMoreButton_' + title.replace(/ /g, '_')}- style={{- color: tag.textColor,- marginLeft: -5,- marginRight: -5,- top: 0- }}- />- )}- </Button>- </div>- );+ return (+ <div+ role="presentation"+ data-tid={'tagContainer_' + title.replace(/ /g, '_')}+ key={key || tag.id || uuidv1()}+ onClick={event => {+ if (event.ctrlKey && addTags) {+ const selectedEntryPaths = [];+ selectedEntries.map(entry => selectedEntryPaths.push(entry.path));+ addTags(selectedEntryPaths, [tag]);+ // Removing tags doesn't seem to work correctly here, yet. Using sidecar tagging, but the removeTagsFromEntry function in tagging.actions.js+ // doesn't recignize it correctly, thinking it's a plain tag and thus tries to rename the files+ // } else if (event.shiftKey) {+ // const selectedEntryPaths = [];+ // selectedEntries.map(entry => selectedEntryPaths.push(entry.path));+ // removeTags(selectedEntryPaths, [tag]);+ } else if (handleTagMenu) {+ handleTagMenu(event, tag, entryPath || tagGroup);+ }+ }}+ onContextMenu={event => {+ if (handleTagMenu) {+ handleTagMenu(event, tag, entryPath || tagGroup);+ }+ }}+ onDoubleClick={event => {+ if (handleTagMenu) {+ handleTagMenu(event, tag, entryPath || tagGroup);+ }+ }}+ style={{+ backgroundColor: 'transparent',+ display: 'inline-block'+ }}+ >+ <Button+ title={description}+ size="small"+ style={{+ opacity: isDragging ? 0.5 : 1,+ fontSize: 13,+ textTransform: 'none',+ color: textColor,+ backgroundColor,+ minHeight: 0,+ minWidth: 0,+ margin: 2,+ paddingTop: 0,+ paddingBottom: 0,+ paddingRight: 0,+ paddingLeft: 5,+ borderRadius: 5+ }}+ >+ <span style={{ flexGrow: '1' }}>+ {isGeoTag && (+ <PlaceIcon+ style={{+ color: tag.textColor,+ fontSize: 18,+ marginBottom: -5+ }}+ />+ )}+ {isTagDate && (+ <DateIcon+ style={{+ color: tag.textColor,+ fontSize: 18,+ marginBottom: -5,+ marginRight: 4+ }}+ />+ )}+ {!isGeoTag && title}+ </span>+ {tagMode === 'remove' ? (+ deleteIcon || (+ <RemoveTagIcon+ data-tid={'tagRemoveButton_' + title.replace(/ /g, '_')}+ style={{+ color: tag.textColor,+ fontSize: 20,+ marginBottom: -5+ }}+ onClick={event => handleRemoveTag(event, tag)}+ />+ )+ ) : (+ <MoreVertIcon+ data-tid={'tagMoreButton_' + title.replace(/ /g, '_')}+ style={{+ color: tag.textColor,+ marginLeft: -5,+ marginRight: -5,+ top: 0+ }}+ />+ )}+ </Button>+ </div>+ );});function mapStateToProps(state) {- return {- allTags: getAllTags(state),- defaultBackgroundColor: getTagColor(state),- defaultTextColor: getTagTextColor(state)- // selectedEntries: getSelectedEntries(state)- };+ return {+ allTags: getAllTags(state),+ defaultBackgroundColor: getTagColor(state),+ defaultTextColor: getTagTextColor(state)+ // selectedEntries: getSelectedEntries(state)+ };}export default connect(mapStateToProps)(TagContainer);diff --git a/app/components/TagContainerDnd.tsx b/app/components/TagContainerDnd.tsxindex 237bfcaba..0c67ea2b0 100644--- a/app/components/TagContainerDnd.tsx+++ b/app/components/TagContainerDnd.tsx@@ -14,71 +14,70 @@* 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/>.*- * @flow*/import React from 'react';import { DragSource } from 'react-dnd';-import type { ConnectDragPreview, ConnectDragSource } from 'react-dnd';+import { ConnectDragPreview, ConnectDragSource } from 'react-dnd';import DragItemTypes from './DragItemTypes';import TagContainer from './TagContainer';-import { type TagGroup, type Tag } from '../reducers/taglibrary';+import { TagGroup, Tag } from '../reducers/taglibrary';const boxSource = {- beginDrag(props) {- // console.log('beginDrag', props);- return {- tagId: props.tag.id,- tag: props.tag,- sourceTagGroupId: props.tagGroup ? props.tagGroup.uuid : undefined- };- },+ beginDrag(props) {+ // console.log('beginDrag', props);+ return {+ tagId: props.tag.id,+ tag: props.tag,+ sourceTagGroupId: props.tagGroup ? props.tagGroup.uuid : undefined+ };+ },- endDrag(props, monitor) {- const item = monitor.getItem();- const dropResult = monitor.getDropResult();+ endDrag(props, monitor) {+ const item = monitor.getItem();+ const dropResult = monitor.getDropResult();- // console.log('DropRESULT: ', dropResult);- // console.log('item: ', item);- if (- dropResult &&- dropResult.tagGroupId &&- dropResult.tagGroupId !== item.sourceTagGroupId &&- props.moveTag- ) {- // console.log(`Dropped ${item.tagId} from ${item.sourceTagGroupId} into ${dropResult.tagGroupId}!`);- props.moveTag(item.tagId, item.sourceTagGroupId, dropResult.tagGroupId);- } else if (dropResult && dropResult.entryPath && props.addTags) {- // console.log(`Dropped item: ${item.tag.title} onto file: ${dropResult.entryPath}!`);- if (- props.selectedEntries.some(entry => entry.path === dropResult.entryPath)- ) {- const selectedEntryPaths = [];- props.selectedEntries.map(entry => selectedEntryPaths.push(entry.path));- props.addTags(selectedEntryPaths, [item.tag]);- } else {- props.addTags([dropResult.entryPath], [item.tag]);- }- }- }+ // console.log('DropRESULT: ', dropResult);+ // console.log('item: ', item);+ if (+ dropResult &&+ dropResult.tagGroupId &&+ dropResult.tagGroupId !== item.sourceTagGroupId &&+ props.moveTag+ ) {+ // console.log(`Dropped ${item.tagId} from ${item.sourceTagGroupId} into ${dropResult.tagGroupId}!`);+ props.moveTag(item.tagId, item.sourceTagGroupId, dropResult.tagGroupId);+ } else if (dropResult && dropResult.entryPath && props.addTags) {+ // console.log(`Dropped item: ${item.tag.title} onto file: ${dropResult.entryPath}!`);+ if (+ props.selectedEntries.some(entry => entry.path === dropResult.entryPath)+ ) {+ const selectedEntryPaths = [];+ props.selectedEntries.map(entry => selectedEntryPaths.push(entry.path));+ props.addTags(selectedEntryPaths, [item.tag]);+ } else {+ props.addTags([dropResult.entryPath], [item.tag]);+ }+ }+ }};type Props = {- tag: Tag,- key: string,- tagGroup: TagGroup,- handleTagMenu: (event: Object, tag: Tag, tagGroup: TagGroup) => void, // TODO refactor- handleTagMenu: (event: Object, tag: Tag, entryPath: string) => void,- handleRemoveTag: (event: Object, tag: Tag) => void,- isDragging: boolean,- tagMode?: 'default' | 'display' | 'remove',- entryPath?: string,- addTags: (paths: Array<string>, tags: Array<Tag>) => void,- moveTag: () => void,- connectDragSource: ConnectDragSource,- connectDragPreview: ConnectDragPreview,- deleteIcon: Object,- selectedEntries: Array<string>+ tag: Tag;+ key: string;+ tagGroup: TagGroup;+ handleTagMenu: (event: Object, tag: Tag, tagGroup: TagGroup) => void; // TODO refactor+ handleTagMenu: (event: Object, tag: Tag, entryPath: string) => void;+ handleRemoveTag: (event: Object, tag: Tag) => void;+ isDragging: boolean;+ tagMode?: 'default' | 'display' | 'remove';+ entryPath?: string;+ addTags: (paths: Array<string>, tags: Array<Tag>) => void;+ moveTag: () => void;+ connectDragSource: ConnectDragSource;+ connectDragPreview: ConnectDragPreview;+ deleteIcon: Object;+ selectedEntries: Array<string>;};// class TagContainerDnd extends React.PureComponent<Props> {@@ -113,40 +112,40 @@ type Props = {// render() {const TagContainerDnd = (props: Props) => {- const {- key,- tag,- tagGroup,- entryPath,- handleTagMenu,- deleteIcon,- selectedEntries,- isDragging,- connectDragSource,- addTags,- tagMode- } = props;+ const {+ key,+ tag,+ tagGroup,+ entryPath,+ handleTagMenu,+ deleteIcon,+ selectedEntries,+ isDragging,+ connectDragSource,+ addTags,+ tagMode+ } = props;- return connectDragSource(- <span>- <TagContainer- key={key}- tag={tag}- tagGroup={tagGroup}- handleTagMenu={handleTagMenu}- deleteIcon={deleteIcon}- addTags={addTags}- tagMode={tagMode}- entryPath={entryPath}- isDragging={isDragging}- selectedEntries={selectedEntries}- />- </span>- );+ return connectDragSource(+ <span>+ <TagContainer+ key={key}+ tag={tag}+ tagGroup={tagGroup}+ handleTagMenu={handleTagMenu}+ deleteIcon={deleteIcon}+ addTags={addTags}+ tagMode={tagMode}+ entryPath={entryPath}+ isDragging={isDragging}+ selectedEntries={selectedEntries}+ />+ </span>+ );};export default DragSource(DragItemTypes.TAG, boxSource, (connect, monitor) => ({- connectDragSource: connect.dragSource(),- connectDragPreview: connect.dragPreview(),- isDragging: monitor.isDragging()+ connectDragSource: connect.dragSource(),+ connectDragPreview: connect.dragPreview(),+ isDragging: monitor.isDragging()}))(TagContainerDnd);diff --git a/app/components/TagDropContainer.tsx b/app/components/TagDropContainer.tsxindex 1f8b89619..0efa98040 100644--- a/app/components/TagDropContainer.tsx+++ b/app/components/TagDropContainer.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/TagGroupContainer.tsx b/app/components/TagGroupContainer.tsxindex 17aeb9272..a536ae177 100644--- a/app/components/TagGroupContainer.tsx+++ b/app/components/TagGroupContainer.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/TagLibrary.tsx b/app/components/TagLibrary.tsxindex 93f5ad163..e25a6eb47 100644--- a/app/components/TagLibrary.tsx+++ b/app/components/TagLibrary.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';@@ -46,403 +45,403 @@ import CustomLogo from './CustomLogo';import TagLibraryMenu from './menus/TagLibraryMenu';import TagGroupMenu from './menus/TagGroupMenu';import {- type TagGroup,- type Tag,- actions as TagLibraryActions,- getAllTags,- getTagGroups+ TagGroup,+ Tag,+ actions as TagLibraryActions,+ getAllTags,+ getTagGroups} from '../reducers/taglibrary';import TaggingActions from '../reducers/tagging-actions';import i18n from '../services/i18n';import { getTagColor, getTagTextColor } from '../reducers/settings';import {- actions as AppActions,- getSelectedEntries,- isReadOnlyMode+ actions as AppActions,+ getSelectedEntries,+ isReadOnlyMode} from '../reducers/app';import SmartTags from '../reducers/smart-tags';const isTagLibraryReadOnly =- window.ExtTagLibrary && window.ExtTagLibrary.length > 0;+ window.ExtTagLibrary && window.ExtTagLibrary.length > 0;type Props = {- classes: Object,- style: Object,- isReadOnlyMode: boolean,- tagTextColor: string,- tagBackgroundColor: string,- tagGroups: Array<TagGroup>,- allTags: Array<Tag>,- openURLExternally: (path: string) => void,- toggleTagGroup: (expanded: boolean, uuid: string) => void,- removeTagGroup: (uuid: string) => void,- moveTagGroupUp: (uuid: string) => void,- moveTagGroupDown: (uuid: string) => void,- sortTagGroup: (uuid: string) => void,- collectTagsFromLocation: (tagGroup: TagGroup) => void,- addTags: () => void,- importTagGroups: () => void,- exportTagGroups: () => void,- toggleTagGroup: () => void,- createTagGroup: () => void,- addTag: () => void,- moveTag: () => void,- editTagGroup: () => void,- editTag: () => void,- deleteTag: () => void,- selectedEntries: Array<Object>+ classes: Object;+ style: Object;+ isReadOnlyMode: boolean;+ tagTextColor: string;+ tagBackgroundColor: string;+ tagGroups: Array<TagGroup>;+ allTags: Array<Tag>;+ openURLExternally: (path: string) => void;+ toggleTagGroup: (expanded: boolean, uuid: string) => void;+ removeTagGroup: (uuid: string) => void;+ moveTagGroupUp: (uuid: string) => void;+ moveTagGroupDown: (uuid: string) => void;+ sortTagGroup: (uuid: string) => void;+ collectTagsFromLocation: (tagGroup: TagGroup) => void;+ addTags: () => void;+ importTagGroups: () => void;+ exportTagGroups: () => void;+ toggleTagGroup: () => void;+ createTagGroup: () => void;+ addTag: () => void;+ moveTag: () => void;+ editTagGroup: () => void;+ editTag: () => void;+ deleteTag: () => void;+ selectedEntries: Array<Object>;};type State = {- tagLibraryMenuAnchorEl: Object | null,- tagLibraryMenuOpened: boolean,- tagGroupMenuAnchorEl: Object | null,- tagGroupMenuOpened: boolean,- tagMenuAnchorEl: Object,- tagMenuOpened: boolean,- selectedTagEntry: TagGroup | null,- selectedTag: Tag | null,- selectedTagGroupEntry: TagGroup | null,- isCreateTagGroupDialogOpened: boolean,- isEditTagGroupDialogOpened: boolean,- isDeleteTagGroupDialogOpened: boolean,- isCreateTagDialogOpened: boolean,- isEditTagDialogOpened: boolean,- isDeleteTagDialogOpened: boolean+ tagLibraryMenuAnchorEl: Object | null;+ tagLibraryMenuOpened: boolean;+ tagGroupMenuAnchorEl: Object | null;+ tagGroupMenuOpened: boolean;+ tagMenuAnchorEl: Object;+ tagMenuOpened: boolean;+ selectedTagEntry: TagGroup | null;+ selectedTag: Tag | null;+ selectedTagGroupEntry: TagGroup | null;+ isCreateTagGroupDialogOpened: boolean;+ isEditTagGroupDialogOpened: boolean;+ isDeleteTagGroupDialogOpened: boolean;+ isCreateTagDialogOpened: boolean;+ isEditTagDialogOpened: boolean;+ isDeleteTagDialogOpened: boolean;};class TagLibrary extends React.Component<Props, State> {- state = {- tagGroupMenuAnchorEl: null,- tagGroupMenuOpened: false,- tagMenuAnchorEl: null,- tagMenuOpened: false,- tagLibraryMenuAnchorEl: null,- tagLibraryMenuOpened: false,- selectedTagGroupEntry: null,- selectedTagEntry: null,- selectedTag: null,- isCreateTagGroupDialogOpened: false,- isEditTagGroupDialogOpened: false,- isDeleteTagGroupDialogOpened: false,- isCreateTagDialogOpened: false,- isEditTagDialogOpened: false,- isDeleteTagDialogOpened: false- };+ state = {+ tagGroupMenuAnchorEl: null,+ tagGroupMenuOpened: false,+ tagMenuAnchorEl: null,+ tagMenuOpened: false,+ tagLibraryMenuAnchorEl: null,+ tagLibraryMenuOpened: false,+ selectedTagGroupEntry: null,+ selectedTagEntry: null,+ selectedTag: null,+ isCreateTagGroupDialogOpened: false,+ isEditTagGroupDialogOpened: false,+ isDeleteTagGroupDialogOpened: false,+ isCreateTagDialogOpened: false,+ isEditTagDialogOpened: false,+ isDeleteTagDialogOpened: false+ };- handleCloseDialogs = () => {- this.setState({- isCreateLocationDialogOpened: false,- isEditLocationDialogOpened: false,- isDeleteLocationDialogOpened: false,- isDeleteDirectoryDialogOpened: false,- isCreateDirectoryDialogOpened: false,- isRenameDirectoryDialogOpened: false- });- };+ handleCloseDialogs = () => {+ this.setState({+ isCreateLocationDialogOpened: false,+ isEditLocationDialogOpened: false,+ isDeleteLocationDialogOpened: false,+ isDeleteDirectoryDialogOpened: false,+ isCreateDirectoryDialogOpened: false,+ isRenameDirectoryDialogOpened: false+ });+ };- handleTagGroupTitleClick = (event: Object, tagGroup) => {- this.props.toggleTagGroup(tagGroup.expanded, tagGroup.uuid);- };+ handleTagGroupTitleClick = (event: Object, tagGroup) => {+ this.props.toggleTagGroup(tagGroup.expanded, tagGroup.uuid);+ };- handleTagGroupMenu = (event: Object, tagGroup) => {- this.setState({- tagGroupMenuOpened: true,- tagGroupMenuAnchorEl: event.currentTarget,- selectedTagGroupEntry: tagGroup- });- };+ handleTagGroupMenu = (event: Object, tagGroup) => {+ this.setState({+ tagGroupMenuOpened: true,+ tagGroupMenuAnchorEl: event.currentTarget,+ selectedTagGroupEntry: tagGroup+ });+ };- handleTagMenu = (event: Object, tag, tagGroup) => {- this.setState({- tagMenuOpened: true,- tagMenuAnchorEl: event.currentTarget,- selectedTagGroupEntry: tagGroup,- selectedTag: tag- });- };+ handleTagMenu = (event: Object, tag, tagGroup) => {+ this.setState({+ tagMenuOpened: true,+ tagMenuAnchorEl: event.currentTarget,+ selectedTagGroupEntry: tagGroup,+ selectedTag: tag+ });+ };- handleTagLibraryMenu = (event: Object) => {- this.setState({- tagLibraryMenuOpened: true,- tagLibraryMenuAnchorEl: event.currentTarget- });- };+ handleTagLibraryMenu = (event: Object) => {+ this.setState({+ tagLibraryMenuOpened: true,+ tagLibraryMenuAnchorEl: event.currentTarget+ });+ };- showCreateTagGroupDialog = () => {- this.setState({ isCreateTagGroupDialogOpened: true });- };+ showCreateTagGroupDialog = () => {+ this.setState({ isCreateTagGroupDialogOpened: true });+ };- showCreateTagsDialog = () => {- this.setState({ isCreateTagDialogOpened: true });- this.handleCloseTagGroupMenu();- };+ showCreateTagsDialog = () => {+ this.setState({ isCreateTagDialogOpened: true });+ this.handleCloseTagGroupMenu();+ };- showEditTagGroupDialog = () => {- this.setState({ isEditTagGroupDialogOpened: true });- this.handleCloseTagGroupMenu();- };+ showEditTagGroupDialog = () => {+ this.setState({ isEditTagGroupDialogOpened: true });+ this.handleCloseTagGroupMenu();+ };- showDeleteTagGroupDialog = () => {- this.setState({ isDeleteTagGroupDialogOpened: true });- this.handleCloseTagGroupMenu();- };+ showDeleteTagGroupDialog = () => {+ this.setState({ isDeleteTagGroupDialogOpened: true });+ this.handleCloseTagGroupMenu();+ };- handleCloseDialogs = () => {- this.setState({- isCreateTagGroupDialogOpened: false,- isEditTagGroupDialogOpened: false,- isDeleteTagGroupDialogOpened: false,- isCreateTagDialogOpened: false,- isEditTagDialogOpened: false,- isDeleteTagDialogOpened: false- });- };+ handleCloseDialogs = () => {+ this.setState({+ isCreateTagGroupDialogOpened: false,+ isEditTagGroupDialogOpened: false,+ isDeleteTagGroupDialogOpened: false,+ isCreateTagDialogOpened: false,+ isEditTagDialogOpened: false,+ isDeleteTagDialogOpened: false+ });+ };- handleCloseTagGroupMenu = () => {- this.setState({- tagGroupMenuOpened: false- });- };+ handleCloseTagGroupMenu = () => {+ this.setState({+ tagGroupMenuOpened: false+ });+ };- handleCloseTagMenu = () => {- this.setState({- tagMenuOpened: false- });- };+ handleCloseTagMenu = () => {+ this.setState({+ tagMenuOpened: false+ });+ };- handleCloseImportExportMenu = () => {- this.setState({ tagLibraryMenuOpened: false });- };+ handleCloseImportExportMenu = () => {+ this.setState({ tagLibraryMenuOpened: false });+ };- renderTagGroup = tagGroup => {- const isReadOnly = tagGroup.readOnly || isTagLibraryReadOnly;- return (- <div key={tagGroup.uuid}>- <ListItem- data-tid={'tagLibraryTagGroupTitle_' + tagGroup.title}- button- style={{ maxWidth: 250 }}- className={this.props.classes.listItem}- onClick={event => this.handleTagGroupTitleClick(event, tagGroup)}- onContextMenu={event => this.handleTagGroupMenu(event, tagGroup)}- title={- 'Number of tags in this tag group: ' + tagGroup.children.length- }- >- <ListItemIcon style={{ minWidth: 'auto' }}>- {tagGroup.expanded ? <ArrowDownIcon /> : <ArrowRightIcon />}- </ListItemIcon>- <Typography- variant="inherit"- className={this.props.classes.header}- style={{ paddingLeft: 0 }}- data-tid="locationTitleElement"- noWrap- >- {tagGroup.title + ' '}- {!tagGroup.expanded && (- <span className={this.props.classes.badge}>- {tagGroup.children.length}- </span>- )}- </Typography>- {!isReadOnly && (- <ListItemSecondaryAction>- <IconButton- aria-label={i18n.t('core:options')}- aria-haspopup="true"- edge="end"- data-tid={- 'tagLibraryMoreButton_' + tagGroup.title.replace(/ /g, '_')- }- onClick={event => this.handleTagGroupMenu(event, tagGroup)}- onContextMenu={event =>- this.handleTagGroupMenu(event, tagGroup)- }- >- <MoreVertIcon />- </IconButton>- </ListItemSecondaryAction>- )}- </ListItem>- <Collapse in={tagGroup.expanded} unmountOnExit>- <TagGroupContainer- taggroup={tagGroup}- data-tid={'tagGroupContainer_' + tagGroup.title}- >- {tagGroup.children &&- tagGroup.children.map((tag: Tag) => {- if (this.props.isReadOnlyMode) {- return (- <TagContainer- key={tagGroup.uuid + tag.title}- tag={tag}- tagGroup={tagGroup}- handleTagMenu={this.handleTagMenu}- addTags={this.props.addTags}- moveTag={this.props.moveTag}- selectedEntries={this.props.selectedEntries}- />- );- }- return (- <TagContainerDnd- key={tagGroup.uuid + tag.title}- tag={tag}- tagGroup={tagGroup}- handleTagMenu={this.handleTagMenu}- addTags={this.props.addTags}- moveTag={this.props.moveTag}- selectedEntries={this.props.selectedEntries}- />- );- })}- </TagGroupContainer>- </Collapse>- </div>- );- };+ renderTagGroup = tagGroup => {+ const isReadOnly = tagGroup.readOnly || isTagLibraryReadOnly;+ return (+ <div key={tagGroup.uuid}>+ <ListItem+ data-tid={'tagLibraryTagGroupTitle_' + tagGroup.title}+ button+ style={{ maxWidth: 250 }}+ className={this.props.classes.listItem}+ onClick={event => this.handleTagGroupTitleClick(event, tagGroup)}+ onContextMenu={event => this.handleTagGroupMenu(event, tagGroup)}+ title={+ 'Number of tags in this tag group: ' + tagGroup.children.length+ }+ >+ <ListItemIcon style={{ minWidth: 'auto' }}>+ {tagGroup.expanded ? <ArrowDownIcon /> : <ArrowRightIcon />}+ </ListItemIcon>+ <Typography+ variant="inherit"+ className={this.props.classes.header}+ style={{ paddingLeft: 0 }}+ data-tid="locationTitleElement"+ noWrap+ >+ {tagGroup.title + ' '}+ {!tagGroup.expanded && (+ <span className={this.props.classes.badge}>+ {tagGroup.children.length}+ </span>+ )}+ </Typography>+ {!isReadOnly && (+ <ListItemSecondaryAction>+ <IconButton+ aria-label={i18n.t('core:options')}+ aria-haspopup="true"+ edge="end"+ data-tid={+ 'tagLibraryMoreButton_' + tagGroup.title.replace(/ /g, '_')+ }+ onClick={event => this.handleTagGroupMenu(event, tagGroup)}+ onContextMenu={event =>+ this.handleTagGroupMenu(event, tagGroup)+ }+ >+ <MoreVertIcon />+ </IconButton>+ </ListItemSecondaryAction>+ )}+ </ListItem>+ <Collapse in={tagGroup.expanded} unmountOnExit>+ <TagGroupContainer+ taggroup={tagGroup}+ data-tid={'tagGroupContainer_' + tagGroup.title}+ >+ {tagGroup.children &&+ tagGroup.children.map((tag: Tag) => {+ if (this.props.isReadOnlyMode) {+ return (+ <TagContainer+ key={tagGroup.uuid + tag.title}+ tag={tag}+ tagGroup={tagGroup}+ handleTagMenu={this.handleTagMenu}+ addTags={this.props.addTags}+ moveTag={this.props.moveTag}+ selectedEntries={this.props.selectedEntries}+ />+ );+ }+ return (+ <TagContainerDnd+ key={tagGroup.uuid + tag.title}+ tag={tag}+ tagGroup={tagGroup}+ handleTagMenu={this.handleTagMenu}+ addTags={this.props.addTags}+ moveTag={this.props.moveTag}+ selectedEntries={this.props.selectedEntries}+ />+ );+ })}+ </TagGroupContainer>+ </Collapse>+ </div>+ );+ };- render() {- const { tagGroups, classes, allTags } = this.props;+ render() {+ const { tagGroups, classes, allTags } = this.props;- return (- <div className={classes.panel} style={this.props.style}>- <CustomLogo />- <div className={classes.toolbar}>- <Typography- className={classNames(classes.panelTitle, classes.header)}- title={- 'Your tag library contains ' +- allTags.length +- ' tags \ndistributed in ' +- tagGroups.length +- ' tag groups'- }- type="subtitle1"- >- {i18n.t('core:tagLibrary')}- </Typography>- {!isTagLibraryReadOnly && (- <IconButton- data-tid="tagLibraryMenu"- onClick={this.handleTagLibraryMenu}- >- <MoreVertIcon />- </IconButton>- )}- </div>- <ConfirmDialog- open={this.state.isDeleteTagGroupDialogOpened}- onClose={this.handleCloseDialogs}- title={i18n.t('core:deleteTagGroup')}- content={i18n.t('core:deleteTagGroupContentConfirm', {- tagGroup: this.state.selectedTagGroupEntry- ? this.state.selectedTagGroupEntry.title- : ''- })}- confirmCallback={result => {- if (result && this.state.selectedTagGroupEntry) {- this.props.removeTagGroup(this.state.selectedTagGroupEntry.uuid);- }- }}- cancelDialogTID={'cancelDeleteTagGroupDialog'}- confirmDialogTID={'confirmDeleteTagGroupDialog'}- />- <CreateTagGroupDialog- key={uuidv1()}- open={this.state.isCreateTagGroupDialogOpened}- onClose={this.handleCloseDialogs}- createTagGroup={this.props.createTagGroup}- color={this.props.tagBackgroundColor}- textcolor={this.props.tagTextColor}- />- <CreateTagsDialog- key={uuidv1()}- open={this.state.isCreateTagDialogOpened}- onClose={this.handleCloseDialogs}- addTag={this.props.addTag}- selectedTagGroupEntry={this.state.selectedTagGroupEntry}- />- <EditTagGroupDialog- open={this.state.isEditTagGroupDialogOpened}- onClose={this.handleCloseDialogs}- editTagGroup={this.props.editTagGroup}- selectedTagGroupEntry={this.state.selectedTagGroupEntry}- />- <TagGroupMenu- anchorEl={this.state.tagGroupMenuAnchorEl}- open={this.state.tagGroupMenuOpened}- onClose={this.handleCloseTagGroupMenu}- selectedTagGroupEntry={this.state.selectedTagGroupEntry}- showCreateTagsDialog={this.showCreateTagsDialog}- showDeleteTagGroupDialog={this.showDeleteTagGroupDialog}- handleCloseTagGroupMenu={this.handleCloseTagGroupMenu}- showEditTagGroupDialog={this.showEditTagGroupDialog}- moveTagGroupUp={this.props.moveTagGroupUp}- moveTagGroupDown={this.props.moveTagGroupDown}- sortTagGroup={this.props.sortTagGroup}- collectTagsFromLocation={this.props.collectTagsFromLocation}- />- <TagLibraryMenu- anchorEl={this.state.tagLibraryMenuAnchorEl}- open={this.state.tagLibraryMenuOpened}- onClose={this.handleCloseImportExportMenu}- tagGroups={tagGroups}- importTagGroups={this.props.importTagGroups}- exportTagGroups={this.props.exportTagGroups}- showCreateTagGroupDialog={this.showCreateTagGroupDialog}- openURLExternally={this.props.openURLExternally}- />- <TagMenu- anchorEl={this.state.tagMenuAnchorEl}- open={this.state.tagMenuOpened}- onClose={this.handleCloseTagMenu}- selectedTagGroupEntry={this.state.selectedTagGroupEntry}- selectedTag={this.state.selectedTag}- editTag={this.props.editTag}- deleteTag={this.props.deleteTag}- />- <div- className={classes.taggroupsArea}- data-tid="tagLibraryTagGroupList"- >- <List style={{ paddingTop: 0 }}>- {SmartTags(i18n).map(this.renderTagGroup)}- </List>- <List style={{ paddingTop: 0 }}>- {tagGroups.map(this.renderTagGroup)}- </List>- </div>- </div>- );- }+ return (+ <div className={classes.panel} style={this.props.style}>+ <CustomLogo />+ <div className={classes.toolbar}>+ <Typography+ className={classNames(classes.panelTitle, classes.header)}+ title={+ 'Your tag library contains ' ++ allTags.length ++ ' tags \ndistributed in ' ++ tagGroups.length ++ ' tag groups'+ }+ type="subtitle1"+ >+ {i18n.t('core:tagLibrary')}+ </Typography>+ {!isTagLibraryReadOnly && (+ <IconButton+ data-tid="tagLibraryMenu"+ onClick={this.handleTagLibraryMenu}+ >+ <MoreVertIcon />+ </IconButton>+ )}+ </div>+ <ConfirmDialog+ open={this.state.isDeleteTagGroupDialogOpened}+ onClose={this.handleCloseDialogs}+ title={i18n.t('core:deleteTagGroup')}+ content={i18n.t('core:deleteTagGroupContentConfirm', {+ tagGroup: this.state.selectedTagGroupEntry+ ? this.state.selectedTagGroupEntry.title+ : ''+ })}+ confirmCallback={result => {+ if (result && this.state.selectedTagGroupEntry) {+ this.props.removeTagGroup(this.state.selectedTagGroupEntry.uuid);+ }+ }}+ cancelDialogTID={'cancelDeleteTagGroupDialog'}+ confirmDialogTID={'confirmDeleteTagGroupDialog'}+ />+ <CreateTagGroupDialog+ key={uuidv1()}+ open={this.state.isCreateTagGroupDialogOpened}+ onClose={this.handleCloseDialogs}+ createTagGroup={this.props.createTagGroup}+ color={this.props.tagBackgroundColor}+ textcolor={this.props.tagTextColor}+ />+ <CreateTagsDialog+ key={uuidv1()}+ open={this.state.isCreateTagDialogOpened}+ onClose={this.handleCloseDialogs}+ addTag={this.props.addTag}+ selectedTagGroupEntry={this.state.selectedTagGroupEntry}+ />+ <EditTagGroupDialog+ open={this.state.isEditTagGroupDialogOpened}+ onClose={this.handleCloseDialogs}+ editTagGroup={this.props.editTagGroup}+ selectedTagGroupEntry={this.state.selectedTagGroupEntry}+ />+ <TagGroupMenu+ anchorEl={this.state.tagGroupMenuAnchorEl}+ open={this.state.tagGroupMenuOpened}+ onClose={this.handleCloseTagGroupMenu}+ selectedTagGroupEntry={this.state.selectedTagGroupEntry}+ showCreateTagsDialog={this.showCreateTagsDialog}+ showDeleteTagGroupDialog={this.showDeleteTagGroupDialog}+ handleCloseTagGroupMenu={this.handleCloseTagGroupMenu}+ showEditTagGroupDialog={this.showEditTagGroupDialog}+ moveTagGroupUp={this.props.moveTagGroupUp}+ moveTagGroupDown={this.props.moveTagGroupDown}+ sortTagGroup={this.props.sortTagGroup}+ collectTagsFromLocation={this.props.collectTagsFromLocation}+ />+ <TagLibraryMenu+ anchorEl={this.state.tagLibraryMenuAnchorEl}+ open={this.state.tagLibraryMenuOpened}+ onClose={this.handleCloseImportExportMenu}+ tagGroups={tagGroups}+ importTagGroups={this.props.importTagGroups}+ exportTagGroups={this.props.exportTagGroups}+ showCreateTagGroupDialog={this.showCreateTagGroupDialog}+ openURLExternally={this.props.openURLExternally}+ />+ <TagMenu+ anchorEl={this.state.tagMenuAnchorEl}+ open={this.state.tagMenuOpened}+ onClose={this.handleCloseTagMenu}+ selectedTagGroupEntry={this.state.selectedTagGroupEntry}+ selectedTag={this.state.selectedTag}+ editTag={this.props.editTag}+ deleteTag={this.props.deleteTag}+ />+ <div+ className={classes.taggroupsArea}+ data-tid="tagLibraryTagGroupList"+ >+ <List style={{ paddingTop: 0 }}>+ {SmartTags(i18n).map(this.renderTagGroup)}+ </List>+ <List style={{ paddingTop: 0 }}>+ {tagGroups.map(this.renderTagGroup)}+ </List>+ </div>+ </div>+ );+ }}function mapStateToProps(state) {- return {- tagGroups: getTagGroups(state),- tagBackgroundColor: getTagColor(state),- tagTextColor: getTagTextColor(state),- selectedEntries: getSelectedEntries(state),- allTags: getAllTags(state),- isReadOnlyMode: isReadOnlyMode(state)- };+ return {+ tagGroups: getTagGroups(state),+ tagBackgroundColor: getTagColor(state),+ tagTextColor: getTagTextColor(state),+ selectedEntries: getSelectedEntries(state),+ allTags: getAllTags(state),+ isReadOnlyMode: isReadOnlyMode(state)+ };}function mapDispatchToProps(dispatch) {- return bindActionCreators(- {- ...TagLibraryActions, // TODO connect only the really needed- addTags: TaggingActions.addTags,- collectTagsFromLocation: TaggingActions.collectTagsFromLocation,- openURLExternally: AppActions.openURLExternally- },- dispatch- );+ return bindActionCreators(+ {+ ...TagLibraryActions, // TODO connect only the really needed+ addTags: TaggingActions.addTags,+ collectTagsFromLocation: TaggingActions.collectTagsFromLocation,+ openURLExternally: AppActions.openURLExternally+ },+ dispatch+ );}export default withStyles(styles)(- connect(mapStateToProps, mapDispatchToProps)(TagLibrary)+ connect(mapStateToProps, mapDispatchToProps)(TagLibrary));diff --git a/app/components/TagsSelect.tsx b/app/components/TagsSelect.tsxindex bb9849f0b..b7cd6003d 100644--- a/app/components/TagsSelect.tsx+++ b/app/components/TagsSelect.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';@@ -29,277 +28,277 @@ import CreatableSelect from 'react-select/creatable';import NoSsr from '@material-ui/core/NoSsr';import TextField from '@material-ui/core/TextField';import i18n from '../services/i18n';-import { type Tag, getAllTags } from '../reducers/taglibrary';+import { Tag, getAllTags } from '../reducers/taglibrary';import { getTagColor, getTagTextColor } from '../reducers/settings';import TagContainer from './TagContainer';const styles = theme => ({- root: {- flexGrow: 1- // height: 250,- /* '& div': { //https://github.com/JedWatson/react-select/issues/1085+ root: {+ flexGrow: 1+ // height: 250,+ /* '& div': { //https://github.com/JedWatson/react-select/issues/1085zIndex: 1} */- },- input: {- display: 'flex',- padding: 0,- height: 'auto'- },- valueContainer: {- display: 'flex',- flexWrap: 'wrap',- flex: 1,- alignItems: 'center',- overflow: 'hidden'- },- noOptionsMessage: {- padding: theme.spacing(1, 2)- },- singleValue: {- fontSize: 16- },- placeholder: {- position: 'absolute',- left: 2,- bottom: 6,- fontSize: 16- },- paper: {- position: 'absolute',- zIndex: 2,- marginTop: theme.spacing(1),- left: 0,- right: 0- }+ },+ input: {+ display: 'flex',+ padding: 0,+ height: 'auto'+ },+ valueContainer: {+ display: 'flex',+ flexWrap: 'wrap',+ flex: 1,+ alignItems: 'center',+ overflow: 'hidden'+ },+ noOptionsMessage: {+ padding: theme.spacing(1, 2)+ },+ singleValue: {+ fontSize: 16+ },+ placeholder: {+ position: 'absolute',+ left: 2,+ bottom: 6,+ fontSize: 16+ },+ paper: {+ position: 'absolute',+ zIndex: 2,+ marginTop: theme.spacing(1),+ left: 0,+ right: 0+ }});function NoOptionsMessage(props) {- return (- <Typography- color="textSecondary"- style={{ display: 'block' }}- className={props.selectProps.classes.noOptionsMessage}- {...props.innerProps}- >- {props.children}- </Typography>- );+ return (+ <Typography+ color="textSecondary"+ style={{ display: 'block' }}+ className={props.selectProps.classes.noOptionsMessage}+ {...props.innerProps}+ >+ {props.children}+ </Typography>+ );}function inputComponent({ inputRef, ...props }) {- return <div ref={inputRef} {...props} />;+ return <div ref={inputRef} {...props} />;}function Control(props) {- const {- children,- innerProps,- innerRef,- selectProps: { classes, TextFieldProps }- } = props;+ const {+ children,+ innerProps,+ innerRef,+ selectProps: { classes, TextFieldProps }+ } = props;- return (- <TextField- fullWidth- InputProps={{- inputComponent,- inputProps: {- className: classes.input,- ref: innerRef,- children,- ...innerProps- }- }}- {...TextFieldProps}- />- );+ return (+ <TextField+ fullWidth+ InputProps={{+ inputComponent,+ inputProps: {+ className: classes.input,+ ref: innerRef,+ children,+ ...innerProps+ }+ }}+ {...TextFieldProps}+ />+ );}function Option(props) {- return (- <MenuItem- ref={props.innerRef}- selected={props.isFocused}- component="div"- style={{- fontWeight: props.isSelected ? 500 : 400- }}- {...props.innerProps}- >- {props.children}- </MenuItem>- );+ return (+ <MenuItem+ ref={props.innerRef}+ selected={props.isFocused}+ component="div"+ style={{+ fontWeight: props.isSelected ? 500 : 400+ }}+ {...props.innerProps}+ >+ {props.children}+ </MenuItem>+ );}function Placeholder(props) {- return (- <Typography- color="textSecondary"- style={{ display: 'block' }}- className={props.selectProps.classes.placeholder}- {...props.innerProps}- >- {props.children}- </Typography>- );+ return (+ <Typography+ color="textSecondary"+ style={{ display: 'block' }}+ className={props.selectProps.classes.placeholder}+ {...props.innerProps}+ >+ {props.children}+ </Typography>+ );}function SingleValue(props) {- return (- <Typography- className={props.selectProps.classes.singleValue}- {...props.innerProps}- >- {props.children}- </Typography>- );+ return (+ <Typography+ className={props.selectProps.classes.singleValue}+ {...props.innerProps}+ >+ {props.children}+ </Typography>+ );}function ValueContainer(props) {- return (- <div className={props.selectProps.classes.valueContainer}>- {props.children}- </div>- );+ return (+ <div className={props.selectProps.classes.valueContainer}>+ {props.children}+ </div>+ );}function MultiValue(props) {- return (- <TagContainer- key={props.data.id || props.data.title}- tag={props.data}- tagMode={'remove'}- deleteIcon={<CloseIcon {...props.removeProps} />}- />- );+ return (+ <TagContainer+ key={props.data.id || props.data.title}+ tag={props.data}+ tagMode={'remove'}+ deleteIcon={<CloseIcon {...props.removeProps} />}+ />+ );}function Menu(props) {- return (- <Paper- elevation={22}- square- className={props.selectProps.classes.paper}- {...props.innerProps}- >- {props.children}- </Paper>- );+ return (+ <Paper+ elevation={22}+ square+ className={props.selectProps.classes.paper}+ {...props.innerProps}+ >+ {props.children}+ </Paper>+ );}const components = {- Control,- Menu,- MultiValue,- NoOptionsMessage,- Option,- Placeholder,- SingleValue,- ValueContainer+ Control,+ Menu,+ MultiValue,+ NoOptionsMessage,+ Option,+ Placeholder,+ SingleValue,+ ValueContainer};type Props = {- classes: Object,- theme: Object,- tags: Array<tag>,- tagSearchType: string,- handleChange: () => void,- allTags: Array<Tag>,- isReadOnlyMode?: boolean,- placeholderText: string+ classes: Object;+ theme: Object;+ tags: Array<tag>;+ tagSearchType: string;+ handleChange: () => void;+ allTags: Array<Tag>;+ isReadOnlyMode?: boolean;+ placeholderText: string;};const TagsSelect = (props: Props) => {- function handleChange(newValue: any, actionMeta: any) {- if (actionMeta.action === 'select-option') {- props.handleChange(props.tagSearchType, newValue, actionMeta.action);- } else if (actionMeta.action === 'create-option') {- props.allTags.push(newValue);- props.handleChange(props.tagSearchType, newValue, actionMeta.action);- } else if (actionMeta.action === 'remove-value') {- props.handleChange(props.tagSearchType, newValue, actionMeta.action);- } else if (actionMeta.action === 'clear') {- props.handleChange(props.tagSearchType, [], actionMeta.action);- }- }+ function handleChange(newValue: any, actionMeta: any) {+ if (actionMeta.action === 'select-option') {+ props.handleChange(props.tagSearchType, newValue, actionMeta.action);+ } else if (actionMeta.action === 'create-option') {+ props.allTags.push(newValue);+ props.handleChange(props.tagSearchType, newValue, actionMeta.action);+ } else if (actionMeta.action === 'remove-value') {+ props.handleChange(props.tagSearchType, newValue, actionMeta.action);+ } else if (actionMeta.action === 'clear') {+ props.handleChange(props.tagSearchType, [], actionMeta.action);+ }+ }- function isValidNewOption(inputValue, selectValue, selectOptions) {- const trimmedInput = inputValue.trim();- return (- trimmedInput.trim().length > 0 &&- !trimmedInput.includes(' ') &&- !trimmedInput.includes('#') &&- !trimmedInput.includes(',') &&- !selectOptions.find(option => option.name === inputValue)- );- }+ function isValidNewOption(inputValue, selectValue, selectOptions) {+ const trimmedInput = inputValue.trim();+ return (+ trimmedInput.trim().length > 0 &&+ !trimmedInput.includes(' ') &&+ !trimmedInput.includes('#') &&+ !trimmedInput.includes(',') &&+ !selectOptions.find(option => option.name === inputValue)+ );+ }- const {- classes,- theme,- allTags,- tags,- defaultBackgroundColor,- defaultTextColor,- isReadOnlyMode = false,- placeholderText = ''- } = props;+ const {+ classes,+ theme,+ allTags,+ tags,+ defaultBackgroundColor,+ defaultTextColor,+ isReadOnlyMode = false,+ placeholderText = ''+ } = props;- const selectStyles = {- input: base => ({- ...base,- color: theme.palette.text.primary,- '& input': {- font: 'inherit'- }- })- };+ const selectStyles = {+ input: base => ({+ ...base,+ color: theme.palette.text.primary,+ '& input': {+ font: 'inherit'+ }+ })+ };- return (- <div className={classes.root}>- <NoSsr>- <CreatableSelect- isClearable={false}- isDisabled={isReadOnlyMode}- classes={classes}- options={allTags}- getOptionLabel={option => option.title}- getOptionValue={option => option.id || option.title}- isValidNewOption={isValidNewOption}- getNewOptionData={(inputValue, optionLabel) => ({- id: uuidv1(),- title: optionLabel,- color: defaultBackgroundColor,- textcolor: defaultTextColor- })}- styles={selectStyles}- fullWidth={true}- components={components}- /* textFieldProps={{+ return (+ <div className={classes.root}>+ <NoSsr>+ <CreatableSelect+ isClearable={false}+ isDisabled={isReadOnlyMode}+ classes={classes}+ options={allTags}+ getOptionLabel={option => option.title}+ getOptionValue={option => option.id || option.title}+ isValidNewOption={isValidNewOption}+ getNewOptionData={(inputValue, optionLabel) => ({+ id: uuidv1(),+ title: optionLabel,+ color: defaultBackgroundColor,+ textcolor: defaultTextColor+ })}+ styles={selectStyles}+ fullWidth={true}+ components={components}+ /* textFieldProps={{label: 'title',InputLabelProps: {shrink: true,},}} */- value={tags}- onChange={handleChange}- placeholder={placeholderText}- isMulti- formatCreateLabel={label => label}- // isSearchable- />- </NoSsr>- </div>- );+ value={tags}+ onChange={handleChange}+ placeholder={placeholderText}+ isMulti+ formatCreateLabel={label => label}+ // isSearchable+ />+ </NoSsr>+ </div>+ );};const mapStateToProps = state => ({- allTags: getAllTags(state),- defaultBackgroundColor: getTagColor(state),- defaultTextColor: getTagTextColor(state)+ allTags: getAllTags(state),+ defaultBackgroundColor: getTagColor(state),+ defaultTextColor: getTagTextColor(state)});export default connect(mapStateToProps)(- withStyles(styles, { withTheme: true })(TagsSelect)+ withStyles(styles, { withTheme: true })(TagsSelect));diff --git a/app/components/TargetFileBox.tsx b/app/components/TargetFileBox.tsxindex abb451b1d..291382848 100644--- a/app/components/TargetFileBox.tsx+++ b/app/components/TargetFileBox.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/TargetMoveFileBox.tsx b/app/components/TargetMoveFileBox.tsxindex 1c241744f..0d73d7ac7 100644--- a/app/components/TargetMoveFileBox.tsx+++ b/app/components/TargetMoveFileBox.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/TransparentBackground.tsx b/app/components/TransparentBackground.tsxindex 9c730073f..173f08453 100644--- a/app/components/TransparentBackground.tsx+++ b/app/components/TransparentBackground.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/VerticalNavigation.tsx b/app/components/VerticalNavigation.tsxindex 290bae38d..a44bc59d4 100644--- a/app/components/VerticalNavigation.tsx+++ b/app/components/VerticalNavigation.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';@@ -41,252 +40,252 @@ import LocationManager from '../components/LocationManager';import HelpFeedbackPanel from '../components/HelpFeedbackPanel';import i18n from '../services/i18n';import { Pro } from '../pro';-import { type Tag } from '../reducers/taglibrary';+import { Tag } from '../reducers/taglibrary';import {- actions as AppActions,- getDirectoryPath,- isSettingsDialogOpened,- isLocationManagerPanelOpened,- isTagLibraryPanelOpened,- isSearchPanelOpened,- isPerspectivesPanelOpened,- isHelpFeedbackPanelOpened,- isReadOnlyMode+ actions as AppActions,+ getDirectoryPath,+ isSettingsDialogOpened,+ isLocationManagerPanelOpened,+ isTagLibraryPanelOpened,+ isSearchPanelOpened,+ isPerspectivesPanelOpened,+ isHelpFeedbackPanelOpened,+ isReadOnlyMode} from '../reducers/app';import { actions as SettingsActions, isFirstRun } from '../reducers/settings';import LoadingLazy from './LoadingLazy';const ProTeaserDialog = React.lazy(() =>- import(/* webpackChunkName: "ProTeaserDialog" */ './dialogs/ProTeaserDialog')+ import(/* webpackChunkName: "ProTeaserDialog" */ './dialogs/ProTeaserDialog'));const ProTeaserDialogAsync = props => (- <React.Suspense fallback={<LoadingLazy />}>- <ProTeaserDialog {...props} />- </React.Suspense>+ <React.Suspense fallback={<LoadingLazy />}>+ <ProTeaserDialog {...props} />+ </React.Suspense>);type Props = {- theme: Object,- isFirstRun: boolean,- directoryPath: string,- setFirstRun: (isFirstRun: boolean) => void,- toggleOnboardingDialog: () => void,- toggleCreateFileDialog: () => void,- toggleAboutDialog: () => void,- toggleKeysDialog: () => void,- toggleSettingsDialog: () => void,- isSettingsDialogOpened: () => void,- isLocationManagerPanelOpened: boolean,- openLocationManagerPanel: () => void,- isTagLibraryPanelOpened: boolean,- openTagLibraryPanel: () => void,- isSearchPanelOpened: boolean,- openSearchPanel: () => void,- isPerspectivesPanelOpened: boolean,- // openPerspectivesPanel: () => void,- isHelpFeedbackPanelOpened: boolean,- openHelpFeedbackPanel: () => void,- closeAllVerticalPanels: () => void,- openFileNatively: (url: string) => void,- openURLExternally: (url: string) => void,- switchTheme: () => void,- showNotification: (message: string) => void,- isReadOnlyMode: boolean+ theme: Object;+ isFirstRun: boolean;+ directoryPath: string;+ setFirstRun: (isFirstRun: boolean) => void;+ toggleOnboardingDialog: () => void;+ toggleCreateFileDialog: () => void;+ toggleAboutDialog: () => void;+ toggleKeysDialog: () => void;+ toggleSettingsDialog: () => void;+ isSettingsDialogOpened: () => void;+ isLocationManagerPanelOpened: boolean;+ openLocationManagerPanel: () => void;+ isTagLibraryPanelOpened: boolean;+ openTagLibraryPanel: () => void;+ isSearchPanelOpened: boolean;+ openSearchPanel: () => void;+ isPerspectivesPanelOpened: boolean;+ // openPerspectivesPanel: () => void,+ isHelpFeedbackPanelOpened: boolean;+ openHelpFeedbackPanel: () => void;+ closeAllVerticalPanels: () => void;+ openFileNatively: (url: string) => void;+ openURLExternally: (url: string) => void;+ switchTheme: () => void;+ showNotification: (message: string) => void;+ isReadOnlyMode: boolean;};type State = {- isProTeaserVisible: boolean // evtl. redux migration+ isProTeaserVisible: boolean; // evtl. redux migration};class VerticalNavigation extends React.Component<Props, State> {- state = {- isProTeaserVisible: false- };+ state = {+ isProTeaserVisible: false+ };- styles = {- panel: {- height: '100%',- backgroundColor: '#2C001E' // 'rgb(89, 89, 89)' // '#00D1A1' // #008023- },- buttonIcon: {- width: 28,- height: 28,- color: '#d6d6d6' // this.props.theme.palette.text.primary- },- button: {- padding: 8,- width: 44,- height: 44- },- selectedButton: {- borderRadius: 0,- backgroundColor: '#880E4F'- },- settingsButton: {- position: 'absolute',- bottom: 0,- left: 0- },- themingButton: {- position: 'absolute',- bottom: 45,- left: 0- },- upgradeButton: {- position: 'absolute',- bottom: 90,- left: 0- }- };+ styles = {+ panel: {+ height: '100%',+ backgroundColor: '#2C001E' // 'rgb(89, 89, 89)' // '#00D1A1' // #008023+ },+ buttonIcon: {+ width: 28,+ height: 28,+ color: '#d6d6d6' // this.props.theme.palette.text.primary+ },+ button: {+ padding: 8,+ width: 44,+ height: 44+ },+ selectedButton: {+ borderRadius: 0,+ backgroundColor: '#880E4F'+ },+ settingsButton: {+ position: 'absolute',+ bottom: 0,+ left: 0+ },+ themingButton: {+ position: 'absolute',+ bottom: 45,+ left: 0+ },+ upgradeButton: {+ position: 'absolute',+ bottom: 90,+ left: 0+ }+ };- toggleProTeaser = () => {- this.setState({ isProTeaserVisible: !this.state.isProTeaserVisible });- };+ toggleProTeaser = () => {+ this.setState({ isProTeaserVisible: !this.state.isProTeaserVisible });+ };- render() {- const {- isFirstRun,- isLocationManagerPanelOpened,- isTagLibraryPanelOpened,- isSearchPanelOpened,- isSettingsDialogOpened,- isPerspectivesPanelOpened,- isHelpFeedbackPanelOpened,- isReadOnlyMode,- toggleCreateFileDialog,- toggleAboutDialog,- toggleOnboardingDialog,- toggleSettingsDialog,- toggleKeysDialog,- openLocationManagerPanel,- openTagLibraryPanel,- openSearchPanel,- openHelpFeedbackPanel,- closeAllVerticalPanels,- switchTheme,- openFileNatively,- openURLExternally,- showNotification,- directoryPath,- setFirstRun,- theme- } = this.props;- return (- <div>- <style>- {`+ render() {+ const {+ isFirstRun,+ isLocationManagerPanelOpened,+ isTagLibraryPanelOpened,+ isSearchPanelOpened,+ isSettingsDialogOpened,+ isPerspectivesPanelOpened,+ isHelpFeedbackPanelOpened,+ isReadOnlyMode,+ toggleCreateFileDialog,+ toggleAboutDialog,+ toggleOnboardingDialog,+ toggleSettingsDialog,+ toggleKeysDialog,+ openLocationManagerPanel,+ openTagLibraryPanel,+ openSearchPanel,+ openHelpFeedbackPanel,+ closeAllVerticalPanels,+ switchTheme,+ openFileNatively,+ openURLExternally,+ showNotification,+ directoryPath,+ setFirstRun,+ theme+ } = this.props;+ return (+ <div>+ <style>+ {`#verticalNavButton:hover {border-radius: 0;background-color: #880E4F;}`}- </style>- {this.state.isProTeaserVisible && (- <ProTeaserDialogAsync- open={this.state.isProTeaserVisible}- onClose={this.toggleProTeaser}- openURLExternally={openURLExternally}- key={uuidv1()}- />- )}- <SplitPane- split="vertical"- minSize={44}- maxSize={44}- defaultSize={44}- resizerStyle={{ backgroundColor: theme.palette.divider }}- >- <div style={this.styles.panel}>- <IconButton- onClick={toggleAboutDialog}- style={{ ...this.styles.button, marginTop: 10, marginBottom: 16 }}- title={i18n.t('core:aboutTitle')}- data-tid="aboutTagSpaces"- >- <img- style={{- ...this.styles.buttonIcon,- color: this.props.theme.palette.text.primary- }}- src={LogoIcon}- alt="TagSpaces Logo"- />- </IconButton>- <IconButton- id="verticalNavButton"- onClick={() => {- if (isReadOnlyMode || !directoryPath) {- showNotification(- 'You are in read-only mode or there is no opened location'- );- } else {- toggleCreateFileDialog();- }- }}- style={{ ...this.styles.button, marginBottom: 20 }}- title={i18n.t('core:createFileTitle')}- data-tid="locationManager"- >- <NewFileIcon style={this.styles.buttonIcon} />- </IconButton>- <IconButton- id="verticalNavButton"- onClick={() => {- if (isLocationManagerPanelOpened) {- closeAllVerticalPanels();- } else {- openLocationManagerPanel();- }- }}- style={- isLocationManagerPanelOpened- ? { ...this.styles.button, ...this.styles.selectedButton }- : this.styles.button- }- title={i18n.t('core:locationManager')}- data-tid="locationManager"- >- <LocationsIcon style={this.styles.buttonIcon} />- </IconButton>- <IconButton- id="verticalNavButton"- title={i18n.t('core:tagGroupOperations')}- data-tid="tagLibrary"- onClick={() => {- if (isTagLibraryPanelOpened) {- closeAllVerticalPanels();- } else {- openTagLibraryPanel();- }- }}- style={- isTagLibraryPanelOpened- ? { ...this.styles.button, ...this.styles.selectedButton }- : this.styles.button- }- >- <TagLibraryIcon style={this.styles.buttonIcon} />- </IconButton>- <IconButton- id="verticalNavButton"- title={i18n.t('core:searchTitle')}- data-tid="search"- onClick={() => {- if (isSearchPanelOpened) {- closeAllVerticalPanels();- } else {- openSearchPanel();- }- }}- style={- isSearchPanelOpened- ? { ...this.styles.button, ...this.styles.selectedButton }- : this.styles.button- }- >- <SearchIcon style={this.styles.buttonIcon} />- </IconButton>- {/* <IconButton+ </style>+ {this.state.isProTeaserVisible && (+ <ProTeaserDialogAsync+ open={this.state.isProTeaserVisible}+ onClose={this.toggleProTeaser}+ openURLExternally={openURLExternally}+ key={uuidv1()}+ />+ )}+ <SplitPane+ split="vertical"+ minSize={44}+ maxSize={44}+ defaultSize={44}+ resizerStyle={{ backgroundColor: theme.palette.divider }}+ >+ <div style={this.styles.panel}>+ <IconButton+ onClick={toggleAboutDialog}+ style={{ ...this.styles.button, marginTop: 10, marginBottom: 16 }}+ title={i18n.t('core:aboutTitle')}+ data-tid="aboutTagSpaces"+ >+ <img+ style={{+ ...this.styles.buttonIcon,+ color: this.props.theme.palette.text.primary+ }}+ src={LogoIcon}+ alt="TagSpaces Logo"+ />+ </IconButton>+ <IconButton+ id="verticalNavButton"+ onClick={() => {+ if (isReadOnlyMode || !directoryPath) {+ showNotification(+ 'You are in read-only mode or there is no opened location'+ );+ } else {+ toggleCreateFileDialog();+ }+ }}+ style={{ ...this.styles.button, marginBottom: 20 }}+ title={i18n.t('core:createFileTitle')}+ data-tid="locationManager"+ >+ <NewFileIcon style={this.styles.buttonIcon} />+ </IconButton>+ <IconButton+ id="verticalNavButton"+ onClick={() => {+ if (isLocationManagerPanelOpened) {+ closeAllVerticalPanels();+ } else {+ openLocationManagerPanel();+ }+ }}+ style={+ isLocationManagerPanelOpened+ ? { ...this.styles.button, ...this.styles.selectedButton }+ : this.styles.button+ }+ title={i18n.t('core:locationManager')}+ data-tid="locationManager"+ >+ <LocationsIcon style={this.styles.buttonIcon} />+ </IconButton>+ <IconButton+ id="verticalNavButton"+ title={i18n.t('core:tagGroupOperations')}+ data-tid="tagLibrary"+ onClick={() => {+ if (isTagLibraryPanelOpened) {+ closeAllVerticalPanels();+ } else {+ openTagLibraryPanel();+ }+ }}+ style={+ isTagLibraryPanelOpened+ ? { ...this.styles.button, ...this.styles.selectedButton }+ : this.styles.button+ }+ >+ <TagLibraryIcon style={this.styles.buttonIcon} />+ </IconButton>+ <IconButton+ id="verticalNavButton"+ title={i18n.t('core:searchTitle')}+ data-tid="search"+ onClick={() => {+ if (isSearchPanelOpened) {+ closeAllVerticalPanels();+ } else {+ openSearchPanel();+ }+ }}+ style={+ isSearchPanelOpened+ ? { ...this.styles.button, ...this.styles.selectedButton }+ : this.styles.button+ }+ >+ <SearchIcon style={this.styles.buttonIcon} />+ </IconButton>+ {/* <IconButtontitle={i18n.t('core:perspectiveManager')}data-tid="perspectiveManager"onClick={() => {@@ -305,138 +304,138 @@ class VerticalNavigation extends React.Component<Props, State> {><PerspectivesIcon style={this.styles.buttonIcon} /></IconButton> */}- <IconButton- id="verticalNavButton"- title={i18n.t('core:helpFeedback')}- data-tid="helpFeedback"- onClick={() => {- if (isHelpFeedbackPanelOpened) {- closeAllVerticalPanels();- } else {- openHelpFeedbackPanel();- }- }}- style={- isHelpFeedbackPanelOpened- ? { ...this.styles.button, ...this.styles.selectedButton }- : this.styles.button- }- >- <HelpIcon style={this.styles.buttonIcon} />- </IconButton>- {!Pro && (- <IconButton- id="verticalNavButton"- title={i18n.t('core:upgradeToPro')}- data-tid="upgradeToPro"- onClick={this.toggleProTeaser}- style={{ ...this.styles.button, ...this.styles.upgradeButton }}- >- <UpgradeIcon- style={{- ...this.styles.buttonIcon- // color: '1DD19F'- }}- />- </IconButton>- )}- <IconButton- id="verticalNavButton"- title={i18n.t('core:switchTheme')}- data-tid="switchTheme"- onClick={switchTheme}- style={{ ...this.styles.button, ...this.styles.themingButton }}- >- <ThemingIcon style={this.styles.buttonIcon} />- </IconButton>- <IconButton- id="verticalNavButton"- title={i18n.t('core:settings')}- data-tid="settings"- onClick={toggleSettingsDialog}- style={- isSettingsDialogOpened- ? {- ...this.styles.button,- ...this.styles.settingsButton,- ...this.styles.selectedButton- }- : {- ...this.styles.button,- ...this.styles.settingsButton- }- }- >- <SettingsIcon style={this.styles.buttonIcon} />- </IconButton>- </div>- <div style={this.styles.panel}>- <LocationManager- style={{- display: isLocationManagerPanelOpened ? 'block' : 'none'- }}- />- {isTagLibraryPanelOpened && <TagLibrary />}- <Search- style={{ display: isSearchPanelOpened ? 'block' : 'none' }}- />- {isPerspectivesPanelOpened && <PerspectiveManager />}- {isHelpFeedbackPanelOpened && (- <HelpFeedbackPanel- openFileNatively={openFileNatively}- openURLExternally={openURLExternally}- toggleAboutDialog={toggleAboutDialog}- toggleKeysDialog={toggleKeysDialog}- toggleOnboardingDialog={toggleOnboardingDialog}- toggleProTeaser={this.toggleProTeaser}- />- )}- </div>- </SplitPane>- </div>- );- }+ <IconButton+ id="verticalNavButton"+ title={i18n.t('core:helpFeedback')}+ data-tid="helpFeedback"+ onClick={() => {+ if (isHelpFeedbackPanelOpened) {+ closeAllVerticalPanels();+ } else {+ openHelpFeedbackPanel();+ }+ }}+ style={+ isHelpFeedbackPanelOpened+ ? { ...this.styles.button, ...this.styles.selectedButton }+ : this.styles.button+ }+ >+ <HelpIcon style={this.styles.buttonIcon} />+ </IconButton>+ {!Pro && (+ <IconButton+ id="verticalNavButton"+ title={i18n.t('core:upgradeToPro')}+ data-tid="upgradeToPro"+ onClick={this.toggleProTeaser}+ style={{ ...this.styles.button, ...this.styles.upgradeButton }}+ >+ <UpgradeIcon+ style={{+ ...this.styles.buttonIcon+ // color: '1DD19F'+ }}+ />+ </IconButton>+ )}+ <IconButton+ id="verticalNavButton"+ title={i18n.t('core:switchTheme')}+ data-tid="switchTheme"+ onClick={switchTheme}+ style={{ ...this.styles.button, ...this.styles.themingButton }}+ >+ <ThemingIcon style={this.styles.buttonIcon} />+ </IconButton>+ <IconButton+ id="verticalNavButton"+ title={i18n.t('core:settings')}+ data-tid="settings"+ onClick={toggleSettingsDialog}+ style={+ isSettingsDialogOpened+ ? {+ ...this.styles.button,+ ...this.styles.settingsButton,+ ...this.styles.selectedButton+ }+ : {+ ...this.styles.button,+ ...this.styles.settingsButton+ }+ }+ >+ <SettingsIcon style={this.styles.buttonIcon} />+ </IconButton>+ </div>+ <div style={this.styles.panel}>+ <LocationManager+ style={{+ display: isLocationManagerPanelOpened ? 'block' : 'none'+ }}+ />+ {isTagLibraryPanelOpened && <TagLibrary />}+ <Search+ style={{ display: isSearchPanelOpened ? 'block' : 'none' }}+ />+ {isPerspectivesPanelOpened && <PerspectiveManager />}+ {isHelpFeedbackPanelOpened && (+ <HelpFeedbackPanel+ openFileNatively={openFileNatively}+ openURLExternally={openURLExternally}+ toggleAboutDialog={toggleAboutDialog}+ toggleKeysDialog={toggleKeysDialog}+ toggleOnboardingDialog={toggleOnboardingDialog}+ toggleProTeaser={this.toggleProTeaser}+ />+ )}+ </div>+ </SplitPane>+ </div>+ );+ }}function mapStateToProps(state) {- return {- isFirstRun: isFirstRun(state),- isSettingsDialogOpened: isSettingsDialogOpened(state),- isLocationManagerPanelOpened: isLocationManagerPanelOpened(state),- isTagLibraryPanelOpened: isTagLibraryPanelOpened(state),- isSearchPanelOpened: isSearchPanelOpened(state),- isPerspectivesPanelOpened: isPerspectivesPanelOpened(state),- isHelpFeedbackPanelOpened: isHelpFeedbackPanelOpened(state),- isReadOnlyMode: isReadOnlyMode(state),- directoryPath: getDirectoryPath(state)- };+ return {+ isFirstRun: isFirstRun(state),+ isSettingsDialogOpened: isSettingsDialogOpened(state),+ isLocationManagerPanelOpened: isLocationManagerPanelOpened(state),+ isTagLibraryPanelOpened: isTagLibraryPanelOpened(state),+ isSearchPanelOpened: isSearchPanelOpened(state),+ isPerspectivesPanelOpened: isPerspectivesPanelOpened(state),+ isHelpFeedbackPanelOpened: isHelpFeedbackPanelOpened(state),+ isReadOnlyMode: isReadOnlyMode(state),+ directoryPath: getDirectoryPath(state)+ };}function mapActionCreatorsToProps(dispatch) {- return bindActionCreators(- {- toggleCreateFileDialog: AppActions.toggleCreateFileDialog,- toggleOnboardingDialog: AppActions.toggleOnboardingDialog,- toggleSettingsDialog: AppActions.toggleSettingsDialog,- toggleAboutDialog: AppActions.toggleAboutDialog,- toggleKeysDialog: AppActions.toggleKeysDialog,- openLocationManagerPanel: AppActions.openLocationManagerPanel,- openTagLibraryPanel: AppActions.openTagLibraryPanel,- openSearchPanel: AppActions.openSearchPanel,- openPerspectivesPanel: AppActions.openPerspectivesPanel,- openHelpFeedbackPanel: AppActions.openHelpFeedbackPanel,- openFileNatively: AppActions.openFileNatively,- openURLExternally: AppActions.openURLExternally,- closeAllVerticalPanels: AppActions.closeAllVerticalPanels,- showNotification: AppActions.showNotification,- switchTheme: SettingsActions.switchTheme,- setFirstRun: SettingsActions.setFirstRun- },- dispatch- );+ return bindActionCreators(+ {+ toggleCreateFileDialog: AppActions.toggleCreateFileDialog,+ toggleOnboardingDialog: AppActions.toggleOnboardingDialog,+ toggleSettingsDialog: AppActions.toggleSettingsDialog,+ toggleAboutDialog: AppActions.toggleAboutDialog,+ toggleKeysDialog: AppActions.toggleKeysDialog,+ openLocationManagerPanel: AppActions.openLocationManagerPanel,+ openTagLibraryPanel: AppActions.openTagLibraryPanel,+ openSearchPanel: AppActions.openSearchPanel,+ openPerspectivesPanel: AppActions.openPerspectivesPanel,+ openHelpFeedbackPanel: AppActions.openHelpFeedbackPanel,+ openFileNatively: AppActions.openFileNatively,+ openURLExternally: AppActions.openURLExternally,+ closeAllVerticalPanels: AppActions.closeAllVerticalPanels,+ showNotification: AppActions.showNotification,+ switchTheme: SettingsActions.switchTheme,+ setFirstRun: SettingsActions.setFirstRun+ },+ dispatch+ );}export default connect(- mapStateToProps,- mapActionCreatorsToProps+ mapStateToProps,+ mapActionCreatorsToProps)(withTheme(VerticalNavigation));diff --git a/app/components/WelcomePanel.tsx b/app/components/WelcomePanel.tsxindex 4a5f15e8f..15b14c1ce 100644--- a/app/components/WelcomePanel.tsx+++ b/app/components/WelcomePanel.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/dialogs/AboutDialog.tsx b/app/components/dialogs/AboutDialog.tsxindex 26e69cfd8..44c84f802 100644--- a/app/components/dialogs/AboutDialog.tsx+++ b/app/components/dialogs/AboutDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React, { useState } from 'react';diff --git a/app/components/dialogs/AddRemoveTagsDialog.tsx b/app/components/dialogs/AddRemoveTagsDialog.tsxindex 5dfe49b3b..bd91b68eb 100644--- a/app/components/dialogs/AddRemoveTagsDialog.tsx+++ b/app/components/dialogs/AddRemoveTagsDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';@@ -31,165 +30,165 @@ import FileIcon from '@material-ui/icons/InsertDriveFileOutlined';import Typography from '@material-ui/core/Typography';import Dialog from '@material-ui/core/Dialog';import Slide from '@material-ui/core/Slide';-import { type Tag } from '../../reducers/taglibrary';+import { Tag } from '../../reducers/taglibrary';import TagsSelect from '../TagsSelect';import i18n from '../../services/i18n';import { extractFileName } from '../../utils/paths';const Transition = React.forwardRef(function Transition(props, ref) {- return <Slide direction="down" ref={ref} {...props} />;+ return <Slide direction="down" ref={ref} {...props} />;});type Props = {- open: boolean,- fullScreen: boolean,- selectedEntries: Array<Object>,- onClose: () => void,- addTags: (paths: Array<string>, tags: Array<Tag>) => void,- removeTags: (paths: Array<string>, tags: Array<Tag>) => void,- removeAllTags: (paths: Array<string>) => void+ open: boolean;+ fullScreen: boolean;+ selectedEntries: Array<any>;+ onClose: () => void;+ addTags: (paths: Array<string>, tags: Array<Tag>) => void;+ removeTags: (paths: Array<string>, tags: Array<Tag>) => void;+ removeAllTags: (paths: Array<string>) => void;};type State = {- disableConfirmButton: boolean,- open: boolean,- newlyAddedTags: Array<Tag>,- isConfirmDialogOpened: boolean+ disableConfirmButton: boolean;+ open: boolean;+ newlyAddedTags: Array<Tag>;+ isConfirmDialogOpened: boolean;};class AddRemoveTagsDialog extends React.Component<Props, State> {- state = {- disableConfirmButton: true,- newlyAddedTags: [],- open: false,- isConfirmDialogOpened: false- };+ state = {+ disableConfirmButton: true,+ newlyAddedTags: [],+ open: false,+ isConfirmDialogOpened: false+ };- handleChange = (name, value) => {- this.setState({- newlyAddedTags: value- });- };+ handleChange = (name, value) => {+ this.setState({+ newlyAddedTags: value+ });+ };- onClose = () => {- this.setState({ newlyAddedTags: [] });- this.props.onClose();- };+ onClose = () => {+ this.setState({ newlyAddedTags: [] });+ this.props.onClose();+ };- addTags = () => {- if (this.props.selectedEntries && this.props.selectedEntries.length > 0) {- const paths = [];- this.props.selectedEntries.map(entry => {- paths.push(entry.path);- return true;- });- this.props.addTags(paths, this.state.newlyAddedTags);- }- this.onClose();- };+ addTags = () => {+ if (this.props.selectedEntries && this.props.selectedEntries.length > 0) {+ const paths = [];+ this.props.selectedEntries.map(entry => {+ paths.push(entry.path);+ return true;+ });+ this.props.addTags(paths, this.state.newlyAddedTags);+ }+ this.onClose();+ };- render() {- const {- open,- selectedEntries = [],- removeTags,- removeAllTags,- fullScreen,- onClose- } = this.props;- const { newlyAddedTags = [] } = this.state;+ render() {+ const {+ open,+ selectedEntries = [],+ removeTags,+ removeAllTags,+ fullScreen,+ onClose+ } = this.props;+ const { newlyAddedTags = [] } = this.state;- return (- <Dialog- open={open}- fullScreen={fullScreen}- onClose={onClose}- keepMounted- scroll="paper"- // onEnterKey={(event) => onEnterKeyHandler(event, this.addTags)}- TransitionComponent={Transition}- >- <DialogTitle>{i18n.t('core:tagOperationTitle')}</DialogTitle>- <DialogContent style={{ minHeight: 330 }}>- <TagsSelect- placeholderText={i18n.t('core:selectTags')}- tags={newlyAddedTags}- handleChange={this.handleChange}- />- <List dense style={{ width: 550 }}>- {selectedEntries.length > 0 &&- selectedEntries.map(entry => (- <ListItem key={uuidv1()} title={entry.path}>- <ListItemIcon>- <FileIcon />- </ListItemIcon>- <Typography variant="inherit" noWrap>- {extractFileName(entry.path || '')}- </Typography>- </ListItem>- ))}- </List>- </DialogContent>- <DialogActions>- <Button data-tid="cancel" onClick={this.onClose} color="primary">- {i18n.t('core:cancel')}- </Button>- <Button- data-tid="cleanTagsMultipleEntries"- disabled={selectedEntries.length < 1}- color="primary"- onClick={() => {- if (selectedEntries && selectedEntries.length > 0) {- const paths = [];- selectedEntries.map(entry => {- paths.push(entry.path);- return true;- });- removeAllTags(paths);- }- this.onClose();- }}- >- {i18n.t('core:tagOperationCleanTags')}- </Button>- <Button- data-tid="removeTagsMultipleEntries"- disabled={- !newlyAddedTags ||- newlyAddedTags.length < 1 ||- selectedEntries.length < 1- }- color="primary"- onClick={() => {- if (selectedEntries && selectedEntries.length > 0) {- const paths = [];- selectedEntries.map(entry => {- paths.push(entry.path);- return true;- });- removeTags(paths, newlyAddedTags);- }- this.onClose();- }}- >- {i18n.t('core:tagOperationRemoveTag')}- </Button>- <Button- data-tid="addTagsMultipleEntries"- disabled={- !newlyAddedTags ||- newlyAddedTags.length < 1 ||- selectedEntries.length < 1- }- color="primary"- onClick={this.addTags}- >- {i18n.t('core:tagOperationAddTag')}- </Button>- </DialogActions>- </Dialog>- );- }+ return (+ <Dialog+ open={open}+ fullScreen={fullScreen}+ onClose={onClose}+ keepMounted+ scroll="paper"+ // onEnterKey={(event) => onEnterKeyHandler(event, this.addTags)}+ TransitionComponent={Transition}+ >+ <DialogTitle>{i18n.t('core:tagOperationTitle')}</DialogTitle>+ <DialogContent style={{ minHeight: 330 }}>+ <TagsSelect+ placeholderText={i18n.t('core:selectTags') as string}+ tags={newlyAddedTags}+ handleChange={this.handleChange}+ />+ <List dense style={{ width: 550 }}>+ {selectedEntries.length > 0 &&+ selectedEntries.map(entry => (+ <ListItem key={uuidv1()} title={entry.path}>+ <ListItemIcon>+ <FileIcon />+ </ListItemIcon>+ <Typography variant="inherit" noWrap>+ {extractFileName(entry.path || '')}+ </Typography>+ </ListItem>+ ))}+ </List>+ </DialogContent>+ <DialogActions>+ <Button data-tid="cancel" onClick={this.onClose} color="primary">+ {i18n.t('core:cancel')}+ </Button>+ <Button+ data-tid="cleanTagsMultipleEntries"+ disabled={selectedEntries.length < 1}+ color="primary"+ onClick={() => {+ if (selectedEntries && selectedEntries.length > 0) {+ const paths = [];+ selectedEntries.map(entry => {+ paths.push(entry.path);+ return true;+ });+ removeAllTags(paths);+ }+ this.onClose();+ }}+ >+ {i18n.t('core:tagOperationCleanTags')}+ </Button>+ <Button+ data-tid="removeTagsMultipleEntries"+ disabled={+ !newlyAddedTags ||+ newlyAddedTags.length < 1 ||+ selectedEntries.length < 1+ }+ color="primary"+ onClick={() => {+ if (selectedEntries && selectedEntries.length > 0) {+ const paths = [];+ selectedEntries.map(entry => {+ paths.push(entry.path);+ return true;+ });+ removeTags(paths, newlyAddedTags);+ }+ this.onClose();+ }}+ >+ {i18n.t('core:tagOperationRemoveTag')}+ </Button>+ <Button+ data-tid="addTagsMultipleEntries"+ disabled={+ !newlyAddedTags ||+ newlyAddedTags.length < 1 ||+ selectedEntries.length < 1+ }+ color="primary"+ onClick={this.addTags}+ >+ {i18n.t('core:tagOperationAddTag')}+ </Button>+ </DialogActions>+ </Dialog>+ );+ }}export default withMobileDialog()(AddRemoveTagsDialog);diff --git a/app/components/dialogs/ColorPickerDialog.tsx b/app/components/dialogs/ColorPickerDialog.tsxindex 618de5464..fd80e919c 100644--- a/app/components/dialogs/ColorPickerDialog.tsx+++ b/app/components/dialogs/ColorPickerDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React, { useState } from 'react';diff --git a/app/components/dialogs/ConfirmDialog.tsx b/app/components/dialogs/ConfirmDialog.tsxindex b38a455e0..422cfdb16 100644--- a/app/components/dialogs/ConfirmDialog.tsx+++ b/app/components/dialogs/ConfirmDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/dialogs/CreateDialog.tsx b/app/components/dialogs/CreateDialog.tsxindex 05b5392d7..0b7c14ad7 100644--- a/app/components/dialogs/CreateDialog.tsx+++ b/app/components/dialogs/CreateDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/dialogs/CreateDirectoryDialog.tsx b/app/components/dialogs/CreateDirectoryDialog.tsxindex 824f486ca..fb7771db2 100644--- a/app/components/dialogs/CreateDirectoryDialog.tsx+++ b/app/components/dialogs/CreateDirectoryDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React, { useState, useEffect } from 'react';diff --git a/app/components/dialogs/CreateFileDialog.tsx b/app/components/dialogs/CreateFileDialog.tsxindex 5e60dee43..a38535d77 100644--- a/app/components/dialogs/CreateFileDialog.tsx+++ b/app/components/dialogs/CreateFileDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/dialogs/CreateLocationDialog.tsx b/app/components/dialogs/CreateLocationDialog.tsxindex 2faf5102d..c935b409c 100644--- a/app/components/dialogs/CreateLocationDialog.tsx+++ b/app/components/dialogs/CreateLocationDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/dialogs/CreateTagGroupDialog.tsx b/app/components/dialogs/CreateTagGroupDialog.tsxindex 91cb91f80..b8f8e3577 100644--- a/app/components/dialogs/CreateTagGroupDialog.tsx+++ b/app/components/dialogs/CreateTagGroupDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';@@ -27,223 +26,223 @@ import FormControl from '@material-ui/core/FormControl';import FormHelperText from '@material-ui/core/FormHelperText';import Dialog from '@material-ui/core/Dialog';import ColorPickerDialog from './ColorPickerDialog';-import { type TagGroup } from '../../reducers/taglibrary';+import { TagGroup } from '../../reducers/taglibrary';import i18n from '../../services/i18n';import TransparentBackground from '../TransparentBackground';type Props = {- open: boolean,- onClose: () => void,- createTagGroup: (tagGroup: TagGroup) => void,- color: string,- textcolor: string+ open: boolean;+ onClose: () => void;+ createTagGroup: (tagGroup: TagGroup) => void;+ color: string;+ textcolor: string;};type State = {- inputError: boolean,- displayColorPicker: boolean,- displayTextColorPicker: boolean,- disableConfirmButton: boolean,- uuid: string,- title: string,- color: string,- textcolor: string,- children: string,- expanded: boolean+ inputError: boolean;+ displayColorPicker: boolean;+ displayTextColorPicker: boolean;+ disableConfirmButton: boolean;+ uuid: string;+ title: string;+ color: string;+ textcolor: string;+ children: string;+ expanded: boolean;};class CreateTagGroupDialog extends React.Component<Props, State> {- state = {- displayColorPicker: false,- displayTextColorPicker: false,- inputError: false,- disableConfirmButton: true,- title: '',- children: '',- color: this.props.color,- textcolor: this.props.textcolor,- expanded: true,- uuid: ''- };-- handleInputChange = (event: Object) => {- const target = event.target;- const value = target.type === 'checkbox' ? target.checked : target.value;- const name = target.name;-- this.setState(- {- [name]: value- },- this.handleValidation- );- };-- handleValidation() {- if (this.state.title.length > 0) {- this.setState({ inputError: false, disableConfirmButton: false });- } else {- this.setState({ inputError: true, disableConfirmButton: true });- }- }-- onConfirm = () => {- if (!this.state.disableConfirmButton) {- this.props.createTagGroup({- uuid: this.state.uuid,- title: this.state.title,- expanded: true,- color: this.state.color,- textcolor: this.state.textcolor,- children: []- });- this.setState({ inputError: false, disableConfirmButton: true });- this.props.onClose();- }- };-- toggleDefaultTagBackgroundColorPicker = () => {- this.setState(prevState => ({- displayColorPicker: !prevState.displayColorPicker- }));- };-- toggleDefaultTagTextColorPicker = () => {- this.setState(prevState => ({- displayTextColorPicker: !prevState.displayTextColorPicker- }));- };-- handleChangeColor = (color: string) => {- this.setState({ color });- };-- handleChangeTextColor = (color: string) => {- this.setState({ textcolor: color });- };-- render() {- const { fullScreen, open, onClose } = this.props;-- const styles = {- color: {- width: '100%',- height: 30,- borderRadius: 2,- borderWidth: 1,- borderStyle: 'solid',- borderColor: 'gray',- background: this.state.color- },- textcolor: {- width: '100%',- height: 30,- borderRadius: 2,- borderWidth: 1,- borderStyle: 'solid',- borderColor: 'gray',- background: this.state.textcolor- },- swatch: {- padding: '5px',- borderRadius: '1px',- boxShadow: '0 0 0 1px rgba(0,0,0,.1)',- display: 'inline-block',- cursor: 'pointer'- },- helpText: {- marginBottom: '5px',- fontSize: '1rem'- }- };-- return (- <Dialog- open={open}- onClose={onClose}- fullScreen={fullScreen}- keepMounted- scroll="paper"- // onKeyDown={confirmFunction}- >- <DialogTitle>{i18n.t('core:createTagGroupTitle')}</DialogTitle>- <DialogContent>- <FormControl fullWidth={true} error={this.state.inputError}>- <TextField- fullWidth={true}- error={this.state.inputError}- autoFocus- name="title"- label={i18n.t('core:createTagGroupName')}- value={this.state.title}- onChange={this.handleInputChange}- data-tid="createTagGroupInput"- />- {this.state.inputError && (- <FormHelperText>- {i18n.t('core:taggroupTitleHelper')}- </FormHelperText>- )}- </FormControl>- <FormControl fullWidth={true}>- <FormHelperText style={styles.helpText}>- {i18n.t('core:tagBackgroundColor')}- </FormHelperText>- <TransparentBackground>- <Button- onClick={this.toggleDefaultTagBackgroundColorPicker}- data-tid="createTagGroupBackgroundColor"- style={styles.color}- role="presentation"- >- - </Button>- </TransparentBackground>- <ColorPickerDialog- open={this.state.displayColorPicker}- setColor={this.handleChangeColor}- onClose={this.toggleDefaultTagBackgroundColorPicker}- color={this.state.color}- />- </FormControl>- <FormControl fullWidth={true}>- <FormHelperText style={styles.helpText}>- {i18n.t('core:tagForegroundColor')}- </FormHelperText>- <TransparentBackground>- <Button- onClick={this.toggleDefaultTagTextColorPicker}- data-tid="createTagGroupForegroundColor"- style={styles.textcolor}- role="presentation"- >- - </Button>- </TransparentBackground>- <ColorPickerDialog- open={this.state.displayTextColorPicker}- setColor={this.handleChangeTextColor}- onClose={this.toggleDefaultTagTextColorPicker}- color={this.state.textcolor}- />- </FormControl>- </DialogContent>- <DialogActions>- <Button onClick={this.props.onClose} color="primary">- {i18n.t('core:cancel')}- </Button>- <Button- disabled={this.state.disableConfirmButton}- onClick={this.onConfirm}- data-tid="createTagGroupConfirmButton"- color="primary"- >- {i18n.t('core:ok')}- </Button>- </DialogActions>- </Dialog>- );- }+ state = {+ displayColorPicker: false,+ displayTextColorPicker: false,+ inputError: false,+ disableConfirmButton: true,+ title: '',+ children: '',+ color: this.props.color,+ textcolor: this.props.textcolor,+ expanded: true,+ uuid: ''+ };++ handleInputChange = (event: Object) => {+ const target = event.target;+ const value = target.type === 'checkbox' ? target.checked : target.value;+ const name = target.name;++ this.setState(+ {+ [name]: value+ },+ this.handleValidation+ );+ };++ handleValidation() {+ if (this.state.title.length > 0) {+ this.setState({ inputError: false, disableConfirmButton: false });+ } else {+ this.setState({ inputError: true, disableConfirmButton: true });+ }+ }++ onConfirm = () => {+ if (!this.state.disableConfirmButton) {+ this.props.createTagGroup({+ uuid: this.state.uuid,+ title: this.state.title,+ expanded: true,+ color: this.state.color,+ textcolor: this.state.textcolor,+ children: []+ });+ this.setState({ inputError: false, disableConfirmButton: true });+ this.props.onClose();+ }+ };++ toggleDefaultTagBackgroundColorPicker = () => {+ this.setState(prevState => ({+ displayColorPicker: !prevState.displayColorPicker+ }));+ };++ toggleDefaultTagTextColorPicker = () => {+ this.setState(prevState => ({+ displayTextColorPicker: !prevState.displayTextColorPicker+ }));+ };++ handleChangeColor = (color: string) => {+ this.setState({ color });+ };++ handleChangeTextColor = (color: string) => {+ this.setState({ textcolor: color });+ };++ render() {+ const { fullScreen, open, onClose } = this.props;++ const styles = {+ color: {+ width: '100%',+ height: 30,+ borderRadius: 2,+ borderWidth: 1,+ borderStyle: 'solid',+ borderColor: 'gray',+ background: this.state.color+ },+ textcolor: {+ width: '100%',+ height: 30,+ borderRadius: 2,+ borderWidth: 1,+ borderStyle: 'solid',+ borderColor: 'gray',+ background: this.state.textcolor+ },+ swatch: {+ padding: '5px',+ borderRadius: '1px',+ boxShadow: '0 0 0 1px rgba(0,0,0,.1)',+ display: 'inline-block',+ cursor: 'pointer'+ },+ helpText: {+ marginBottom: '5px',+ fontSize: '1rem'+ }+ };++ return (+ <Dialog+ open={open}+ onClose={onClose}+ fullScreen={fullScreen}+ keepMounted+ scroll="paper"+ // onKeyDown={confirmFunction}+ >+ <DialogTitle>{i18n.t('core:createTagGroupTitle')}</DialogTitle>+ <DialogContent>+ <FormControl fullWidth={true} error={this.state.inputError}>+ <TextField+ fullWidth={true}+ error={this.state.inputError}+ autoFocus+ name="title"+ label={i18n.t('core:createTagGroupName')}+ value={this.state.title}+ onChange={this.handleInputChange}+ data-tid="createTagGroupInput"+ />+ {this.state.inputError && (+ <FormHelperText>+ {i18n.t('core:taggroupTitleHelper')}+ </FormHelperText>+ )}+ </FormControl>+ <FormControl fullWidth={true}>+ <FormHelperText style={styles.helpText}>+ {i18n.t('core:tagBackgroundColor')}+ </FormHelperText>+ <TransparentBackground>+ <Button+ onClick={this.toggleDefaultTagBackgroundColorPicker}+ data-tid="createTagGroupBackgroundColor"+ style={styles.color}+ role="presentation"+ >+ + </Button>+ </TransparentBackground>+ <ColorPickerDialog+ open={this.state.displayColorPicker}+ setColor={this.handleChangeColor}+ onClose={this.toggleDefaultTagBackgroundColorPicker}+ color={this.state.color}+ />+ </FormControl>+ <FormControl fullWidth={true}>+ <FormHelperText style={styles.helpText}>+ {i18n.t('core:tagForegroundColor')}+ </FormHelperText>+ <TransparentBackground>+ <Button+ onClick={this.toggleDefaultTagTextColorPicker}+ data-tid="createTagGroupForegroundColor"+ style={styles.textcolor}+ role="presentation"+ >+ + </Button>+ </TransparentBackground>+ <ColorPickerDialog+ open={this.state.displayTextColorPicker}+ setColor={this.handleChangeTextColor}+ onClose={this.toggleDefaultTagTextColorPicker}+ color={this.state.textcolor}+ />+ </FormControl>+ </DialogContent>+ <DialogActions>+ <Button onClick={this.props.onClose} color="primary">+ {i18n.t('core:cancel')}+ </Button>+ <Button+ disabled={this.state.disableConfirmButton}+ onClick={this.onConfirm}+ data-tid="createTagGroupConfirmButton"+ color="primary"+ >+ {i18n.t('core:ok')}+ </Button>+ </DialogActions>+ </Dialog>+ );+ }}export default CreateTagGroupDialog;diff --git a/app/components/dialogs/CreateTagsDialog.tsx b/app/components/dialogs/CreateTagsDialog.tsxindex d76ead5cf..c605101f7 100644--- a/app/components/dialogs/CreateTagsDialog.tsx+++ b/app/components/dialogs/CreateTagsDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';@@ -27,109 +26,109 @@ import FormControl from '@material-ui/core/FormControl';import FormHelperText from '@material-ui/core/FormHelperText';import Dialog from '@material-ui/core/Dialog';import i18n from '../../services/i18n';-import { type TagGroup } from '../../reducers/taglibrary';+import { TagGroup } from '../../reducers/taglibrary';type Props = {- open: boolean,- onClose: () => void,- addTag: (tags: string, uuid: string) => void,- fullScreen: boolean,- selectedTagGroupEntry: TagGroup+ open: boolean;+ onClose: () => void;+ addTag: (tags: string, uuid: string) => void;+ fullScreen: boolean;+ selectedTagGroupEntry: TagGroup;};type State = {- inputError: boolean,- disableConfirmButton: boolean,- open: boolean,- tagTitle: string+ inputError: boolean;+ disableConfirmButton: boolean;+ open: boolean;+ tagTitle: string;};class CreateTagsDialog extends React.Component<Props, State> {- state = {- inputError: false,- disableConfirmButton: true,- open: false,- tagTitle: ''- };+ state = {+ inputError: false,+ disableConfirmButton: true,+ open: false,+ tagTitle: ''+ };- handleInputChange = (event: Object) => {- const target = event.target;- const value = target.type === 'checkbox' ? target.checked : target.value;- const name = target.name;+ handleInputChange = (event: Object) => {+ const target = event.target;+ const value = target.type === 'checkbox' ? target.checked : target.value;+ const name = target.name;- this.setState(- {- [name]: value- },- this.handleValidation- );- };+ this.setState(+ {+ [name]: value+ },+ this.handleValidation+ );+ };- handleValidation() {- const tagCheck = RegExp(/^[^\#\/\\[\]]{1,}$/);- if (this.state.tagTitle && tagCheck.test(this.state.tagTitle)) {- this.setState({ inputError: false, disableConfirmButton: false });- } else {- this.setState({ inputError: true, disableConfirmButton: true });- }- }+ handleValidation() {+ const tagCheck = RegExp(/^[^\#\/\\[\]]{1,}$/);+ if (this.state.tagTitle && tagCheck.test(this.state.tagTitle)) {+ this.setState({ inputError: false, disableConfirmButton: false });+ } else {+ this.setState({ inputError: true, disableConfirmButton: true });+ }+ }- onConfirm = () => {- if (!this.state.disableConfirmButton) {- this.setState({ open: false, disableConfirmButton: true });- this.props.addTag(- this.state.tagTitle,- this.props.selectedTagGroupEntry.uuid- );- this.props.onClose();- }- };+ onConfirm = () => {+ if (!this.state.disableConfirmButton) {+ this.setState({ open: false, disableConfirmButton: true });+ this.props.addTag(+ this.state.tagTitle,+ this.props.selectedTagGroupEntry.uuid+ );+ this.props.onClose();+ }+ };- render() {- const { fullScreen, open, onClose } = this.props;+ render() {+ const { fullScreen, open, onClose } = this.props;- return (- <Dialog- open={open}- onClose={onClose}- fullScreen={fullScreen}- keepMounted- scroll="paper"- >- <DialogTitle>{i18n.t('core:addTagsToGroupTitle')}</DialogTitle>- <DialogContent style={{ minWidth: 400 }}>- <FormControl fullWidth={true} error={this.state.inputError}>- <TextField- error={this.state.inputError}- name="tagTitle"- autoFocus- label={i18n.t('core:addTagsToGroupTagsPlaceholder')}- onChange={this.handleInputChange}- value={this.state.tagTitle}- data-tid="addTagsInput"- fullWidth={true}- />- {this.state.inputError && (- <FormHelperText>{i18n.t('core:tagTitleHelper')}</FormHelperText>- )}- </FormControl>- </DialogContent>- <DialogActions>- <Button onClick={this.props.onClose} color="primary">- {i18n.t('core:cancel')}- </Button>- <Button- disabled={this.state.disableConfirmButton}- onClick={this.onConfirm}- data-tid="createTagsConfirmButton"- color="primary"- >- {i18n.t('core:ok')}- </Button>- </DialogActions>- </Dialog>- );- }+ return (+ <Dialog+ open={open}+ onClose={onClose}+ fullScreen={fullScreen}+ keepMounted+ scroll="paper"+ >+ <DialogTitle>{i18n.t('core:addTagsToGroupTitle')}</DialogTitle>+ <DialogContent style={{ minWidth: 400 }}>+ <FormControl fullWidth={true} error={this.state.inputError}>+ <TextField+ error={this.state.inputError}+ name="tagTitle"+ autoFocus+ label={i18n.t('core:addTagsToGroupTagsPlaceholder')}+ onChange={this.handleInputChange}+ value={this.state.tagTitle}+ data-tid="addTagsInput"+ fullWidth={true}+ />+ {this.state.inputError && (+ <FormHelperText>{i18n.t('core:tagTitleHelper')}</FormHelperText>+ )}+ </FormControl>+ </DialogContent>+ <DialogActions>+ <Button onClick={this.props.onClose} color="primary">+ {i18n.t('core:cancel')}+ </Button>+ <Button+ disabled={this.state.disableConfirmButton}+ onClick={this.onConfirm}+ data-tid="createTagsConfirmButton"+ color="primary"+ >+ {i18n.t('core:ok')}+ </Button>+ </DialogActions>+ </Dialog>+ );+ }}export default CreateTagsDialog;diff --git a/app/components/dialogs/Dialogs.css.tsx b/app/components/dialogs/Dialogs.css.tsxindex 1d55ba6c6..39afe5423 100644--- a/app/components/dialogs/Dialogs.css.tsx+++ b/app/components/dialogs/Dialogs.css.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/export default (theme: Object) => ({diff --git a/app/components/dialogs/EditEntryTagDialog.tsx b/app/components/dialogs/EditEntryTagDialog.tsxindex cb4e23990..aa89494fa 100644--- a/app/components/dialogs/EditEntryTagDialog.tsx+++ b/app/components/dialogs/EditEntryTagDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React, { useState, useEffect } from 'react';@@ -32,189 +31,188 @@ import FormHelperText from '@material-ui/core/FormHelperText';import Dialog from '@material-ui/core/Dialog';import i18n from '../../services/i18n';import { isPlusCode } from '../../utils/misc';-import { type Tag } from '../../reducers/taglibrary';+import { Tag } from '../../reducers/taglibrary';import { Pro } from '../../pro';import { getSelectedTag } from '../../reducers/app';import TaggingActions, {- defaultTagLocation+ defaultTagLocation} from '../../reducers/tagging-actions';import { isDateTimeTag } from '../../utils/dates';const styles = () => ({- root: {- minWidth: 400,- height: '100%',- marginBottom: 30- }+ root: {+ minWidth: 400,+ height: '100%',+ marginBottom: 30+ }});type Props = {- classes: Object,- open: boolean,- fullScreen: boolean,- onClose: () => void,- editTagForEntry: (path: string, tag: Tag, title: string) => void,- currentEntryPath: string,- selectedTag: Tag,- open: boolean+ classes: Object;+ open: boolean;+ fullScreen: boolean;+ onClose: () => void;+ editTagForEntry: (path: string, tag: Tag, title: string) => void;+ currentEntryPath: string;+ selectedTag: Tag;};const GeoTagEditor = Pro && Pro.UI ? Pro.UI.GeoTagEditor : React.Fragment;const DateTagEditor = Pro && Pro.UI ? Pro.UI.DateTagEditor : React.Fragment;const EditEntryTagDialog = (props: Props) => {- const [disableConfirmButton, setDisableConfirmButton] = useState(true);- const [errorTag, setErrorTag] = useState(false);- const [title, setTitle] = useState(- props.selectedTag && props.selectedTag.title- );- const { onClose, open, fullScreen } = props;-- useEffect(() => {- handleValidation();- });-- function handleValidation() {- const tagCheck = RegExp(/^[^\#\/\\ \[\]]{1,}$/);- if (title && tagCheck.test(title)) {- setErrorTag(false);- setDisableConfirmButton(false);- } else {- setErrorTag(true);- setDisableConfirmButton(true);- }- }-- function onConfirm() {- if (!disableConfirmButton) {- props.editTagForEntry(props.currentEntryPath, props.selectedTag, title);- setErrorTag(false);- setDisableConfirmButton(true);- props.onClose();- }- }-- function renderTitle() {- return <DialogTitle>{i18n.t('core:tagProperties')}</DialogTitle>;- }-- function renderContent() {- const showGeoEditor = GeoTagEditor && isPlusCode(title);- let showDatePeriodEditor = false;- if (title.indexOf('-') > -1) {- const a = title.split('-');- if (a.length === 2) {- for (let i = 0; i < a.length; i += 1) {- if (isDateTimeTag(a[i])) {- showDatePeriodEditor = true;- } else {- showDatePeriodEditor = false;- break;- }- }- }- } else showDatePeriodEditor = isDateTimeTag(title);- showDatePeriodEditor = DateTagEditor && showDatePeriodEditor;-- return (- <DialogContent- data-tid="editEntryTagDialog"- className={props.classes.root}- >- <FormControl fullWidth={true} error={errorTag}>- <TextField- fullWidth={true}- error={errorTag}- margin="dense"- name="title"- autoFocus- label={i18n.t('core:editTag')}- onChange={event => {- const target = event.target;- setTitle(target.value);- }}- value={title}- data-tid="editTagEntryDialog_input"- />- {errorTag && (- <FormHelperText>{i18n.t('core:tagTitleHelper')}</FormHelperText>- )}- </FormControl>- {showGeoEditor && (- <GeoTagEditor- key={title}- geoTag={title}- onChange={setTitle}- zoom={title === defaultTagLocation ? 2 : undefined}- />- )}- {showDatePeriodEditor && (- <DateTagEditor- key={title}- datePeriodTag={title}- onChange={setTitle}- />- )}- </DialogContent>- );- }-- function renderActions() {- return (- <DialogActions>- <Button- data-tid="closeEditTagEntryDialog"- onClick={props.onClose}- color="primary"- >- {i18n.t('core:cancel')}- </Button>- <Button- disabled={disableConfirmButton}- onClick={onConfirm}- data-tid="confirmEditTagEntryDialog"- color="primary"- >- {i18n.t('core:ok')}- </Button>- </DialogActions>- );- }-- return (- <Dialog- open={open}- fullScreen={fullScreen}- onClose={onClose}- // onEnterKey={(event) => onEnterKeyHandler(event, onConfirm)}- >- {renderTitle()}- {renderContent()}- {renderActions()}- </Dialog>- );+ const [disableConfirmButton, setDisableConfirmButton] = useState(true);+ const [errorTag, setErrorTag] = useState(false);+ const [title, setTitle] = useState(+ props.selectedTag && props.selectedTag.title+ );+ const { onClose, open, fullScreen } = props;++ useEffect(() => {+ handleValidation();+ });++ function handleValidation() {+ const tagCheck = RegExp(/^[^\#\/\\ \[\]]{1,}$/);+ if (title && tagCheck.test(title)) {+ setErrorTag(false);+ setDisableConfirmButton(false);+ } else {+ setErrorTag(true);+ setDisableConfirmButton(true);+ }+ }++ function onConfirm() {+ if (!disableConfirmButton) {+ props.editTagForEntry(props.currentEntryPath, props.selectedTag, title);+ setErrorTag(false);+ setDisableConfirmButton(true);+ props.onClose();+ }+ }++ function renderTitle() {+ return <DialogTitle>{i18n.t('core:tagProperties')}</DialogTitle>;+ }++ function renderContent() {+ const showGeoEditor = GeoTagEditor && isPlusCode(title);+ let showDatePeriodEditor = false;+ if (title.indexOf('-') > -1) {+ const a = title.split('-');+ if (a.length === 2) {+ for (let i = 0; i < a.length; i += 1) {+ if (isDateTimeTag(a[i])) {+ showDatePeriodEditor = true;+ } else {+ showDatePeriodEditor = false;+ break;+ }+ }+ }+ } else showDatePeriodEditor = isDateTimeTag(title);+ showDatePeriodEditor = DateTagEditor && showDatePeriodEditor;++ return (+ <DialogContent+ data-tid="editEntryTagDialog"+ className={props.classes.root}+ >+ <FormControl fullWidth={true} error={errorTag}>+ <TextField+ fullWidth={true}+ error={errorTag}+ margin="dense"+ name="title"+ autoFocus+ label={i18n.t('core:editTag')}+ onChange={event => {+ const target = event.target;+ setTitle(target.value);+ }}+ value={title}+ data-tid="editTagEntryDialog_input"+ />+ {errorTag && (+ <FormHelperText>{i18n.t('core:tagTitleHelper')}</FormHelperText>+ )}+ </FormControl>+ {showGeoEditor && (+ <GeoTagEditor+ key={title}+ geoTag={title}+ onChange={setTitle}+ zoom={title === defaultTagLocation ? 2 : undefined}+ />+ )}+ {showDatePeriodEditor && (+ <DateTagEditor+ key={title}+ datePeriodTag={title}+ onChange={setTitle}+ />+ )}+ </DialogContent>+ );+ }++ function renderActions() {+ return (+ <DialogActions>+ <Button+ data-tid="closeEditTagEntryDialog"+ onClick={props.onClose}+ color="primary"+ >+ {i18n.t('core:cancel')}+ </Button>+ <Button+ disabled={disableConfirmButton}+ onClick={onConfirm}+ data-tid="confirmEditTagEntryDialog"+ color="primary"+ >+ {i18n.t('core:ok')}+ </Button>+ </DialogActions>+ );+ }++ return (+ <Dialog+ open={open}+ fullScreen={fullScreen}+ onClose={onClose}+ // onEnterKey={(event) => onEnterKeyHandler(event, onConfirm)}+ >+ {renderTitle()}+ {renderContent()}+ {renderActions()}+ </Dialog>+ );};function mapStateToProps(state) {- return {- selectedTag: getSelectedTag(state),- currentEntryPath: getSelectedTag(state)- ? getSelectedTag(state).path- : undefined- };+ return {+ selectedTag: getSelectedTag(state),+ currentEntryPath: getSelectedTag(state)+ ? getSelectedTag(state).path+ : undefined+ };}function mapDispatchToProps(dispatch) {- return bindActionCreators(- {- editTagForEntry: TaggingActions.editTagForEntry- },- dispatch- );+ return bindActionCreators(+ {+ editTagForEntry: TaggingActions.editTagForEntry+ },+ dispatch+ );}export default withMobileDialog()(- withStyles(styles)(- connect(mapStateToProps, mapDispatchToProps)(EditEntryTagDialog)- )+ withStyles(styles)(+ connect(mapStateToProps, mapDispatchToProps)(EditEntryTagDialog)+ ));diff --git a/app/components/dialogs/EditLocationDialog.tsx b/app/components/dialogs/EditLocationDialog.tsxindex 95050854d..0be3e12d1 100644--- a/app/components/dialogs/EditLocationDialog.tsx+++ b/app/components/dialogs/EditLocationDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/dialogs/EditTagDialog.tsx b/app/components/dialogs/EditTagDialog.tsxindex 113e41771..0ef5a358a 100644--- a/app/components/dialogs/EditTagDialog.tsx+++ b/app/components/dialogs/EditTagDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';@@ -30,259 +29,259 @@ import Dialog from '@material-ui/core/Dialog';import ColorPickerDialog from './ColorPickerDialog';import TransparentBackground from '../TransparentBackground';import i18n from '../../services/i18n';-import { type Tag, type TagGroup } from '../../reducers/taglibrary';+import { Tag, TagGroup } from '../../reducers/taglibrary';type Props = {- open: boolean,- onClose: () => void,- editTag: (tag: Tag, tagGroupId: string) => void,- selectedTag: Tag,- selectedTagGroupEntry: TagGroup+ open: boolean;+ onClose: () => void;+ editTag: (tag: Tag, tagGroupId: string) => void;+ selectedTag: Tag;+ selectedTagGroupEntry: TagGroup;};type State = {- inputError: boolean,- displayColorPicker: boolean,- displayTextColorPicker: boolean,- disableConfirmButton: boolean,- title: string,- color: string,- textcolor: string,- modifiedDate: string+ inputError: boolean;+ displayColorPicker: boolean;+ displayTextColorPicker: boolean;+ disableConfirmButton: boolean;+ title: string;+ color: string;+ textcolor: string;+ modifiedDate: string;};class EditTagDialog extends React.Component<Props, State> {- state = {- displayColorPicker: false,- displayTextColorPicker: false,- inputError: false,- disableConfirmButton: true,- title: '',- color: '',- textcolor: '',- modifiedDate: ''- };+ state = {+ displayColorPicker: false,+ displayTextColorPicker: false,+ inputError: false,+ disableConfirmButton: true,+ title: '',+ color: '',+ textcolor: '',+ modifiedDate: ''+ };- componentWillReceiveProps = ({ open, selectedTag }: Props) => {- if (open === true) {- this.setState({- disableConfirmButton: !selectedTag.title,- title: selectedTag.title,- color: selectedTag.color,- textcolor: selectedTag.textcolor,- modifiedDate: selectedTag.modified_date- });- }- };+ componentWillReceiveProps = ({ open, selectedTag }: Props) => {+ if (open === true) {+ this.setState({+ disableConfirmButton: !selectedTag.title,+ title: selectedTag.title,+ color: selectedTag.color,+ textcolor: selectedTag.textcolor,+ modifiedDate: selectedTag.modified_date+ });+ }+ };- handleInputChange = (event: Object) => {- const target = event.target;- const value = target.type === 'checkbox' ? target.checked : target.value;- const name = target.name;+ handleInputChange = (event: Object) => {+ const target = event.target;+ const value = target.type === 'checkbox' ? target.checked : target.value;+ const name = target.name;- this.setState(- {- [name]: value- },- this.handleValidation- );- };+ this.setState(+ {+ [name]: value+ },+ this.handleValidation+ );+ };- handleValidation() {- const tagCheck = RegExp(/^[^\#\/\\ \[\]]{1,}$/);- if (this.state.title && tagCheck.test(this.state.title)) {- this.setState({ inputError: false, disableConfirmButton: false });- } else {- this.setState({ inputError: true, disableConfirmButton: true });- }- }+ handleValidation() {+ const tagCheck = RegExp(/^[^\#\/\\ \[\]]{1,}$/);+ if (this.state.title && tagCheck.test(this.state.title)) {+ this.setState({ inputError: false, disableConfirmButton: false });+ } else {+ this.setState({ inputError: true, disableConfirmButton: true });+ }+ }- onConfirm = () => {- if (- !this.state.disableConfirmButton &&- this.props.editTag &&- this.props.selectedTagGroupEntry &&- this.props.selectedTag- ) {- this.props.editTag(- {- ...this.props.selectedTag,- title: this.state.title,- color: this.state.color,- textcolor: this.state.textcolor- },- this.props.selectedTagGroupEntry.uuid- );- this.setState({ inputError: false, disableConfirmButton: true });- this.props.onClose();- }- };+ onConfirm = () => {+ if (+ !this.state.disableConfirmButton &&+ this.props.editTag &&+ this.props.selectedTagGroupEntry &&+ this.props.selectedTag+ ) {+ this.props.editTag(+ {+ ...this.props.selectedTag,+ title: this.state.title,+ color: this.state.color,+ textcolor: this.state.textcolor+ },+ this.props.selectedTagGroupEntry.uuid+ );+ this.setState({ inputError: false, disableConfirmButton: true });+ this.props.onClose();+ }+ };- toggleDefaultTagBackgroundColorPicker = () => {- this.setState({- displayColorPicker: !this.state.displayColorPicker- });- };+ toggleDefaultTagBackgroundColorPicker = () => {+ this.setState({+ displayColorPicker: !this.state.displayColorPicker+ });+ };- toggleDefaultTagTextColorPicker = () => {- this.setState({- displayTextColorPicker: !this.state.displayTextColorPicker- });- };+ toggleDefaultTagTextColorPicker = () => {+ this.setState({+ displayTextColorPicker: !this.state.displayTextColorPicker+ });+ };- handleChangeColor = (color: string) => {- this.setState({ color });- };+ handleChangeColor = (color: string) => {+ this.setState({ color });+ };- handleChangeTextColor = (color: string) => {- this.setState({ textcolor: color });- };+ handleChangeTextColor = (color: string) => {+ this.setState({ textcolor: color });+ };- render() {- const { color, textcolor, modifiedDate } = this.state;- const { fullScreen, open, onClose } = this.props;- const styles = {- color: {- width: '100%',- height: 30,- borderRadius: 2,- borderWidth: 1,- borderStyle: 'solid',- borderColor: 'gray',- padding: '5px',- background: color- },- textcolor: {- width: '100%',- height: 30,- borderRadius: 2,- borderWidth: 1,- borderStyle: 'solid',- borderColor: 'gray',- padding: '5px',- background: textcolor- },- helpText: {- marginBottom: '5px',- fontSize: '1rem'- }- };+ render() {+ const { color, textcolor, modifiedDate } = this.state;+ const { fullScreen, open, onClose } = this.props;+ const styles = {+ color: {+ width: '100%',+ height: 30,+ borderRadius: 2,+ borderWidth: 1,+ borderStyle: 'solid',+ borderColor: 'gray',+ padding: '5px',+ background: color+ },+ textcolor: {+ width: '100%',+ height: 30,+ borderRadius: 2,+ borderWidth: 1,+ borderStyle: 'solid',+ borderColor: 'gray',+ padding: '5px',+ background: textcolor+ },+ helpText: {+ marginBottom: '5px',+ fontSize: '1rem'+ }+ };- return (- <Dialog- open={open}- fullScreen={fullScreen}- onClose={onClose}- keepMounted- scroll="paper"- // onEnterKey={(event) => onEnterKeyHandler(event, this.addTags)}- >- <DialogTitle style={{ overflow: 'visible' }}>- {i18n.t('core:editTagTitle')}- {` '${this.state.title}'`}- </DialogTitle>- <DialogContent style={{ overflow: 'visible' }}>- <FormControl- fullWidth={true}- error={this.state.inputError}- style={{ overflow: 'visible' }}- >- {modifiedDate && (- <div- className="tag-date"- style={{- fontSize: 12,- position: 'relative',- bottom: 20,- color: '#808080'- }}- >- <span className="text" style={{ fontWeight: 600 }}>{`${i18n.t(- 'core:modifiedDate'- )}: `}</span>- <time>{format(new Date(modifiedDate), 'yyyy-mm-dd')}</time>- </div>- )}- <TextField- error={this.state.inputError}- margin="dense"- name="title"- autoFocus- label={i18n.t('core:editTag')}- onChange={this.handleInputChange}- value={this.state.title}- data-tid="editTagInput"- fullWidth={true}- />- {this.state.inputError && (- <FormHelperText style={styles.helpText}>- {i18n.t('core:tagTitleHelper')}- </FormHelperText>- )}- </FormControl>- <FormControl fullWidth={true}>- <FormHelperText style={styles.helpText}>- {i18n.t('core:tagBackgroundColor')}- </FormHelperText>- <TransparentBackground>- <Button- onClick={this.toggleDefaultTagBackgroundColorPicker}- data-tid="tagBackgroundColorEditTagDialog"- style={styles.color}- role="presentation"- >- - </Button>- </TransparentBackground>- <ColorPickerDialog- open={this.state.displayColorPicker}- setColor={this.handleChangeColor}- onClose={this.toggleDefaultTagBackgroundColorPicker}- color={this.state.color}- />- </FormControl>- <FormControl fullWidth={true}>- <FormHelperText style={styles.helpText}>- {i18n.t('core:tagForegroundColor')}- </FormHelperText>- <TransparentBackground>- <Button- onClick={this.toggleDefaultTagTextColorPicker}- data-tid="tagForegroundColorEditTagDialog"- style={styles.textcolor}- role="presentation"- >- - </Button>- </TransparentBackground>- <ColorPickerDialog- open={this.state.displayTextColorPicker}- setColor={this.handleChangeTextColor}- onClose={this.toggleDefaultTagTextColorPicker}- color={this.state.textcolor}- />- </FormControl>- </DialogContent>- <DialogActions>- <Button- onClick={this.props.onClose}- data-tid="closeEditTagDialog"- color="primary"- >- {i18n.t('core:cancel')}- </Button>- <Button- disabled={this.state.disableConfirmButton}- onClick={this.onConfirm}- data-tid="editTagConfirm"- color="primary"- >- {i18n.t('core:ok')}- </Button>- </DialogActions>- </Dialog>- );- }+ return (+ <Dialog+ open={open}+ fullScreen={fullScreen}+ onClose={onClose}+ keepMounted+ scroll="paper"+ // onEnterKey={(event) => onEnterKeyHandler(event, this.addTags)}+ >+ <DialogTitle style={{ overflow: 'visible' }}>+ {i18n.t('core:editTagTitle')}+ {` '${this.state.title}'`}+ </DialogTitle>+ <DialogContent style={{ overflow: 'visible' }}>+ <FormControl+ fullWidth={true}+ error={this.state.inputError}+ style={{ overflow: 'visible' }}+ >+ {modifiedDate && (+ <div+ className="tag-date"+ style={{+ fontSize: 12,+ position: 'relative',+ bottom: 20,+ color: '#808080'+ }}+ >+ <span className="text" style={{ fontWeight: 600 }}>{`${i18n.t(+ 'core:modifiedDate'+ )}: `}</span>+ <time>{format(new Date(modifiedDate), 'yyyy-mm-dd')}</time>+ </div>+ )}+ <TextField+ error={this.state.inputError}+ margin="dense"+ name="title"+ autoFocus+ label={i18n.t('core:editTag')}+ onChange={this.handleInputChange}+ value={this.state.title}+ data-tid="editTagInput"+ fullWidth={true}+ />+ {this.state.inputError && (+ <FormHelperText style={styles.helpText}>+ {i18n.t('core:tagTitleHelper')}+ </FormHelperText>+ )}+ </FormControl>+ <FormControl fullWidth={true}>+ <FormHelperText style={styles.helpText}>+ {i18n.t('core:tagBackgroundColor')}+ </FormHelperText>+ <TransparentBackground>+ <Button+ onClick={this.toggleDefaultTagBackgroundColorPicker}+ data-tid="tagBackgroundColorEditTagDialog"+ style={styles.color}+ role="presentation"+ >+ + </Button>+ </TransparentBackground>+ <ColorPickerDialog+ open={this.state.displayColorPicker}+ setColor={this.handleChangeColor}+ onClose={this.toggleDefaultTagBackgroundColorPicker}+ color={this.state.color}+ />+ </FormControl>+ <FormControl fullWidth={true}>+ <FormHelperText style={styles.helpText}>+ {i18n.t('core:tagForegroundColor')}+ </FormHelperText>+ <TransparentBackground>+ <Button+ onClick={this.toggleDefaultTagTextColorPicker}+ data-tid="tagForegroundColorEditTagDialog"+ style={styles.textcolor}+ role="presentation"+ >+ + </Button>+ </TransparentBackground>+ <ColorPickerDialog+ open={this.state.displayTextColorPicker}+ setColor={this.handleChangeTextColor}+ onClose={this.toggleDefaultTagTextColorPicker}+ color={this.state.textcolor}+ />+ </FormControl>+ </DialogContent>+ <DialogActions>+ <Button+ onClick={this.props.onClose}+ data-tid="closeEditTagDialog"+ color="primary"+ >+ {i18n.t('core:cancel')}+ </Button>+ <Button+ disabled={this.state.disableConfirmButton}+ onClick={this.onConfirm}+ data-tid="editTagConfirm"+ color="primary"+ >+ {i18n.t('core:ok')}+ </Button>+ </DialogActions>+ </Dialog>+ );+ }}export default EditTagDialog;diff --git a/app/components/dialogs/EditTagGroupDialog.tsx b/app/components/dialogs/EditTagGroupDialog.tsxindex 3e38a97c9..1e5b6011c 100644--- a/app/components/dialogs/EditTagGroupDialog.tsx+++ b/app/components/dialogs/EditTagGroupDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';@@ -29,285 +28,285 @@ import FormHelperText from '@material-ui/core/FormHelperText';import Switch from '@material-ui/core/Switch';import Dialog from '@material-ui/core/Dialog';import ColorPickerDialog from './ColorPickerDialog';-import { type TagGroup } from '../../reducers/taglibrary';+import { TagGroup } from '../../reducers/taglibrary';import i18n from '../../services/i18n';import TransparentBackground from '../TransparentBackground';type Props = {- open: boolean,- editTagGroup: (tagGroup: TagGroup) => void,- selectedTagGroupEntry: TagGroup,- onClose: () => void+ open: boolean;+ editTagGroup: (tagGroup: TagGroup) => void;+ selectedTagGroupEntry: TagGroup;+ onClose: () => void;};type State = {- inputError: boolean,- displayColorPicker: boolean,- displayTextColorPicker: boolean,- disableConfirmButton: boolean,- title: string,- applyChanges: boolean,- color: string,- textcolor: string,- modifiedDate: string+ inputError: boolean;+ displayColorPicker: boolean;+ displayTextColorPicker: boolean;+ disableConfirmButton: boolean;+ title: string;+ applyChanges: boolean;+ color: string;+ textcolor: string;+ modifiedDate: string;};class EditTagGroupDialog extends React.Component<Props, State> {- state = {- displayColorPicker: false,- displayTextColorPicker: false,- inputError: false,- disableConfirmButton: true,- applyChanges: false,- title: '',- color: '',- textcolor: '',- modifiedDate: ''- };+ state = {+ displayColorPicker: false,+ displayTextColorPicker: false,+ inputError: false,+ disableConfirmButton: true,+ applyChanges: false,+ title: '',+ color: '',+ textcolor: '',+ modifiedDate: ''+ };- componentWillReceiveProps = ({ open, selectedTagGroupEntry }) => {- if (open === true) {- this.setState({- disableConfirmButton: !selectedTagGroupEntry.title,- applyChanges: false,- title: selectedTagGroupEntry.title,- color: selectedTagGroupEntry.color,- textcolor: selectedTagGroupEntry.textcolor,- modifiedDate: selectedTagGroupEntry.modified_date- });- }- };+ componentWillReceiveProps = ({ open, selectedTagGroupEntry }) => {+ if (open === true) {+ this.setState({+ disableConfirmButton: !selectedTagGroupEntry.title,+ applyChanges: false,+ title: selectedTagGroupEntry.title,+ color: selectedTagGroupEntry.color,+ textcolor: selectedTagGroupEntry.textcolor,+ modifiedDate: selectedTagGroupEntry.modified_date+ });+ }+ };- handleInputChange = (event: Object) => {- const target = event.target;- const value = target.type === 'checkbox' ? target.checked : target.value;- const name = target.name;+ handleInputChange = (event: Object) => {+ const target = event.target;+ const value = target.type === 'checkbox' ? target.checked : target.value;+ const name = target.name;- this.setState(- {- [name]: value- },- this.handleValidation- );- };+ this.setState(+ {+ [name]: value+ },+ this.handleValidation+ );+ };- handleValidation() {- if (this.state.title && this.state.title.length > 0) {- this.setState({ inputError: false, disableConfirmButton: false });- } else {- this.setState({ inputError: true, disableConfirmButton: true });- }- }+ handleValidation() {+ if (this.state.title && this.state.title.length > 0) {+ this.setState({ inputError: false, disableConfirmButton: false });+ } else {+ this.setState({ inputError: true, disableConfirmButton: true });+ }+ }- onConfirm = () => {- const { disableConfirmButton, applyChanges } = this.state;- const { selectedTagGroupEntry } = this.props;- if (disableConfirmButton) {- return;- }+ onConfirm = () => {+ const { disableConfirmButton, applyChanges } = this.state;+ const { selectedTagGroupEntry } = this.props;+ if (disableConfirmButton) {+ return;+ }- if (selectedTagGroupEntry && selectedTagGroupEntry.children) {- this.props.editTagGroup({- ...selectedTagGroupEntry,- title: this.state.title,- color: this.state.color,- textcolor: this.state.textcolor,- children: selectedTagGroupEntry.children.map(tag => ({- ...tag,- color: applyChanges ? this.state.color : tag.color,- textcolor: applyChanges ? this.state.textcolor : tag.textcolor,- style: tag.style- }))- });- this.setState({ inputError: false, disableConfirmButton: true });- this.props.onClose();- }- };+ if (selectedTagGroupEntry && selectedTagGroupEntry.children) {+ this.props.editTagGroup({+ ...selectedTagGroupEntry,+ title: this.state.title,+ color: this.state.color,+ textcolor: this.state.textcolor,+ children: selectedTagGroupEntry.children.map(tag => ({+ ...tag,+ color: applyChanges ? this.state.color : tag.color,+ textcolor: applyChanges ? this.state.textcolor : tag.textcolor,+ style: tag.style+ }))+ });+ this.setState({ inputError: false, disableConfirmButton: true });+ this.props.onClose();+ }+ };- toggleDefaultTagBackgroundColorPicker = () => {- this.setState({ displayColorPicker: !this.state.displayColorPicker });- };+ toggleDefaultTagBackgroundColorPicker = () => {+ this.setState({ displayColorPicker: !this.state.displayColorPicker });+ };- toggleDefaultTagTextColorPicker = () => {- this.setState({- displayTextColorPicker: !this.state.displayTextColorPicker- });- };+ toggleDefaultTagTextColorPicker = () => {+ this.setState({+ displayTextColorPicker: !this.state.displayTextColorPicker+ });+ };- handleChangeColor = (color: string) => {- this.setState({ color });- };+ handleChangeColor = (color: string) => {+ this.setState({ color });+ };- handleChangeTextColor = (color: string) => {- this.setState({ textcolor: color });- };+ handleChangeTextColor = (color: string) => {+ this.setState({ textcolor: color });+ };- setApplyChanges = (applyColorChanges: boolean) => {- this.setState({ applyChanges: applyColorChanges });- };+ setApplyChanges = (applyColorChanges: boolean) => {+ this.setState({ applyChanges: applyColorChanges });+ };- renderTitle = () => (- <DialogTitle style={{ overflow: 'visible' }}>- {i18n.t('core:editTagGroupTitle')}- {` '${this.state.title}'`}- </DialogTitle>- );+ renderTitle = () => (+ <DialogTitle style={{ overflow: 'visible' }}>+ {i18n.t('core:editTagGroupTitle')}+ {` '${this.state.title}'`}+ </DialogTitle>+ );- renderContent = () => {- const { color, textcolor, modifiedDate } = this.state;- const styles = {- color: {- width: '100%',- height: 30,- borderRadius: 2,- borderWidth: 1,- borderStyle: 'solid',- borderColor: 'gray',- padding: '5px',- background: color- },- textcolor: {- width: '100%',- height: 30,- borderRadius: 2,- borderWidth: 1,- borderStyle: 'solid',- borderColor: 'gray',- padding: '5px',- background: textcolor- },- helpText: {- marginBottom: '5px',- fontSize: '1rem'- }- };+ renderContent = () => {+ const { color, textcolor, modifiedDate } = this.state;+ const styles = {+ color: {+ width: '100%',+ height: 30,+ borderRadius: 2,+ borderWidth: 1,+ borderStyle: 'solid',+ borderColor: 'gray',+ padding: '5px',+ background: color+ },+ textcolor: {+ width: '100%',+ height: 30,+ borderRadius: 2,+ borderWidth: 1,+ borderStyle: 'solid',+ borderColor: 'gray',+ padding: '5px',+ background: textcolor+ },+ helpText: {+ marginBottom: '5px',+ fontSize: '1rem'+ }+ };- return (- <DialogContent style={{ overflow: 'visible' }}>- <FormControl- fullWidth={true}- error={this.state.inputError}- style={{ overflow: 'visible' }}- >- {modifiedDate && (- <div- className="tag-date"- style={{- fontSize: 12,- position: 'relative',- bottom: 20,- color: '#808080'- }}- >- <span className="text" style={{ fontWeight: 600 }}>{`${i18n.t(- 'core:modifiedDate'- )}: `}</span>- <time>{format(new Date(modifiedDate), 'yyyy-mm-dd')}</time>- </div>- )}- <TextField- error={this.state.inputError}- margin="dense"- name="title"- autoFocus- label={i18n.t('core:editTagGroupNewName')}- onChange={this.handleInputChange}- value={this.state.title}- data-tid="editTagGroupInput"- fullWidth={true}- />- {this.state.inputError && (- <FormHelperText>- {i18n.t('core:taggroupTitleHelper')}- </FormHelperText>- )}- </FormControl>- <FormControl fullWidth={true}>- <FormHelperText style={styles.helpText}>- {i18n.t('core:tagBackgroundColor')}- </FormHelperText>- <TransparentBackground>- <Button- onClick={this.toggleDefaultTagBackgroundColorPicker}- data-tid="editTagGroupBackgroundColor"- style={styles.color}- >- - </Button>- </TransparentBackground>- <ColorPickerDialog- open={this.state.displayColorPicker}- setColor={this.handleChangeColor}- onClose={this.toggleDefaultTagBackgroundColorPicker}- color={this.state.color}- />- </FormControl>- <FormControl fullWidth={true}>- <FormHelperText style={styles.helpText}>- {i18n.t('core:tagForegroundColor')}- </FormHelperText>- <TransparentBackground>- <Button- onClick={this.toggleDefaultTagTextColorPicker}- data-tid="editTagGroupForegroundColor"- style={styles.textcolor}- role="presentation"- >- - </Button>- </TransparentBackground>- <ColorPickerDialog- open={this.state.displayTextColorPicker}- setColor={this.handleChangeTextColor}- onClose={this.toggleDefaultTagTextColorPicker}- color={this.state.textcolor}- />- </FormControl>- <FormControl>- <FormHelperText style={styles.helpText}>- {i18n.t('core:colorChangesToAllTags')}- </FormHelperText>- <Switch- data-tid="editTagGroupSwitch"- onClick={() => this.setApplyChanges(!this.state.applyChanges)}- checked={this.state.applyChanges}- />- </FormControl>- </DialogContent>- );- };+ return (+ <DialogContent style={{ overflow: 'visible' }}>+ <FormControl+ fullWidth={true}+ error={this.state.inputError}+ style={{ overflow: 'visible' }}+ >+ {modifiedDate && (+ <div+ className="tag-date"+ style={{+ fontSize: 12,+ position: 'relative',+ bottom: 20,+ color: '#808080'+ }}+ >+ <span className="text" style={{ fontWeight: 600 }}>{`${i18n.t(+ 'core:modifiedDate'+ )}: `}</span>+ <time>{format(new Date(modifiedDate), 'yyyy-mm-dd')}</time>+ </div>+ )}+ <TextField+ error={this.state.inputError}+ margin="dense"+ name="title"+ autoFocus+ label={i18n.t('core:editTagGroupNewName')}+ onChange={this.handleInputChange}+ value={this.state.title}+ data-tid="editTagGroupInput"+ fullWidth={true}+ />+ {this.state.inputError && (+ <FormHelperText>+ {i18n.t('core:taggroupTitleHelper')}+ </FormHelperText>+ )}+ </FormControl>+ <FormControl fullWidth={true}>+ <FormHelperText style={styles.helpText}>+ {i18n.t('core:tagBackgroundColor')}+ </FormHelperText>+ <TransparentBackground>+ <Button+ onClick={this.toggleDefaultTagBackgroundColorPicker}+ data-tid="editTagGroupBackgroundColor"+ style={styles.color}+ >+ + </Button>+ </TransparentBackground>+ <ColorPickerDialog+ open={this.state.displayColorPicker}+ setColor={this.handleChangeColor}+ onClose={this.toggleDefaultTagBackgroundColorPicker}+ color={this.state.color}+ />+ </FormControl>+ <FormControl fullWidth={true}>+ <FormHelperText style={styles.helpText}>+ {i18n.t('core:tagForegroundColor')}+ </FormHelperText>+ <TransparentBackground>+ <Button+ onClick={this.toggleDefaultTagTextColorPicker}+ data-tid="editTagGroupForegroundColor"+ style={styles.textcolor}+ role="presentation"+ >+ + </Button>+ </TransparentBackground>+ <ColorPickerDialog+ open={this.state.displayTextColorPicker}+ setColor={this.handleChangeTextColor}+ onClose={this.toggleDefaultTagTextColorPicker}+ color={this.state.textcolor}+ />+ </FormControl>+ <FormControl>+ <FormHelperText style={styles.helpText}>+ {i18n.t('core:colorChangesToAllTags')}+ </FormHelperText>+ <Switch+ data-tid="editTagGroupSwitch"+ onClick={() => this.setApplyChanges(!this.state.applyChanges)}+ checked={this.state.applyChanges}+ />+ </FormControl>+ </DialogContent>+ );+ };- renderActions = () => (- <DialogActions>- <Button onClick={this.props.onClose} color="primary">- {i18n.t('core:cancel')}- </Button>- <Button- disabled={this.state.disableConfirmButton}- onClick={this.onConfirm}- data-tid="editTagGroupConfirmButton"- color="primary"- >- {i18n.t('core:ok')}- </Button>- </DialogActions>- );+ renderActions = () => (+ <DialogActions>+ <Button onClick={this.props.onClose} color="primary">+ {i18n.t('core:cancel')}+ </Button>+ <Button+ disabled={this.state.disableConfirmButton}+ onClick={this.onConfirm}+ data-tid="editTagGroupConfirmButton"+ color="primary"+ >+ {i18n.t('core:ok')}+ </Button>+ </DialogActions>+ );- render() {- const { onClose, open, fullScreen } = this.props;- return (- <Dialog- open={open}- fullScreen={fullScreen}- onClose={onClose}- // onEnterKey={(event) => onEnterKeyHandler(event, this.onConfirm)}- >- {this.renderTitle()}- {this.renderContent()}- {this.renderActions()}- </Dialog>- );- }+ render() {+ const { onClose, open, fullScreen } = this.props;+ return (+ <Dialog+ open={open}+ fullScreen={fullScreen}+ onClose={onClose}+ // onEnterKey={(event) => onEnterKeyHandler(event, this.onConfirm)}+ >+ {this.renderTitle()}+ {this.renderContent()}+ {this.renderActions()}+ </Dialog>+ );+ }}export default EditTagGroupDialog;diff --git a/app/components/dialogs/GenericDialog.tsx b/app/components/dialogs/GenericDialog.tsxindex 6d6eaebfd..24f021714 100644--- a/app/components/dialogs/GenericDialog.tsx+++ b/app/components/dialogs/GenericDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/dialogs/ImportExportTagGroupsDialog.tsx b/app/components/dialogs/ImportExportTagGroupsDialog.tsxindex 6da705ced..2ecc053f2 100644--- a/app/components/dialogs/ImportExportTagGroupsDialog.tsx+++ b/app/components/dialogs/ImportExportTagGroupsDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/dialogs/KeyboardDialog.tsx b/app/components/dialogs/KeyboardDialog.tsxindex 1c644bdd2..9e78760b6 100644--- a/app/components/dialogs/KeyboardDialog.tsx+++ b/app/components/dialogs/KeyboardDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/dialogs/LicenseDialog.tsx b/app/components/dialogs/LicenseDialog.tsxindex 5ec0c61a3..8961f03db 100644--- a/app/components/dialogs/LicenseDialog.tsx+++ b/app/components/dialogs/LicenseDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/dialogs/LocalForm.tsx b/app/components/dialogs/LocalForm.tsxindex 45fdf5ca1..a0fdd98c4 100644--- a/app/components/dialogs/LocalForm.tsx+++ b/app/components/dialogs/LocalForm.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/dialogs/MoveCopyFilesDialog.tsx b/app/components/dialogs/MoveCopyFilesDialog.tsxindex 7c7cdb494..8f810c1bc 100644--- a/app/components/dialogs/MoveCopyFilesDialog.tsx+++ b/app/components/dialogs/MoveCopyFilesDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React, { useState, useEffect } from 'react';diff --git a/app/components/dialogs/ObjectStoreForm.tsx b/app/components/dialogs/ObjectStoreForm.tsxindex ecb9aa4e8..fcbce1ffe 100644--- a/app/components/dialogs/ObjectStoreForm.tsx+++ b/app/components/dialogs/ObjectStoreForm.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/dialogs/OnboardingDialog.tsx b/app/components/dialogs/OnboardingDialog.tsxindex 38335fcb3..2ba3b3720 100644--- a/app/components/dialogs/OnboardingDialog.tsx+++ b/app/components/dialogs/OnboardingDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React, { useState } from 'react';diff --git a/app/components/dialogs/ProTeaserDialog.tsx b/app/components/dialogs/ProTeaserDialog.tsxindex 716849f51..5d7eac954 100644--- a/app/components/dialogs/ProTeaserDialog.tsx+++ b/app/components/dialogs/ProTeaserDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/dialogs/RenameDirectoryDialog.tsx b/app/components/dialogs/RenameDirectoryDialog.tsxindex 9184197a1..1a15b1933 100644--- a/app/components/dialogs/RenameDirectoryDialog.tsx+++ b/app/components/dialogs/RenameDirectoryDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/dialogs/RenameFileDialog.tsx b/app/components/dialogs/RenameFileDialog.tsxindex 2a1f1e095..b83a9499c 100644--- a/app/components/dialogs/RenameFileDialog.tsx+++ b/app/components/dialogs/RenameFileDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/dialogs/SelectDirectoryDialog.tsx b/app/components/dialogs/SelectDirectoryDialog.tsxindex 1a6832526..26f625e4c 100644--- a/app/components/dialogs/SelectDirectoryDialog.tsx+++ b/app/components/dialogs/SelectDirectoryDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/dialogs/ThirdPartyLibsDialog.tsx b/app/components/dialogs/ThirdPartyLibsDialog.tsxindex db5b05be0..807d3dbd0 100644--- a/app/components/dialogs/ThirdPartyLibsDialog.tsx+++ b/app/components/dialogs/ThirdPartyLibsDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/dialogs/settings/SettingsDialog.tsx b/app/components/dialogs/settings/SettingsDialog.tsxindex 01939f3d1..44c7e665c 100644--- a/app/components/dialogs/settings/SettingsDialog.tsx+++ b/app/components/dialogs/settings/SettingsDialog.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/dialogs/settings/SettingsFileTypes.tsx b/app/components/dialogs/settings/SettingsFileTypes.tsxindex 78e8c78a5..3e1c88bba 100644--- a/app/components/dialogs/settings/SettingsFileTypes.tsx+++ b/app/components/dialogs/settings/SettingsFileTypes.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React, { Component } from 'react';diff --git a/app/components/dialogs/settings/SettingsGeneral.tsx b/app/components/dialogs/settings/SettingsGeneral.tsxindex bc72dea4a..0907312e3 100644--- a/app/components/dialogs/settings/SettingsGeneral.tsx+++ b/app/components/dialogs/settings/SettingsGeneral.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/dialogs/settings/SettingsKeyBindings.tsx b/app/components/dialogs/settings/SettingsKeyBindings.tsxindex b53e1a522..d4b28c772 100644--- a/app/components/dialogs/settings/SettingsKeyBindings.tsx+++ b/app/components/dialogs/settings/SettingsKeyBindings.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/menus/DirectoryMenu.tsx b/app/components/menus/DirectoryMenu.tsxindex b948a0f42..fb4c49444 100644--- a/app/components/menus/DirectoryMenu.tsx+++ b/app/components/menus/DirectoryMenu.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React, { useState } from 'react';diff --git a/app/components/menus/EntryTagMenu.tsx b/app/components/menus/EntryTagMenu.tsxindex b5253c747..261b353ec 100644--- a/app/components/menus/EntryTagMenu.tsx+++ b/app/components/menus/EntryTagMenu.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React, { useState } from 'react';@@ -29,124 +28,124 @@ import Menu from '@material-ui/core/Menu';import MenuItem from '@material-ui/core/MenuItem';import ConfirmDialog from '../dialogs/ConfirmDialog';import i18n from '../../services/i18n';-import { type Tag } from '../../reducers/taglibrary';+import { Tag } from '../../reducers/taglibrary';import { actions as LocationIndexActions } from '../../reducers/location-index';-import { type SearchQuery } from '../../services/search';+import { SearchQuery } from '../../services/search';import { getMaxSearchResults } from '../../reducers/settings';import { actions as AppActions } from '../../reducers/app';type Props = {- open: boolean,- onClose: () => void,- anchorEl: Object | null,- selectedTag: Tag | null,- currentEntryPath: string,- removeTags: (paths: Array<string>, tags: Array<Tag>) => void,- searchLocationIndex: (searchQuery: SearchQuery) => void,- maxSearchResults: number,- openSearchPanel: () => void,- toggleEditTagDialog: (tag: Tag) => void,- isReadOnlyMode: boolean+ open: boolean;+ onClose: () => void;+ anchorEl: Object | null;+ selectedTag: Tag | null;+ currentEntryPath: string;+ removeTags: (paths: Array<string>, tags: Array<Tag>) => void;+ searchLocationIndex: (searchQuery: SearchQuery) => void;+ maxSearchResults: number;+ openSearchPanel: () => void;+ toggleEditTagDialog: (tag: Tag) => void;+ isReadOnlyMode: boolean;};const EntryTagMenu = (props: Props) => {- const [isDeleteTagDialogOpened, setIsDeleteTagDialogOpened] = useState(false);+ const [isDeleteTagDialogOpened, setIsDeleteTagDialogOpened] = useState(false);- function showEditTagDialog() {- props.onClose();- // setIsEditTagDialogOpened(true);- const tag = props.selectedTag;- tag.path = props.currentEntryPath;- props.toggleEditTagDialog(tag);- }+ function showEditTagDialog() {+ props.onClose();+ // setIsEditTagDialogOpened(true);+ const tag = props.selectedTag;+ tag.path = props.currentEntryPath;+ props.toggleEditTagDialog(tag);+ }- function showDeleteTagDialog() {- props.onClose();- setIsDeleteTagDialogOpened(true);- }+ function showDeleteTagDialog() {+ props.onClose();+ setIsDeleteTagDialogOpened(true);+ }- function showFilesWithThisTag() {- if (props.selectedTag) {- props.openSearchPanel();- props.searchLocationIndex({- tagsAND: [props.selectedTag],- maxSearchResults: props.maxSearchResults- });- }- props.onClose();- }+ function showFilesWithThisTag() {+ if (props.selectedTag) {+ props.openSearchPanel();+ props.searchLocationIndex({+ tagsAND: [props.selectedTag],+ maxSearchResults: props.maxSearchResults+ });+ }+ props.onClose();+ }- function handleCloseDialogs() {- setIsDeleteTagDialogOpened(false);- }+ function handleCloseDialogs() {+ setIsDeleteTagDialogOpened(false);+ }- function confirmRemoveTag() {- props.removeTags([props.currentEntryPath], [props.selectedTag]);- handleCloseDialogs();- }+ function confirmRemoveTag() {+ props.removeTags([props.currentEntryPath], [props.selectedTag]);+ handleCloseDialogs();+ }- return (- <div style={{ overflowY: 'hidden !important' }}>- <Menu anchorEl={props.anchorEl} open={props.open} onClose={props.onClose}>- <MenuItem- data-tid="showFilesWithThisTag"- onClick={showFilesWithThisTag}- >- <ListItemIcon>- <ShowEntriesWithTagIcon />- </ListItemIcon>- <ListItemText primary={i18n.t('core:showFilesWithThisTag')} />- </MenuItem>- <MenuItem data-tid="editTagDialogMenu" onClick={showEditTagDialog}>- <ListItemIcon>- <EditIcon />- </ListItemIcon>- <ListItemText primary={i18n.t('core:editTagTitle')} />- </MenuItem>- {!props.isReadOnlyMode && (- <div>- <MenuItem data-tid="deleteTagMenu" onClick={showDeleteTagDialog}>- <ListItemIcon>- <DeleteIcon />- </ListItemIcon>- <ListItemText primary={i18n.t('core:removeTag')} />- </MenuItem>- </div>- )}- </Menu>- <ConfirmDialog- open={isDeleteTagDialogOpened}- onClose={handleCloseDialogs}- title={i18n.t('core:removeTag')}- content={i18n.t('core:removeTagTooltip')}- confirmCallback={result => {- if (result) {- confirmRemoveTag();- }- }}- cancelDialogTID={'cancelDeleteTagDialogTagMenu'}- confirmDialogTID={'confirmRemoveTagFromFile'}- confirmDialogContent={'confirmDialogContent'}- />- </div>- );+ return (+ <div style={{ overflowY: 'hidden !important' }}>+ <Menu anchorEl={props.anchorEl} open={props.open} onClose={props.onClose}>+ <MenuItem+ data-tid="showFilesWithThisTag"+ onClick={showFilesWithThisTag}+ >+ <ListItemIcon>+ <ShowEntriesWithTagIcon />+ </ListItemIcon>+ <ListItemText primary={i18n.t('core:showFilesWithThisTag')} />+ </MenuItem>+ <MenuItem data-tid="editTagDialogMenu" onClick={showEditTagDialog}>+ <ListItemIcon>+ <EditIcon />+ </ListItemIcon>+ <ListItemText primary={i18n.t('core:editTagTitle')} />+ </MenuItem>+ {!props.isReadOnlyMode && (+ <div>+ <MenuItem data-tid="deleteTagMenu" onClick={showDeleteTagDialog}>+ <ListItemIcon>+ <DeleteIcon />+ </ListItemIcon>+ <ListItemText primary={i18n.t('core:removeTag')} />+ </MenuItem>+ </div>+ )}+ </Menu>+ <ConfirmDialog+ open={isDeleteTagDialogOpened}+ onClose={handleCloseDialogs}+ title={i18n.t('core:removeTag')}+ content={i18n.t('core:removeTagTooltip')}+ confirmCallback={result => {+ if (result) {+ confirmRemoveTag();+ }+ }}+ cancelDialogTID={'cancelDeleteTagDialogTagMenu'}+ confirmDialogTID={'confirmRemoveTagFromFile'}+ confirmDialogContent={'confirmDialogContent'}+ />+ </div>+ );};function mapStateToProps(state) {- return {- maxSearchResults: getMaxSearchResults(state)- };+ return {+ maxSearchResults: getMaxSearchResults(state)+ };}function mapDispatchToProps(dispatch) {- return bindActionCreators(- {- searchLocationIndex: LocationIndexActions.searchLocationIndex,- openSearchPanel: AppActions.openSearchPanel,- toggleEditTagDialog: AppActions.toggleEditTagDialog- },- dispatch- );+ return bindActionCreators(+ {+ searchLocationIndex: LocationIndexActions.searchLocationIndex,+ openSearchPanel: AppActions.openSearchPanel,+ toggleEditTagDialog: AppActions.toggleEditTagDialog+ },+ dispatch+ );}export default connect(mapStateToProps, mapDispatchToProps)(EntryTagMenu);diff --git a/app/components/menus/FileMenu.tsx b/app/components/menus/FileMenu.tsxindex 16b5ce988..5ddaa728b 100644--- a/app/components/menus/FileMenu.tsx+++ b/app/components/menus/FileMenu.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/menus/LocationManagerMenu.tsx b/app/components/menus/LocationManagerMenu.tsxindex c7f062e37..2829cbdfa 100644--- a/app/components/menus/LocationManagerMenu.tsx+++ b/app/components/menus/LocationManagerMenu.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/menus/LocationMenu.tsx b/app/components/menus/LocationMenu.tsxindex e68baa5b0..40413892d 100644--- a/app/components/menus/LocationMenu.tsx+++ b/app/components/menus/LocationMenu.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/menus/SearchMenu.tsx b/app/components/menus/SearchMenu.tsxindex 8c4916e8e..4d4e4b3b2 100644--- a/app/components/menus/SearchMenu.tsx+++ b/app/components/menus/SearchMenu.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/components/menus/TagGroupMenu.tsx b/app/components/menus/TagGroupMenu.tsxindex 6764fac4c..4c6567ec6 100644--- a/app/components/menus/TagGroupMenu.tsx+++ b/app/components/menus/TagGroupMenu.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';@@ -29,123 +28,123 @@ import TagIcon from '@material-ui/icons/LocalOffer';import CollectTagsIcon from '@material-ui/icons/Voicemail';import Menu from '@material-ui/core/Menu';import MenuItem from '@material-ui/core/MenuItem';-import { type TagGroup } from '../../reducers/taglibrary';+import { TagGroup } from '../../reducers/taglibrary';import i18n from '../../services/i18n';import { Pro } from '../../pro';type Props = {- classes: Object,- anchorEl: Object,- open: boolean,- onClose: () => void,- selectedTagGroupEntry: TagGroup,- showCreateTagsDialog: () => void,- showDeleteTagGroupDialog: () => void,- showEditTagGroupDialog: () => void,- moveTagGroupUp: (tagGroupId: string) => void,- moveTagGroupDown: (tagGroupId: string) => void,- sortTagGroup: (tagGroupId: string) => void,- collectTagsFromLocation: (tagGroup: TagGroup) => void,- handleCloseTagGroupMenu: () => void+ classes: Object;+ anchorEl: Object;+ open: boolean;+ onClose: () => void;+ selectedTagGroupEntry: TagGroup;+ showCreateTagsDialog: () => void;+ showDeleteTagGroupDialog: () => void;+ showEditTagGroupDialog: () => void;+ moveTagGroupUp: (tagGroupId: string) => void;+ moveTagGroupDown: (tagGroupId: string) => void;+ sortTagGroup: (tagGroupId: string) => void;+ collectTagsFromLocation: (tagGroup: TagGroup) => void;+ handleCloseTagGroupMenu: () => void;};const TagLibraryMenu = (props: Props) => {- function handleCollectTags() {- props.onClose();+ function handleCollectTags() {+ props.onClose();- if (props.selectedTagGroupEntry) {- props.collectTagsFromLocation(props.selectedTagGroupEntry);- }- props.handleCloseTagGroupMenu();- }+ if (props.selectedTagGroupEntry) {+ props.collectTagsFromLocation(props.selectedTagGroupEntry);+ }+ props.handleCloseTagGroupMenu();+ }- function moveTagGroupUp() {- if (props.selectedTagGroupEntry) {- props.moveTagGroupUp(props.selectedTagGroupEntry.uuid);- }- props.handleCloseTagGroupMenu();- }+ function moveTagGroupUp() {+ if (props.selectedTagGroupEntry) {+ props.moveTagGroupUp(props.selectedTagGroupEntry.uuid);+ }+ props.handleCloseTagGroupMenu();+ }- function moveTagGroupDown() {- if (props.selectedTagGroupEntry) {- props.moveTagGroupDown(props.selectedTagGroupEntry.uuid);- }- props.handleCloseTagGroupMenu();- }+ function moveTagGroupDown() {+ if (props.selectedTagGroupEntry) {+ props.moveTagGroupDown(props.selectedTagGroupEntry.uuid);+ }+ props.handleCloseTagGroupMenu();+ }- function sortTagGroup() {- if (props.selectedTagGroupEntry) {- props.sortTagGroup(props.selectedTagGroupEntry.uuid);- }- props.handleCloseTagGroupMenu();- }+ function sortTagGroup() {+ if (props.selectedTagGroupEntry) {+ props.sortTagGroup(props.selectedTagGroupEntry.uuid);+ }+ props.handleCloseTagGroupMenu();+ }- return (- <div style={{ overflowY: 'hidden !important' }}>- <Menu- anchorEl={props.anchorEl}- open={props.open}- onClose={props.handleCloseTagGroupMenu}- >- <MenuItem data-tid="createTags" onClick={props.showCreateTagsDialog}>- <ListItemIcon>- <TagIcon />- </ListItemIcon>- <ListItemText primary={i18n.t('core:addTags')} />- </MenuItem>- <MenuItem- data-tid="editTagGroup"- onClick={props.showEditTagGroupDialog}- >- <ListItemIcon>- <Edit />- </ListItemIcon>- <ListItemText primary={i18n.t('core:editTagGroup')} />- </MenuItem>- <MenuItem data-tid="moveTagGroupUp" onClick={moveTagGroupUp}>- <ListItemIcon>- <ArrowUpward />- </ListItemIcon>- <ListItemText primary={i18n.t('core:moveTagGroupUp')} />- </MenuItem>- <MenuItem data-tid="moveTagGroupDown" onClick={moveTagGroupDown}>- <ListItemIcon>- <ArrowDownward />- </ListItemIcon>- <ListItemText primary={i18n.t('core:moveTagGroupDown')} />- </MenuItem>- <MenuItem data-tid="sortTagGroup" onClick={sortTagGroup}>- <ListItemIcon>- <SortTagGroupIcon />- </ListItemIcon>- <ListItemText primary={i18n.t('core:sortTagGroup')} />- </MenuItem>- <MenuItem- data-tid="deleteTagGroup"- onClick={props.showDeleteTagGroupDialog}- >- <ListItemIcon>- <DeleteTagGroupIcon />- </ListItemIcon>- <ListItemText primary={i18n.t('core:deleteTagGroup')} />- </MenuItem>- <MenuItem- data-tid="collectTags"- onClick={handleCollectTags}- title={Pro ? '' : i18n.t('core:needProVersion')}- >- <ListItemIcon>- <CollectTagsIcon />- </ListItemIcon>- <ListItemText- primary={- i18n.t('core:collectTagsFromLocation') + (Pro ? '' : ' PRO')- }- />- </MenuItem>- </Menu>- </div>- );+ return (+ <div style={{ overflowY: 'hidden !important' }}>+ <Menu+ anchorEl={props.anchorEl}+ open={props.open}+ onClose={props.handleCloseTagGroupMenu}+ >+ <MenuItem data-tid="createTags" onClick={props.showCreateTagsDialog}>+ <ListItemIcon>+ <TagIcon />+ </ListItemIcon>+ <ListItemText primary={i18n.t('core:addTags')} />+ </MenuItem>+ <MenuItem+ data-tid="editTagGroup"+ onClick={props.showEditTagGroupDialog}+ >+ <ListItemIcon>+ <Edit />+ </ListItemIcon>+ <ListItemText primary={i18n.t('core:editTagGroup')} />+ </MenuItem>+ <MenuItem data-tid="moveTagGroupUp" onClick={moveTagGroupUp}>+ <ListItemIcon>+ <ArrowUpward />+ </ListItemIcon>+ <ListItemText primary={i18n.t('core:moveTagGroupUp')} />+ </MenuItem>+ <MenuItem data-tid="moveTagGroupDown" onClick={moveTagGroupDown}>+ <ListItemIcon>+ <ArrowDownward />+ </ListItemIcon>+ <ListItemText primary={i18n.t('core:moveTagGroupDown')} />+ </MenuItem>+ <MenuItem data-tid="sortTagGroup" onClick={sortTagGroup}>+ <ListItemIcon>+ <SortTagGroupIcon />+ </ListItemIcon>+ <ListItemText primary={i18n.t('core:sortTagGroup')} />+ </MenuItem>+ <MenuItem+ data-tid="deleteTagGroup"+ onClick={props.showDeleteTagGroupDialog}+ >+ <ListItemIcon>+ <DeleteTagGroupIcon />+ </ListItemIcon>+ <ListItemText primary={i18n.t('core:deleteTagGroup')} />+ </MenuItem>+ <MenuItem+ data-tid="collectTags"+ onClick={handleCollectTags}+ title={Pro ? '' : i18n.t('core:needProVersion')}+ >+ <ListItemIcon>+ <CollectTagsIcon />+ </ListItemIcon>+ <ListItemText+ primary={+ i18n.t('core:collectTagsFromLocation') + (Pro ? '' : ' PRO')+ }+ />+ </MenuItem>+ </Menu>+ </div>+ );};export default TagLibraryMenu;diff --git a/app/components/menus/TagLibraryMenu.tsx b/app/components/menus/TagLibraryMenu.tsxindex 809ff8f0f..931af630b 100644--- a/app/components/menus/TagLibraryMenu.tsx+++ b/app/components/menus/TagLibraryMenu.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React, { useState } from 'react';diff --git a/app/components/menus/TagMenu.tsx b/app/components/menus/TagMenu.tsxindex 590e6a0d9..b500c12aa 100644--- a/app/components/menus/TagMenu.tsx+++ b/app/components/menus/TagMenu.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React, { useState } from 'react';@@ -29,139 +28,139 @@ import Menu from '@material-ui/core/Menu';import MenuItem from '@material-ui/core/MenuItem';import ConfirmDialog from '../dialogs/ConfirmDialog';import EditTagDialog from '../dialogs/EditTagDialog';-import { type Tag, type TagGroup } from '../../reducers/taglibrary';+import { Tag, TagGroup } from '../../reducers/taglibrary';import { actions as LocationIndexActions } from '../../reducers/location-index';import i18n from '../../services/i18n';-import { type SearchQuery } from '../../services/search';+import { SearchQuery } from '../../services/search';import { getMaxSearchResults } from '../../reducers/settings';import { actions as AppActions } from '../../reducers/app';const isTagLibraryReadOnly =- window.ExtTagLibrary && window.ExtTagLibrary.length > 0;+ window.ExtTagLibrary && window.ExtTagLibrary.length > 0;type Props = {- anchorEl?: Object,- open?: boolean,- onClose: () => void,- selectedTag?: Tag,- selectedTagGroupEntry?: TagGroup,- deleteTag: (uuid: string, tagGroupUuid: string) => void,- searchLocationIndex: (searchQuery: SearchQuery) => void,- editTag: () => void,- openSearchPanel: () => void,- maxSearchResults: number+ anchorEl?: Object;+ open?: boolean;+ onClose: () => void;+ selectedTag?: Tag;+ selectedTagGroupEntry?: TagGroup;+ deleteTag: (uuid: string, tagGroupUuid: string) => void;+ searchLocationIndex: (searchQuery: SearchQuery) => void;+ editTag: () => void;+ openSearchPanel: () => void;+ maxSearchResults: number;};const TagLibraryMenu = (props: Props) => {- const [isEditTagDialogOpened, setIsEditTagDialogOpened] = useState(false);- const [isDeleteTagDialogOpened, setIsDeleteTagDialogOpened] = useState(false);+ const [isEditTagDialogOpened, setIsEditTagDialogOpened] = useState(false);+ const [isDeleteTagDialogOpened, setIsDeleteTagDialogOpened] = useState(false);- function tagSelectedFiles() {- // TODO not implemented- props.onClose();- }+ function tagSelectedFiles() {+ // TODO not implemented+ props.onClose();+ }- function showFilesWithThisTag() {- if (props.selectedTag) {- props.openSearchPanel();- props.searchLocationIndex({- tagsAND: [props.selectedTag],- maxSearchResults: props.maxSearchResults- });- }- props.onClose();- }+ function showFilesWithThisTag() {+ if (props.selectedTag) {+ props.openSearchPanel();+ props.searchLocationIndex({+ tagsAND: [props.selectedTag],+ maxSearchResults: props.maxSearchResults+ });+ }+ props.onClose();+ }- function showEditTagDialog() {- props.onClose();- setIsEditTagDialogOpened(true);- }+ function showEditTagDialog() {+ props.onClose();+ setIsEditTagDialogOpened(true);+ }- function showDeleteTagDialog() {- props.onClose();- setIsDeleteTagDialogOpened(true);- }+ function showDeleteTagDialog() {+ props.onClose();+ setIsDeleteTagDialogOpened(true);+ }- function handleCloseDialogs() {- setIsEditTagDialogOpened(false);- setIsDeleteTagDialogOpened(false);- }+ function handleCloseDialogs() {+ setIsEditTagDialogOpened(false);+ setIsDeleteTagDialogOpened(false);+ }- function confirmDeleteTag() {- if (props.selectedTag && props.selectedTagGroupEntry) {- props.deleteTag(props.selectedTag.id, props.selectedTagGroupEntry.uuid);- }- }+ function confirmDeleteTag() {+ if (props.selectedTag && props.selectedTagGroupEntry) {+ props.deleteTag(props.selectedTag.id, props.selectedTagGroupEntry.uuid);+ }+ }- return (- <div style={{ overflowY: 'hidden !important' }}>- <Menu anchorEl={props.anchorEl} open={props.open} onClose={props.onClose}>- <MenuItem- data-tid="showFilesWithThisTag"- onClick={showFilesWithThisTag}- >- <ListItemIcon>- <ShowEntriesWithTagIcon />- </ListItemIcon>- <ListItemText primary={i18n.t('core:showFilesWithThisTag')} />- </MenuItem>- {!isTagLibraryReadOnly && (- <MenuItem data-tid="editTagDialog" onClick={showEditTagDialog}>- <ListItemIcon>- <Edit />- </ListItemIcon>- <ListItemText primary={i18n.t('core:editTag')} />- </MenuItem>- )}- {!isTagLibraryReadOnly && (- <MenuItem data-tid="deleteTagDialog" onClick={showDeleteTagDialog}>- <ListItemIcon>- <DeleteIcon />- </ListItemIcon>- <ListItemText primary={i18n.t('core:deleteTagFromTagGroup')} />- </MenuItem>- )}- </Menu>- <EditTagDialog- open={isEditTagDialogOpened}- onClose={handleCloseDialogs}- editTag={props.editTag}- selectedTagGroupEntry={props.selectedTagGroupEntry}- selectedTag={props.selectedTag}- />- <ConfirmDialog- open={isDeleteTagDialogOpened}- onClose={handleCloseDialogs}- title={i18n.t('core:deleteTagFromTagGroup')}- content={i18n.t('core:deleteTagFromTagGroupContentConfirm', {- tagName: props.selectedTag ? props.selectedTag.title : ''- })}- confirmCallback={result => {- if (result) {- confirmDeleteTag();- }- }}- cancelDialogTID={'cancelDeleteTagDialogTagMenu'}- confirmDialogTID={'confirmDeleteTagDialogTagMenu'}- />- </div>- );+ return (+ <div style={{ overflowY: 'hidden !important' }}>+ <Menu anchorEl={props.anchorEl} open={props.open} onClose={props.onClose}>+ <MenuItem+ data-tid="showFilesWithThisTag"+ onClick={showFilesWithThisTag}+ >+ <ListItemIcon>+ <ShowEntriesWithTagIcon />+ </ListItemIcon>+ <ListItemText primary={i18n.t('core:showFilesWithThisTag')} />+ </MenuItem>+ {!isTagLibraryReadOnly && (+ <MenuItem data-tid="editTagDialog" onClick={showEditTagDialog}>+ <ListItemIcon>+ <Edit />+ </ListItemIcon>+ <ListItemText primary={i18n.t('core:editTag')} />+ </MenuItem>+ )}+ {!isTagLibraryReadOnly && (+ <MenuItem data-tid="deleteTagDialog" onClick={showDeleteTagDialog}>+ <ListItemIcon>+ <DeleteIcon />+ </ListItemIcon>+ <ListItemText primary={i18n.t('core:deleteTagFromTagGroup')} />+ </MenuItem>+ )}+ </Menu>+ <EditTagDialog+ open={isEditTagDialogOpened}+ onClose={handleCloseDialogs}+ editTag={props.editTag}+ selectedTagGroupEntry={props.selectedTagGroupEntry}+ selectedTag={props.selectedTag}+ />+ <ConfirmDialog+ open={isDeleteTagDialogOpened}+ onClose={handleCloseDialogs}+ title={i18n.t('core:deleteTagFromTagGroup')}+ content={i18n.t('core:deleteTagFromTagGroupContentConfirm', {+ tagName: props.selectedTag ? props.selectedTag.title : ''+ })}+ confirmCallback={result => {+ if (result) {+ confirmDeleteTag();+ }+ }}+ cancelDialogTID={'cancelDeleteTagDialogTagMenu'}+ confirmDialogTID={'confirmDeleteTagDialogTagMenu'}+ />+ </div>+ );};function mapStateToProps(state) {- return {- maxSearchResults: getMaxSearchResults(state)- };+ return {+ maxSearchResults: getMaxSearchResults(state)+ };}function mapDispatchToProps(dispatch) {- return bindActionCreators(- {- openSearchPanel: AppActions.openSearchPanel,- searchLocationIndex: LocationIndexActions.searchLocationIndex- },- dispatch- );+ return bindActionCreators(+ {+ openSearchPanel: AppActions.openSearchPanel,+ searchLocationIndex: LocationIndexActions.searchLocationIndex+ },+ dispatch+ );}export default connect(mapStateToProps, mapDispatchToProps)(TagLibraryMenu);diff --git a/app/containers/App.tsx b/app/containers/App.tsxindex d581546f1..2989130d9 100644--- a/app/containers/App.tsx+++ b/app/containers/App.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React, { Component } from 'react';diff --git a/app/containers/LoginPage.tsx b/app/containers/LoginPage.tsxindex 5eb6da293..e546f6178 100644--- a/app/containers/LoginPage.tsx+++ b/app/containers/LoginPage.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React, { Component } from 'react';diff --git a/app/containers/MainPage.tsx b/app/containers/MainPage.tsxindex 8c8bd2458..f4e42fd6e 100644--- a/app/containers/MainPage.tsx+++ b/app/containers/MainPage.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React, { Component } from 'react';diff --git a/app/containers/Root.tsx b/app/containers/Root.tsxindex f23622259..84fcf0dc0 100644--- a/app/containers/Root.tsx+++ b/app/containers/Root.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/index.ts b/app/index.tsxsimilarity index 99%rename from app/index.tsrename to app/index.tsxindex 148225dfb..b89214149 100644--- a/app/index.ts+++ b/app/index.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/main.dev.ts b/app/main.dev.tsindex 6bb958715..98fdc9647 100644--- a/app/main.dev.ts+++ b/app/main.dev.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import { app, BrowserWindow, ipcMain, globalShortcut, dialog } from 'electron';diff --git a/app/perspectives/grid-perspective/components/CellContent.tsx b/app/perspectives/grid-perspective/components/CellContent.tsxindex 8c7b8b756..74501f6e8 100644--- a/app/perspectives/grid-perspective/components/CellContent.tsx+++ b/app/perspectives/grid-perspective/components/CellContent.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';@@ -30,351 +29,351 @@ import TagIcon from '@material-ui/icons/LocalOffer';import { formatFileSize, formatDateTime } from '../../../utils/misc';import { extractTitle } from '../../../utils/paths';import {- type FileSystemEntry,- findColorForFileEntry+ FileSystemEntry,+ findColorForFileEntry} from '../../../services/utils-io';import TagContainerDnd from '../../../components/TagContainerDnd';import TagContainer from '../../../components/TagContainer';import i18n from '../../../services/i18n';-import { type Tag } from '../../../reducers/taglibrary';+import { Tag } from '../../../reducers/taglibrary';const maxDescriptionPreviewLength = 100;type Props = {- selected: boolean,- fsEntry: FileSystemEntry,- entrySize: string,- classes: Object,- theme: Object,- supportedFileTypes: Array<Object>,- thumbnailMode: any,- addTags: () => void,- openFile: (path: string, isFile: boolean) => void,- selectedEntries: Array<Object>,- isReadOnlyMode: boolean,- showTags: boolean,- handleTagMenu: (event: Object, tag: Tag, entryPath: string) => void,- layoutType: string,- handleGridContextMenu: (event: Object, fsEntry: FileSystemEntry) => void,- handleGridCellDblClick: (event: Object, fsEntry: FileSystemEntry) => void,- handleGridCellClick: (event: Object, fsEntry: FileSystemEntry) => void+ selected: boolean;+ fsEntry: FileSystemEntry;+ entrySize: string;+ classes: Object;+ theme: Object;+ supportedFileTypes: Array<Object>;+ thumbnailMode: any;+ addTags: () => void;+ openFile: (path: string, isFile: boolean) => void;+ selectedEntries: Array<Object>;+ isReadOnlyMode: boolean;+ showTags: boolean;+ handleTagMenu: (event: Object, tag: Tag, entryPath: string) => void;+ layoutType: string;+ handleGridContextMenu: (event: Object, fsEntry: FileSystemEntry) => void;+ handleGridCellDblClick: (event: Object, fsEntry: FileSystemEntry) => void;+ handleGridCellClick: (event: Object, fsEntry: FileSystemEntry) => void;};const CellContent = (props: Props) => {- const {- selected,- fsEntry,- entrySize,- classes,- theme,- supportedFileTypes,- thumbnailMode,- addTags,- selectedEntries,- isReadOnlyMode,- handleTagMenu,- layoutType,- handleGridContextMenu,- handleGridCellDblClick,- handleGridCellClick,- showTags,- openFile- } = props;- const fsEntryBackgroundColor = fsEntry.color ? fsEntry.color : 'transparent';+ const {+ selected,+ fsEntry,+ entrySize,+ classes,+ theme,+ supportedFileTypes,+ thumbnailMode,+ addTags,+ selectedEntries,+ isReadOnlyMode,+ handleTagMenu,+ layoutType,+ handleGridContextMenu,+ handleGridCellDblClick,+ handleGridCellClick,+ showTags,+ openFile+ } = props;+ const fsEntryBackgroundColor = fsEntry.color ? fsEntry.color : 'transparent';- let description = removeMd(fsEntry.description);- if (description.length > maxDescriptionPreviewLength) {- description = description.substr(0, maxDescriptionPreviewLength) + '...';- }+ let description = removeMd(fsEntry.description);+ if (description.length > maxDescriptionPreviewLength) {+ description = description.substr(0, maxDescriptionPreviewLength) + '...';+ }- const fsEntryColor = findColorForFileEntry(- fsEntry.extension,- fsEntry.isFile,- supportedFileTypes- );+ const fsEntryColor = findColorForFileEntry(+ fsEntry.extension,+ fsEntry.isFile,+ supportedFileTypes+ );- // let thumbPathUrl = fsEntry.thumbPath- // ? 'url("' + fsEntry.thumbPath + '")'- // : '';- // if (AppConfig.isWin) {- // thumbPathUrl = thumbPathUrl.split('\\').join('\\\\');- // }+ // let thumbPathUrl = fsEntry.thumbPath+ // ? 'url("' + fsEntry.thumbPath + '")'+ // : '';+ // if (AppConfig.isWin) {+ // thumbPathUrl = thumbPathUrl.split('\\').join('\\\\');+ // }- let tagTitles = '';- fsEntry.tags.map(tag => {- tagTitles += tag.title + ', ';- return true;- });- tagTitles = tagTitles.substring(0, tagTitles.length - 2);- const tagPlaceholder =- tagTitles.length > 0 ? (- <IconButton- title={tagTitles}- onClick={() => openFile(fsEntry.path, fsEntry.isFile)}- >- <TagIcon />- </IconButton>- ) : null;+ let tagTitles = '';+ fsEntry.tags.map(tag => {+ tagTitles += tag.title + ', ';+ return true;+ });+ tagTitles = tagTitles.substring(0, tagTitles.length - 2);+ const tagPlaceholder =+ tagTitles.length > 0 ? (+ <IconButton+ title={tagTitles}+ onClick={() => openFile(fsEntry.path, fsEntry.isFile)}+ >+ <TagIcon />+ </IconButton>+ ) : null;- function renderGridCell() {- return (- <div- style={{- backgroundColor: fsEntryBackgroundColor- }}- >- <div- className={classes.gridCellThumb}- style={{- position: 'relative',- // zIndex: 1,- height: 150 // fsEntry.isFile ? 150 : 70- }}- >- {fsEntry.thumbPath && (- <img- alt="thumbnail"- className={classes.gridCellThumb}- src={fsEntry.thumbPath}- loading="lazy"- style={{- objectFit: thumbnailMode,- position: 'absolute',- width: '100%',- height: 150- }}- />- )}- <div id="gridCellTags" className={classes.gridCellTags}>- {showTags- ? fsEntry.tags.map(tag => renderTag(tag))- : tagPlaceholder}- </div>- {description.length > 0 && (- <Typography- id="gridCellDescription"- className={classes.gridCellDescription}- title={i18n.t('core:filePropertiesDescription')}- variant="caption"- >- {description}- </Typography>- )}- </div>- <Typography- className={classes.gridCellTitle}- data-tid="fsEntryName"- title={fsEntry.path}- noWrap={true}- variant="body1"- >- {extractTitle(fsEntry.name, !fsEntry.isFile)}- </Typography>- {fsEntry.isFile ? (- <div className={classes.gridDetails}>- <Typography- className={classes.gridFileExtension}- style={{ backgroundColor: fsEntryColor }}- noWrap={true}- variant="button"- title={fsEntry.path}- >- {fsEntry.extension}- </Typography>- <Typography className={classes.gridSizeDate} variant="caption">- <span- title={- i18n.t('core:modifiedDate') +- ': ' +- formatDateTime(fsEntry.lmdt, true)- }- >- {fsEntry.lmdt &&- ' ' +- formatDistance(fsEntry.lmdt, new Date(), {- addSuffix: true- })}- </span>- <span title={fsEntry.size + ' ' + i18n.t('core:sizeInBytes')}>- {' ' + formatFileSize(fsEntry.size)}- </span>- </Typography>- </div>- ) : (- <div className={classes.gridDetails}>- <FolderIcon- className={classes.gridFolder}- style={{ backgroundColor: fsEntryColor }}- title={fsEntry.path}- />- </div>- )}- </div>- );- }+ function renderGridCell() {+ return (+ <div+ style={{+ backgroundColor: fsEntryBackgroundColor+ }}+ >+ <div+ className={classes.gridCellThumb}+ style={{+ position: 'relative',+ // zIndex: 1,+ height: 150 // fsEntry.isFile ? 150 : 70+ }}+ >+ {fsEntry.thumbPath && (+ <img+ alt="thumbnail"+ className={classes.gridCellThumb}+ src={fsEntry.thumbPath}+ loading="lazy"+ style={{+ objectFit: thumbnailMode,+ position: 'absolute',+ width: '100%',+ height: 150+ }}+ />+ )}+ <div id="gridCellTags" className={classes.gridCellTags}>+ {showTags+ ? fsEntry.tags.map(tag => renderTag(tag))+ : tagPlaceholder}+ </div>+ {description.length > 0 && (+ <Typography+ id="gridCellDescription"+ className={classes.gridCellDescription}+ title={i18n.t('core:filePropertiesDescription')}+ variant="caption"+ >+ {description}+ </Typography>+ )}+ </div>+ <Typography+ className={classes.gridCellTitle}+ data-tid="fsEntryName"+ title={fsEntry.path}+ noWrap={true}+ variant="body1"+ >+ {extractTitle(fsEntry.name, !fsEntry.isFile)}+ </Typography>+ {fsEntry.isFile ? (+ <div className={classes.gridDetails}>+ <Typography+ className={classes.gridFileExtension}+ style={{ backgroundColor: fsEntryColor }}+ noWrap={true}+ variant="button"+ title={fsEntry.path}+ >+ {fsEntry.extension}+ </Typography>+ <Typography className={classes.gridSizeDate} variant="caption">+ <span+ title={+ i18n.t('core:modifiedDate') ++ ': ' ++ formatDateTime(fsEntry.lmdt, true)+ }+ >+ {fsEntry.lmdt &&+ ' ' ++ formatDistance(fsEntry.lmdt, new Date(), {+ addSuffix: true+ })}+ </span>+ <span title={fsEntry.size + ' ' + i18n.t('core:sizeInBytes')}>+ {' ' + formatFileSize(fsEntry.size)}+ </span>+ </Typography>+ </div>+ ) : (+ <div className={classes.gridDetails}>+ <FolderIcon+ className={classes.gridFolder}+ style={{ backgroundColor: fsEntryColor }}+ title={fsEntry.path}+ />+ </div>+ )}+ </div>+ );+ }- function renderRowCell() {- let tmbSize = 85;- if (entrySize === 'small') {- tmbSize = 50;- } else if (entrySize === 'normal') {- tmbSize = 85;- } else if (entrySize === 'big') {- tmbSize = 120;- }- return (- <Grid- container- wrap="nowrap"- style={{- backgroundColor: theme.palette.background.default- }}- >- <Grid- item- style={{- minHeight: entryHeight,- padding: 10,- marginRight: 5,- backgroundColor: fsEntryBackgroundColor- }}- >- {fsEntry.isFile ? (- <div- className={classes.rowFileExtension}- title={fsEntry.path}- style={{ backgroundColor: fsEntryColor }}- >- {fsEntry.extension}- </div>- ) : (- <span className={classes.gridFolder} title={fsEntry.path}>- <FolderIcon- className={classes.rowFolder}- style={{ backgroundColor: fsEntryColor }}- />- </span>- )}- </Grid>- <Grid item xs zeroMinWidth>- <Typography style={{ wordBreak: 'break-all' }}>- {extractTitle(fsEntry.name, !fsEntry.isFile)}- {entrySize === 'small' && tagPlaceholder}- </Typography>- {entrySize !== 'small'- ? showTags- ? fsEntry.tags.map(tag => renderTag(tag))- : tagPlaceholder- : null}- {entrySize !== 'small' && (- <Typography- style={{- color: 'gray',- padding: 5- }}- >- <span title={fsEntry.size + ' ' + i18n.t('core:sizeInBytes')}>- {fsEntry.isFile && formatFileSize(fsEntry.size) + ' - '}- </span>- <span- title={- i18n.t('core:modifiedDate') +- ': ' +- formatDateTime(fsEntry.lmdt, true)- }- >- {fsEntry.isFile &&- fsEntry.lmdt &&- '️ ' +- formatDistance(fsEntry.lmdt, new Date(), {- addSuffix: true- }) +- ' '}- </span>- <span title={i18n.t('core:entryDescription')}>- {description && description}- </span>- </Typography>- )}- </Grid>- {fsEntry.thumbPath && (- <Grid item>- <img- alt="thumbnail"- className={classes.gridCellThumb}- src={fsEntry.thumbPath}- loading="lazy"- style={{- objectFit: thumbnailMode,- height: tmbSize,- width: tmbSize- }}- />- </Grid>- )}- </Grid>- );- }+ function renderRowCell() {+ let tmbSize = 85;+ if (entrySize === 'small') {+ tmbSize = 50;+ } else if (entrySize === 'normal') {+ tmbSize = 85;+ } else if (entrySize === 'big') {+ tmbSize = 120;+ }+ return (+ <Grid+ container+ wrap="nowrap"+ style={{+ backgroundColor: theme.palette.background.default+ }}+ >+ <Grid+ item+ style={{+ minHeight: entryHeight,+ padding: 10,+ marginRight: 5,+ backgroundColor: fsEntryBackgroundColor+ }}+ >+ {fsEntry.isFile ? (+ <div+ className={classes.rowFileExtension}+ title={fsEntry.path}+ style={{ backgroundColor: fsEntryColor }}+ >+ {fsEntry.extension}+ </div>+ ) : (+ <span className={classes.gridFolder} title={fsEntry.path}>+ <FolderIcon+ className={classes.rowFolder}+ style={{ backgroundColor: fsEntryColor }}+ />+ </span>+ )}+ </Grid>+ <Grid item xs zeroMinWidth>+ <Typography style={{ wordBreak: 'break-all' }}>+ {extractTitle(fsEntry.name, !fsEntry.isFile)}+ {entrySize === 'small' && tagPlaceholder}+ </Typography>+ {entrySize !== 'small'+ ? showTags+ ? fsEntry.tags.map(tag => renderTag(tag))+ : tagPlaceholder+ : null}+ {entrySize !== 'small' && (+ <Typography+ style={{+ color: 'gray',+ padding: 5+ }}+ >+ <span title={fsEntry.size + ' ' + i18n.t('core:sizeInBytes')}>+ {fsEntry.isFile && formatFileSize(fsEntry.size) + ' - '}+ </span>+ <span+ title={+ i18n.t('core:modifiedDate') ++ ': ' ++ formatDateTime(fsEntry.lmdt, true)+ }+ >+ {fsEntry.isFile &&+ fsEntry.lmdt &&+ '️ ' ++ formatDistance(fsEntry.lmdt, new Date(), {+ addSuffix: true+ }) ++ ' '}+ </span>+ <span title={i18n.t('core:entryDescription')}>+ {description && description}+ </span>+ </Typography>+ )}+ </Grid>+ {fsEntry.thumbPath && (+ <Grid item>+ <img+ alt="thumbnail"+ className={classes.gridCellThumb}+ src={fsEntry.thumbPath}+ loading="lazy"+ style={{+ objectFit: thumbnailMode,+ height: tmbSize,+ width: tmbSize+ }}+ />+ </Grid>+ )}+ </Grid>+ );+ }- function renderTag(tag: Object) {- return isReadOnlyMode ? (- <TagContainer- tag={tag}- key={fsEntry.path + tag.title}- entryPath={fsEntry.path}- addTags={addTags}- handleTagMenu={handleTagMenu}- selectedEntries={selectedEntries}- />- ) : (- <TagContainerDnd- tag={tag}- key={fsEntry.path + tag.title}- entryPath={fsEntry.path}- addTags={addTags}- handleTagMenu={handleTagMenu}- selectedEntries={selectedEntries}- />- );- }+ function renderTag(tag: Object) {+ return isReadOnlyMode ? (+ <TagContainer+ tag={tag}+ key={fsEntry.path + tag.title}+ entryPath={fsEntry.path}+ addTags={addTags}+ handleTagMenu={handleTagMenu}+ selectedEntries={selectedEntries}+ />+ ) : (+ <TagContainerDnd+ tag={tag}+ key={fsEntry.path + tag.title}+ entryPath={fsEntry.path}+ addTags={addTags}+ handleTagMenu={handleTagMenu}+ selectedEntries={selectedEntries}+ />+ );+ }- let entryHeight = 130;- if (entrySize === 'small') {- entryHeight = 50;- } else if (entrySize === 'normal') {- entryHeight = 80;- } else if (entrySize === 'big') {- entryHeight = 130;- }+ let entryHeight = 130;+ if (entrySize === 'small') {+ entryHeight = 50;+ } else if (entrySize === 'normal') {+ entryHeight = 80;+ } else if (entrySize === 'big') {+ entryHeight = 130;+ }- let gridCell = React.Fragment;- if (layoutType === 'grid') {- gridCell = renderGridCell();- } else if (layoutType === 'row') {- gridCell = renderRowCell();- }+ let gridCell = React.Fragment;+ if (layoutType === 'grid') {+ gridCell = renderGridCell();+ } else if (layoutType === 'row') {+ gridCell = renderRowCell();+ }- return (- <Paper- elevation={2}- data-entry-id={fsEntry.uuid}- className={classNames(- layoutType === 'grid' && classes.gridCell,- layoutType === 'row' && classes.rowCell,- selected && layoutType === 'grid' && classes.selectedGridCell,- selected && layoutType === 'row' && classes.selectedRowCell- )}- style={{- minHeight: layoutType === 'row' ? entryHeight : 'auto',- backgroundColor: theme.palette.background.default- }}- onContextMenu={event => handleGridContextMenu(event, fsEntry)}- onDoubleClick={event => handleGridCellDblClick(event, fsEntry)}- onClick={event => handleGridCellClick(event, fsEntry)}- >- {gridCell}- </Paper>- );+ return (+ <Paper+ elevation={2}+ data-entry-id={fsEntry.uuid}+ className={classNames(+ layoutType === 'grid' && classes.gridCell,+ layoutType === 'row' && classes.rowCell,+ selected && layoutType === 'grid' && classes.selectedGridCell,+ selected && layoutType === 'row' && classes.selectedRowCell+ )}+ style={{+ minHeight: layoutType === 'row' ? entryHeight : 'auto',+ backgroundColor: theme.palette.background.default+ }}+ onContextMenu={event => handleGridContextMenu(event, fsEntry)}+ onDoubleClick={event => handleGridCellDblClick(event, fsEntry)}+ onClick={event => handleGridCellClick(event, fsEntry)}+ >+ {gridCell}+ </Paper>+ );};export default CellContent;diff --git a/app/perspectives/grid-perspective/components/GridOptionsMenu.tsx b/app/perspectives/grid-perspective/components/GridOptionsMenu.tsxindex 9c839b826..824e5b349 100644--- a/app/perspectives/grid-perspective/components/GridOptionsMenu.tsx+++ b/app/perspectives/grid-perspective/components/GridOptionsMenu.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/perspectives/grid-perspective/components/MainContainer.tsx b/app/perspectives/grid-perspective/components/MainContainer.tsxindex e10547318..49ef912e6 100644--- a/app/perspectives/grid-perspective/components/MainContainer.tsx+++ b/app/perspectives/grid-perspective/components/MainContainer.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';@@ -27,8 +26,8 @@ import { withStyles } from '@material-ui/core/styles';import Typography from '@material-ui/core/Typography';import FolderIcon from '@material-ui/icons/FolderOpen';import FolderHiddenIcon from '@material-ui/icons/Folder';-import { type FileSystemEntry } from '../../../services/utils-io';-import { type Tag } from '../../../reducers/taglibrary';+import { FileSystemEntry } from '../../../services/utils-io';+import { Tag } from '../../../reducers/taglibrary';import {getSupportedFileTypes,getDesktopMode,diff --git a/app/perspectives/grid-perspective/components/MainToolbar.tsx b/app/perspectives/grid-perspective/components/MainToolbar.tsxindex 0f872b6ec..2d8fad858 100644--- a/app/perspectives/grid-perspective/components/MainToolbar.tsx+++ b/app/perspectives/grid-perspective/components/MainToolbar.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/perspectives/grid-perspective/components/SortingMenu.tsx b/app/perspectives/grid-perspective/components/SortingMenu.tsxindex f70fb4932..3094ab9ae 100644--- a/app/perspectives/grid-perspective/components/SortingMenu.tsx+++ b/app/perspectives/grid-perspective/components/SortingMenu.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import React from 'react';diff --git a/app/perspectives/grid-perspective/components/styles.css.tsx b/app/perspectives/grid-perspective/components/styles.css.tsxindex b096109b1..f45cdf7de 100644--- a/app/perspectives/grid-perspective/components/styles.css.tsx+++ b/app/perspectives/grid-perspective/components/styles.css.tsx@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import AppConfig from '../../../config';diff --git a/app/pro/index.ts b/app/pro/index.tsindex 3377ec199..aa848adc4 100644--- a/app/pro/index.ts+++ b/app/pro/index.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/let tsPro;diff --git a/app/reducers/app.ts b/app/reducers/app.tsindex 5d292b5b1..03f266a08 100644--- a/app/reducers/app.ts+++ b/app/reducers/app.ts@@ -14,11 +14,10 @@* 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/>.*- * @flow*/import uuidv1 from 'uuid';-import { type Location, locationType } from './locations';+import { Location, locationType } from './locations';import PlatformIO from '../services/platform-io';import AppConfig from '../config';import {@@ -31,7 +30,6 @@ import {extractFileExtension,extractDirectoryName,extractFileName,- getMetaDirectoryPath,getMetaFileLocationForFile,getThumbFileLocationForFile,extractParentDirectoryPath,@@ -43,7 +41,7 @@ import i18n from '../services/i18n';import { Pro } from '../pro';import { getThumbnailURLPromise } from '../services/thumbsgenerator';import { actions as LocationIndexActions } from './location-index';-import { type Tag } from './taglibrary';+import { Tag } from './taglibrary';export const types = {DEVICE_ONLINE: 'APP/DEVICE_ONLINE',diff --git a/app/reducers/index.ts b/app/reducers/index.tsindex 88c7ffa26..e2b015f8f 100644--- a/app/reducers/index.ts+++ b/app/reducers/index.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import { persistCombineReducers } from 'redux-persist';import { routerReducer as router } from 'react-router-redux';diff --git a/app/reducers/io-actions.ts b/app/reducers/io-actions.tsindex 0709f2c7d..fdc2607d0 100644--- a/app/reducers/io-actions.ts+++ b/app/reducers/io-actions.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import { actions as AppActions } from './app';diff --git a/app/reducers/location-index.ts b/app/reducers/location-index.tsindex 8800d87e4..0a60eb392 100644--- a/app/reducers/location-index.ts+++ b/app/reducers/location-index.ts@@ -14,126 +14,125 @@* 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/>.*- * @flow*/-import { type Location, getLocation, locationType } from './locations';+import { Location, getLocation, locationType } from './locations';import { createDirectoryIndex } from '../services/utils-io';import { Pro } from '../pro';import {- extractFileExtension,- extractFileName,- extractTagsAsObjects- // getThumbFileLocationForFile+ extractFileExtension,+ extractFileName,+ extractTagsAsObjects+ // getThumbFileLocationForFile} from '../utils/paths';-import type { SearchQuery } from '../services/search';+import { SearchQuery } from '../services/search';import Search from '../services/search';import { actions as AppActions } from './app';import AppConfig from '../config';import i18n from '../services/i18n';// import PlatformIO from '../services/platform-io';-import { type Tag } from './taglibrary';+import { Tag } from './taglibrary';export const types = {- INDEX_DIRECTORY: 'INDEX_DIRECTORY',- INDEX_DIRECTORY_CLEAR: 'INDEX_DIRECTORY_CLEAR',- INDEX_DIRECTORY_START: 'INDEX_DIRECTORY_START',- INDEX_DIRECTORY_CANCEL: 'INDEX_DIRECTORY_CANCEL',- INDEX_DIRECTORY_SUCCESS: 'INDEX_DIRECTORY_SUCCESS',- INDEX_DIRECTORY_FAILURE: 'INDEX_DIRECTORY_FAILURE',- INDEX_DIRECTORY_SEARCH: 'INDEX_DIRECTORY_SEARCH',- REFLECT_DELETE_ENTRY: 'INDEX/REFLECT_DELETE_ENTRY',- REFLECT_CREATE_ENTRY: 'INDEX/REFLECT_CREATE_ENTRY',- REFLECT_RENAME_ENTRY: 'INDEX/REFLECT_RENAME_ENTRY',- REFLECT_UPDATE_SIDECARTAGS: 'INDEX/REFLECT_UPDATE_SIDECARTAGS',- REFLECT_UPDATE_SIDECARMETA: 'INDEX/REFLECT_UPDATE_SIDECARMETA'+ INDEX_DIRECTORY: 'INDEX_DIRECTORY',+ INDEX_DIRECTORY_CLEAR: 'INDEX_DIRECTORY_CLEAR',+ INDEX_DIRECTORY_START: 'INDEX_DIRECTORY_START',+ INDEX_DIRECTORY_CANCEL: 'INDEX_DIRECTORY_CANCEL',+ INDEX_DIRECTORY_SUCCESS: 'INDEX_DIRECTORY_SUCCESS',+ INDEX_DIRECTORY_FAILURE: 'INDEX_DIRECTORY_FAILURE',+ INDEX_DIRECTORY_SEARCH: 'INDEX_DIRECTORY_SEARCH',+ REFLECT_DELETE_ENTRY: 'INDEX/REFLECT_DELETE_ENTRY',+ REFLECT_CREATE_ENTRY: 'INDEX/REFLECT_CREATE_ENTRY',+ REFLECT_RENAME_ENTRY: 'INDEX/REFLECT_RENAME_ENTRY',+ REFLECT_UPDATE_SIDECARTAGS: 'INDEX/REFLECT_UPDATE_SIDECARTAGS',+ REFLECT_UPDATE_SIDECARMETA: 'INDEX/REFLECT_UPDATE_SIDECARMETA'};export const initialState = {- currentDirectoryIndex: [],- isIndexing: false+ currentDirectoryIndex: [],+ isIndexing: false};export default (state: Object = initialState, action: Object) => {- switch (action.type) {- case types.INDEX_DIRECTORY_START: {- return {- ...state,- currentDirectoryIndex: [],- isIndexing: true- };- }- case types.INDEX_DIRECTORY_CLEAR: {- return {- ...state,- currentDirectoryIndex: [],- isIndexing: false- };- }- case types.INDEX_DIRECTORY_CANCEL: {- window.walkCanceled = true;- return { ...state, isIndexing: false };- }- case types.INDEX_DIRECTORY_SUCCESS: {- return {- ...state,- currentDirectoryIndex: action.directoryIndex,- isIndexing: false- };- }- case types.INDEX_DIRECTORY_FAILURE: {- return {- ...state,- lastError: action.error,- currentDirectoryIndex: [],- isIndexing: false- };- }- case types.REFLECT_DELETE_ENTRY: {- const newDirectoryIndex = state.currentDirectoryIndex.filter(- entry => !entry.path.startsWith(action.path)- );- if (state.currentDirectoryIndex.length > newDirectoryIndex.length) {- return {- ...state,- currentDirectoryIndex: newDirectoryIndex- };- }- return state;- }- case types.REFLECT_CREATE_ENTRY: {- const entryIndex = state.currentDirectoryIndex.findIndex(- entry => entry.path === action.newEntry.path- );- if (entryIndex) {- return state;- }- return {- ...state,- currentDirectoryIndex: [action.newEntry, ...state.currentDirectoryIndex]- };- }- case types.REFLECT_RENAME_ENTRY: {- return {- ...state,- currentDirectoryIndex: state.currentDirectoryIndex.map(entry => {- if (entry.path !== action.path) {- return entry;- }- return {- ...entry,- path: action.newPath,- // thumbPath: getThumbFileLocationForFile(action.newPath), // disabled due performance concerns- name: extractFileName(action.newPath),- extension: extractFileExtension(action.newPath),- tags: [- ...entry.tags.filter(tag => tag.type === 'sidecar'), // add only sidecar tags- ...extractTagsAsObjects(action.newPath) // , getTagDelimiter(state))- ]- };- })- };- /* const indexForRenamingInIndex = state.currentDirectoryIndex.findIndex((entry) => entry.path === action.path);+ switch (action.type) {+ case types.INDEX_DIRECTORY_START: {+ return {+ ...state,+ currentDirectoryIndex: [],+ isIndexing: true+ };+ }+ case types.INDEX_DIRECTORY_CLEAR: {+ return {+ ...state,+ currentDirectoryIndex: [],+ isIndexing: false+ };+ }+ case types.INDEX_DIRECTORY_CANCEL: {+ window.walkCanceled = true;+ return { ...state, isIndexing: false };+ }+ case types.INDEX_DIRECTORY_SUCCESS: {+ return {+ ...state,+ currentDirectoryIndex: action.directoryIndex,+ isIndexing: false+ };+ }+ case types.INDEX_DIRECTORY_FAILURE: {+ return {+ ...state,+ lastError: action.error,+ currentDirectoryIndex: [],+ isIndexing: false+ };+ }+ case types.REFLECT_DELETE_ENTRY: {+ const newDirectoryIndex = state.currentDirectoryIndex.filter(+ entry => !entry.path.startsWith(action.path)+ );+ if (state.currentDirectoryIndex.length > newDirectoryIndex.length) {+ return {+ ...state,+ currentDirectoryIndex: newDirectoryIndex+ };+ }+ return state;+ }+ case types.REFLECT_CREATE_ENTRY: {+ const entryIndex = state.currentDirectoryIndex.findIndex(+ entry => entry.path === action.newEntry.path+ );+ if (entryIndex) {+ return state;+ }+ return {+ ...state,+ currentDirectoryIndex: [action.newEntry, ...state.currentDirectoryIndex]+ };+ }+ case types.REFLECT_RENAME_ENTRY: {+ return {+ ...state,+ currentDirectoryIndex: state.currentDirectoryIndex.map(entry => {+ if (entry.path !== action.path) {+ return entry;+ }+ return {+ ...entry,+ path: action.newPath,+ // thumbPath: getThumbFileLocationForFile(action.newPath), // disabled due performance concerns+ name: extractFileName(action.newPath),+ extension: extractFileExtension(action.newPath),+ tags: [+ ...entry.tags.filter(tag => tag.type === 'sidecar'), // add only sidecar tags+ ...extractTagsAsObjects(action.newPath) // , getTagDelimiter(state))+ ]+ };+ })+ };+ /* const indexForRenamingInIndex = state.currentDirectoryIndex.findIndex((entry) => entry.path === action.path);if (indexForRenamingInIndex >= 0) {const updateEntry = {...state.currentDirectoryIndex[indexForRenamingInIndex],@@ -156,24 +155,24 @@ export default (state: Object = initialState, action: Object) => {};}return state; */- }- case types.REFLECT_UPDATE_SIDECARTAGS: {- return {- ...state,- currentDirectoryIndex: state.currentDirectoryIndex.map(entry => {- if (entry.path !== action.path) {- return entry;- }- return {- ...entry,- tags: [- ...entry.tags.filter(tag => tag.type === 'plain'),- ...action.tags- ]- };- })- };- /* const indexForUpdatingInIndex = state.currentDirectoryIndex.findIndex((entry) => entry.path === action.path);+ }+ case types.REFLECT_UPDATE_SIDECARTAGS: {+ return {+ ...state,+ currentDirectoryIndex: state.currentDirectoryIndex.map(entry => {+ if (entry.path !== action.path) {+ return entry;+ }+ return {+ ...entry,+ tags: [+ ...entry.tags.filter(tag => tag.type === 'plain'),+ ...action.tags+ ]+ };+ })+ };+ /* const indexForUpdatingInIndex = state.currentDirectoryIndex.findIndex((entry) => entry.path === action.path);if (indexForUpdatingInIndex >= 0) {const updateEntry = {...state.currentDirectoryIndex[indexForUpdatingInIndex],@@ -192,21 +191,21 @@ export default (state: Object = initialState, action: Object) => {};}return state; */- }- case types.REFLECT_UPDATE_SIDECARMETA: {- return {- ...state,- currentDirectoryIndex: state.currentDirectoryIndex.map(entry => {- if (entry.path !== action.path) {- return entry;- }- return {- ...entry,- ...action.entryMeta- };- })- };- /* const indexForUpdatingInIndex = state.currentDirectoryIndex.findIndex((entry) => entry.path === action.path);+ }+ case types.REFLECT_UPDATE_SIDECARMETA: {+ return {+ ...state,+ currentDirectoryIndex: state.currentDirectoryIndex.map(entry => {+ if (entry.path !== action.path) {+ return entry;+ }+ return {+ ...entry,+ ...action.entryMeta+ };+ })+ };+ /* const indexForUpdatingInIndex = state.currentDirectoryIndex.findIndex((entry) => entry.path === action.path);if (indexForUpdatingInIndex >= 0) {const updateEntry = {...state.currentDirectoryIndex[indexForUpdatingInIndex],@@ -222,150 +221,150 @@ export default (state: Object = initialState, action: Object) => {};}return state; */- }- default: {- return state;- }- }+ }+ default: {+ return state;+ }+ }};export const actions = {- startDirectoryIndexing: () => ({ type: types.INDEX_DIRECTORY_START }),- cancelDirectoryIndexing: () => ({ type: types.INDEX_DIRECTORY_CANCEL }),- createDirectoryIndex: (directoryPath: string, extractText: boolean) => (- dispatch: (actions: Object) => void,- getState: () => Object- ) => {- const state = getState();- const currentLocation: Location = getLocation(- state,- state.app.currentLocationId- );- dispatch(actions.startDirectoryIndexing());- createDirectoryIndex(directoryPath, extractText)- .then(directoryIndex => {- dispatch(actions.indexDirectorySuccess(directoryIndex));- if (Pro && Pro.Indexer) {- // && (currentLocation.persistIndex || PlatformIO.haveObjectStoreSupport())) { // always persist on s3 stores- Pro.Indexer.persistIndex(- directoryPath,- directoryIndex,- currentLocation.type === locationType.TYPE_CLOUD- ? '/'- : AppConfig.dirSeparator- );- }- return true;- })- .catch(err => {- dispatch(actions.indexDirectoryFailure(err));- // dispatch(actions.startDirectoryIndexing());- });- },- loadDirectoryIndex: (directoryPath: string) => (- dispatch: (actions: Object) => void,- getState: () => Object- ) => {- const state = getState();- const currentLocation: Location = getLocation(- state,- state.app.currentLocationId- );- dispatch(actions.startDirectoryIndexing());- dispatch(- AppActions.showNotification(i18n.t('core:loadingIndex'), 'default', true)- );- if (Pro && Pro.Indexer.loadIndex) {- Pro.Indexer.loadIndex(- directoryPath,- currentLocation.type === locationType.TYPE_CLOUD- ? '/'- : AppConfig.dirSeparator- )- .then(directoryIndex => {- dispatch(actions.indexDirectorySuccess(directoryIndex));- return true;- })- .catch(err => {- dispatch(actions.indexDirectoryFailure(err));- dispatch(- AppActions.showNotification(- i18n.t('core:loadingIndexFailed'),- 'warning',- true- )- );- });- }- },- clearDirectoryIndex: () => ({- type: types.INDEX_DIRECTORY_CLEAR- }),- searchLocationIndex: (searchQuery: SearchQuery) => (- dispatch: (actions: Object) => void,- getState: () => Object- ) => {- dispatch(- AppActions.showNotification(i18n.t('core:searching'), 'default', false)- );- setTimeout(() => {- // Workaround used to show the start search notification- Search.searchLocationIndex(- getState().locationIndex.currentDirectoryIndex,- searchQuery- )- .then(searchResults => {- dispatch(AppActions.updateSearchResults(searchResults));- dispatch(AppActions.hideNotifications());- return true;- })- .catch(() => {- dispatch(AppActions.updateSearchResults([]));- dispatch(AppActions.hideNotifications());- dispatch(- AppActions.showNotification(- i18n.t('core:searchingFailed'),- 'warning',- true- )- );- });- }, 50);- },- indexDirectorySuccess: (directoryIndex: Array<Object>) => ({- type: types.INDEX_DIRECTORY_SUCCESS,- directoryIndex- }),- indexDirectoryFailure: (error: string) => ({- type: types.INDEX_DIRECTORY_FAILURE,- error- }),- reflectDeleteEntry: (path: string) => ({- type: types.REFLECT_DELETE_ENTRY,- path- }),- reflectCreateEntry: (newEntry: Object) => ({- type: types.REFLECT_CREATE_ENTRY,- newEntry- }),- reflectRenameEntry: (path: string, newPath: string) => ({- type: types.REFLECT_RENAME_ENTRY,- path,- newPath- }),- reflectUpdateSidecarTags: (path: string, tags: Array<Tag>) => ({- type: types.REFLECT_UPDATE_SIDECARTAGS,- path,- tags- }),- reflectUpdateSidecarMeta: (path: string, entryMeta: Object) => ({- type: types.REFLECT_UPDATE_SIDECARMETA,- path,- entryMeta- })+ startDirectoryIndexing: () => ({ type: types.INDEX_DIRECTORY_START }),+ cancelDirectoryIndexing: () => ({ type: types.INDEX_DIRECTORY_CANCEL }),+ createDirectoryIndex: (directoryPath: string, extractText: boolean) => (+ dispatch: (actions: Object) => void,+ getState: () => Object+ ) => {+ const state = getState();+ const currentLocation: Location = getLocation(+ state,+ state.app.currentLocationId+ );+ dispatch(actions.startDirectoryIndexing());+ createDirectoryIndex(directoryPath, extractText)+ .then(directoryIndex => {+ dispatch(actions.indexDirectorySuccess(directoryIndex));+ if (Pro && Pro.Indexer) {+ // && (currentLocation.persistIndex || PlatformIO.haveObjectStoreSupport())) { // always persist on s3 stores+ Pro.Indexer.persistIndex(+ directoryPath,+ directoryIndex,+ currentLocation.type === locationType.TYPE_CLOUD+ ? '/'+ : AppConfig.dirSeparator+ );+ }+ return true;+ })+ .catch(err => {+ dispatch(actions.indexDirectoryFailure(err));+ // dispatch(actions.startDirectoryIndexing());+ });+ },+ loadDirectoryIndex: (directoryPath: string) => (+ dispatch: (actions: Object) => void,+ getState: () => Object+ ) => {+ const state = getState();+ const currentLocation: Location = getLocation(+ state,+ state.app.currentLocationId+ );+ dispatch(actions.startDirectoryIndexing());+ dispatch(+ AppActions.showNotification(i18n.t('core:loadingIndex'), 'default', true)+ );+ if (Pro && Pro.Indexer.loadIndex) {+ Pro.Indexer.loadIndex(+ directoryPath,+ currentLocation.type === locationType.TYPE_CLOUD+ ? '/'+ : AppConfig.dirSeparator+ )+ .then(directoryIndex => {+ dispatch(actions.indexDirectorySuccess(directoryIndex));+ return true;+ })+ .catch(err => {+ dispatch(actions.indexDirectoryFailure(err));+ dispatch(+ AppActions.showNotification(+ i18n.t('core:loadingIndexFailed'),+ 'warning',+ true+ )+ );+ });+ }+ },+ clearDirectoryIndex: () => ({+ type: types.INDEX_DIRECTORY_CLEAR+ }),+ searchLocationIndex: (searchQuery: SearchQuery) => (+ dispatch: (actions: Object) => void,+ getState: () => Object+ ) => {+ dispatch(+ AppActions.showNotification(i18n.t('core:searching'), 'default', false)+ );+ setTimeout(() => {+ // Workaround used to show the start search notification+ Search.searchLocationIndex(+ getState().locationIndex.currentDirectoryIndex,+ searchQuery+ )+ .then(searchResults => {+ dispatch(AppActions.updateSearchResults(searchResults));+ dispatch(AppActions.hideNotifications());+ return true;+ })+ .catch(() => {+ dispatch(AppActions.updateSearchResults([]));+ dispatch(AppActions.hideNotifications());+ dispatch(+ AppActions.showNotification(+ i18n.t('core:searchingFailed'),+ 'warning',+ true+ )+ );+ });+ }, 50);+ },+ indexDirectorySuccess: (directoryIndex: Array<Object>) => ({+ type: types.INDEX_DIRECTORY_SUCCESS,+ directoryIndex+ }),+ indexDirectoryFailure: (error: string) => ({+ type: types.INDEX_DIRECTORY_FAILURE,+ error+ }),+ reflectDeleteEntry: (path: string) => ({+ type: types.REFLECT_DELETE_ENTRY,+ path+ }),+ reflectCreateEntry: (newEntry: Object) => ({+ type: types.REFLECT_CREATE_ENTRY,+ newEntry+ }),+ reflectRenameEntry: (path: string, newPath: string) => ({+ type: types.REFLECT_RENAME_ENTRY,+ path,+ newPath+ }),+ reflectUpdateSidecarTags: (path: string, tags: Array<Tag>) => ({+ type: types.REFLECT_UPDATE_SIDECARTAGS,+ path,+ tags+ }),+ reflectUpdateSidecarMeta: (path: string, entryMeta: Object) => ({+ type: types.REFLECT_UPDATE_SIDECARMETA,+ path,+ entryMeta+ })};// Selectorsexport const getIndexedEntriesCount = (state: Object) =>- state.locationIndex.currentDirectoryIndex.length;+ state.locationIndex.currentDirectoryIndex.length;export const isIndexing = (state: Object) => state.locationIndex.isIndexing;diff --git a/app/reducers/locations.ts b/app/reducers/locations.tsindex 5997c39d5..8286fec61 100644--- a/app/reducers/locations.ts+++ b/app/reducers/locations.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import uuidv1 from 'uuid';diff --git a/app/reducers/settings-default.ts b/app/reducers/settings-default.tsindex d4f49e646..fc94245d3 100644--- a/app/reducers/settings-default.ts+++ b/app/reducers/settings-default.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import AppConfig from '../config';diff --git a/app/reducers/settings.ts b/app/reducers/settings.tsindex cdbb49fa7..97662bd5b 100644--- a/app/reducers/settings.ts+++ b/app/reducers/settings.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import semver from 'semver';diff --git a/app/reducers/tagging-actions.ts b/app/reducers/tagging-actions.tsindex 1c96829d0..5ace8bf9f 100644--- a/app/reducers/tagging-actions.ts+++ b/app/reducers/tagging-actions.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import uuidv1 from 'uuid';@@ -22,8 +21,8 @@ import i18n from '../services/i18n';import { actions as AppActions } from './app';import {actions as TagLibraryActions,- type Tag,- type TagGroup+ Tag,+ TagGroup} from './taglibrary';import {extractFileExtension,diff --git a/app/reducers/taglibrary-default.ts b/app/reducers/taglibrary-default.tsindex 0e90e73d0..52e65d3c3 100644--- a/app/reducers/taglibrary-default.ts+++ b/app/reducers/taglibrary-default.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/// import AppConfig from '../config';diff --git a/app/reducers/taglibrary.ts b/app/reducers/taglibrary.tsindex 016cf5f39..24cbf4e2b 100644--- a/app/reducers/taglibrary.ts+++ b/app/reducers/taglibrary.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import uuidv1 from 'uuid';@@ -25,555 +24,555 @@ import defaultTagLibrary from './taglibrary-default';import AppConfig from '../config';export const types = {- CREATE_TAGGROUP: 'CREATE_TAGGROUP',- IMPORT_TAGGROUP: 'IMPORT_TAGGROUP',- IMPORT_OLD_TAGGROUP: 'IMPORT_OLD_TAGGROUP',- ADD_TAGGROUP: 'ADD_TAGGROUP',- MERGE_TAGGROUP: 'MERGE_TAGGROUP',- REMOVE_TAGGROUP: 'REMOVE_TAGGROUP',- UPDATE_TAGGROUP: 'UPDATE_TAGGROUP',- TOGGLE_TAGGROUP: 'TOGGLE_TAGGROUP',- ADD_TAG: 'ADD_TAG',- REMOVE_TAG: 'REMOVE_TAG',- UPDATE_TAG: 'UPDATE_TAG',- SORT_TAG_GROUP_UP: 'SORT_TAG_GROUP_UP',- MOVE_TAG_GROUP_UP: 'MOVE_TAG_GROUP_UP',- MOVE_TAG_GROUP_DOWN: 'MOVE_TAG_GROUP_DOWN',- EDIT_TAG_COLOR: 'EDIT_TAG_COLOR',- MOVE_TAG: 'MOVE_TAG'+ CREATE_TAGGROUP: 'CREATE_TAGGROUP',+ IMPORT_TAGGROUP: 'IMPORT_TAGGROUP',+ IMPORT_OLD_TAGGROUP: 'IMPORT_OLD_TAGGROUP',+ ADD_TAGGROUP: 'ADD_TAGGROUP',+ MERGE_TAGGROUP: 'MERGE_TAGGROUP',+ REMOVE_TAGGROUP: 'REMOVE_TAGGROUP',+ UPDATE_TAGGROUP: 'UPDATE_TAGGROUP',+ TOGGLE_TAGGROUP: 'TOGGLE_TAGGROUP',+ ADD_TAG: 'ADD_TAG',+ REMOVE_TAG: 'REMOVE_TAG',+ UPDATE_TAG: 'UPDATE_TAG',+ SORT_TAG_GROUP_UP: 'SORT_TAG_GROUP_UP',+ MOVE_TAG_GROUP_UP: 'MOVE_TAG_GROUP_UP',+ MOVE_TAG_GROUP_DOWN: 'MOVE_TAG_GROUP_DOWN',+ EDIT_TAG_COLOR: 'EDIT_TAG_COLOR',+ MOVE_TAG: 'MOVE_TAG'};export type Uuid = string;-export type Tag = {- title: string,- type: 'plain' | 'sidecar' | 'smart', // smart should be eventually removed from this list, functionality should be enough- id?: Uuid,- icon?: string,- description?: string,- style?: string,- path?: string, // needed for geo tagging should be removed- functionality?: string,- keyBinding?: string,- color?: string,- textcolor?: string-};+export interface Tag {+ title: string;+ type: 'plain' | 'sidecar' | 'smart'; // smart should be eventually removed from this list, functionality should be enough+ id?: Uuid;+ icon?: string;+ description?: string;+ style?: string;+ path?: string; // needed for geo tagging should be removed+ functionality?: string;+ keyBinding?: string;+ color?: string;+ textcolor?: string;+}-export type TagGroup = {- uuid: Uuid,- title: string,- expanded: boolean,- description?: string,- categoryId?: string,- readOnly?: boolean,- color?: string,- textcolor?: string,- children?: Array<Tag>-};+export interface TagGroup {+ uuid: Uuid;+ title: string;+ expanded: boolean;+ description?: string;+ categoryId?: string;+ readOnly?: boolean;+ color?: string;+ textcolor?: string;+ children?: Array<Tag>;+}export default (state: Array<TagGroup> = defaultTagLibrary, action: Object) => {- switch (action.type) {- case types.CREATE_TAGGROUP: {- return [- ...state,- {- uuid: uuidv1(),- title: action.entry.title,- expanded: action.entry.expanded,- color: action.entry.color,- textcolor: action.entry.textcolor,- children: [],- created_date: new Date(),- modified_date: new Date()- }- ];- }- case types.ADD_TAGGROUP: {- let indexForEditing = -1;- state.forEach((tagGroup, index) => {- if (tagGroup.uuid === action.entry.uuid) {- indexForEditing = index;- }- });- if (indexForEditing >= 0) {- return [- ...state.slice(0, indexForEditing),- {- uuid: action.entry.uuid,- title: action.entry.title,- expanded: action.entry.expanded,- children: [- ...state[indexForEditing].children,- action.entry.children[0]- ],- created_date: new Date(),- modified_date: new Date()- },- ...state.slice(indexForEditing + 1)- ];- }- return state;- }- case types.MERGE_TAGGROUP: {- const indexForEditing = state.findIndex(- obj => obj.uuid === action.entry.uuid- );- if (indexForEditing >= 0) {- const tags = [- ...state[indexForEditing].children,- ...action.entry.children- ];- tags.splice(0, tags.length - AppConfig.maxCollectedTag);- return [- ...state.slice(0, indexForEditing),- {- uuid: action.entry.uuid,- title: action.entry.title,- expanded: action.entry.expanded,- children: tags,- created_date: action.entry.created_date,- modified_date: new Date()- },- ...state.slice(indexForEditing + 1)- ];- }- return [- ...state,- {- uuid: action.entry.uuid || uuidv1(),- title: action.entry.title,- expanded: action.entry.expanded,- color: action.entry.color,- textcolor: action.entry.textcolor,- children: action.entry.children,- created_date: new Date(),- modified_date: new Date()- }- ];- }- case types.UPDATE_TAGGROUP: {- let indexForEditing = -1;- state.forEach((tagGroup, index) => {- if (tagGroup.uuid === action.entry.uuid) {- indexForEditing = index;- }- });+ switch (action.type) {+ case types.CREATE_TAGGROUP: {+ return [+ ...state,+ {+ uuid: uuidv1(),+ title: action.entry.title,+ expanded: action.entry.expanded,+ color: action.entry.color,+ textcolor: action.entry.textcolor,+ children: [],+ created_date: new Date(),+ modified_date: new Date()+ }+ ];+ }+ case types.ADD_TAGGROUP: {+ let indexForEditing = -1;+ state.forEach((tagGroup, index) => {+ if (tagGroup.uuid === action.entry.uuid) {+ indexForEditing = index;+ }+ });+ if (indexForEditing >= 0) {+ return [+ ...state.slice(0, indexForEditing),+ {+ uuid: action.entry.uuid,+ title: action.entry.title,+ expanded: action.entry.expanded,+ children: [+ ...state[indexForEditing].children,+ action.entry.children[0]+ ],+ created_date: new Date(),+ modified_date: new Date()+ },+ ...state.slice(indexForEditing + 1)+ ];+ }+ return state;+ }+ case types.MERGE_TAGGROUP: {+ const indexForEditing = state.findIndex(+ obj => obj.uuid === action.entry.uuid+ );+ if (indexForEditing >= 0) {+ const tags = [+ ...state[indexForEditing].children,+ ...action.entry.children+ ];+ tags.splice(0, tags.length - AppConfig.maxCollectedTag);+ return [+ ...state.slice(0, indexForEditing),+ {+ uuid: action.entry.uuid,+ title: action.entry.title,+ expanded: action.entry.expanded,+ children: tags,+ created_date: action.entry.created_date,+ modified_date: new Date()+ },+ ...state.slice(indexForEditing + 1)+ ];+ }+ return [+ ...state,+ {+ uuid: action.entry.uuid || uuidv1(),+ title: action.entry.title,+ expanded: action.entry.expanded,+ color: action.entry.color,+ textcolor: action.entry.textcolor,+ children: action.entry.children,+ created_date: new Date(),+ modified_date: new Date()+ }+ ];+ }+ case types.UPDATE_TAGGROUP: {+ let indexForEditing = -1;+ state.forEach((tagGroup, index) => {+ if (tagGroup.uuid === action.entry.uuid) {+ indexForEditing = index;+ }+ });- if (indexForEditing >= 0) {- const modifiedEntry = extend(- { created_date: new Date() },- action.entry,- { modified_date: new Date() }- );- return [- ...state.slice(0, indexForEditing),- modifiedEntry,- ...state.slice(indexForEditing + 1)- ];- }- return state;- }- case types.REMOVE_TAGGROUP: {- let indexForRemoving = -1;- state.forEach((tagGroup, index) => {- if (tagGroup.uuid === action.uuid) {- indexForRemoving = index;- }- });- if (indexForRemoving >= 0) {- return [- ...state.slice(0, indexForRemoving),- ...state.slice(indexForRemoving + 1)- ];- }- return state;- }- case types.ADD_TAG: {- let indexForEditing = -1;- state.forEach((tagGroup, index) => {- if (tagGroup.uuid === action.uuid) {- indexForEditing = index;- }- });+ if (indexForEditing >= 0) {+ const modifiedEntry = extend(+ { created_date: new Date() },+ action.entry,+ { modified_date: new Date() }+ );+ return [+ ...state.slice(0, indexForEditing),+ modifiedEntry,+ ...state.slice(indexForEditing + 1)+ ];+ }+ return state;+ }+ case types.REMOVE_TAGGROUP: {+ let indexForRemoving = -1;+ state.forEach((tagGroup, index) => {+ if (tagGroup.uuid === action.uuid) {+ indexForRemoving = index;+ }+ });+ if (indexForRemoving >= 0) {+ return [+ ...state.slice(0, indexForRemoving),+ ...state.slice(indexForRemoving + 1)+ ];+ }+ return state;+ }+ case types.ADD_TAG: {+ let indexForEditing = -1;+ state.forEach((tagGroup, index) => {+ if (tagGroup.uuid === action.uuid) {+ indexForEditing = index;+ }+ });- if (indexForEditing >= 0) {- let tags = action.tag- .split(' ')- .join(',')- .split(','); // handle spaces around commas- tags = [...new Set(tags)]; // remove duplicates- tags = tags.filter(tag => tag.length > 0); // zero length tags+ if (indexForEditing >= 0) {+ let tags = action.tag+ .split(' ')+ .join(',')+ .split(','); // handle spaces around commas+ tags = [...new Set(tags)]; // remove duplicates+ tags = tags.filter(tag => tag.length > 0); // zero length tags- const taggroupTags = state[indexForEditing].children;- taggroupTags.forEach(tag => {- // filter out duplicated tags- tags = tags.filter(e => e !== tag.title);- });- return [- ...state.slice(0, indexForEditing),- {- ...state[indexForEditing],- children: taggroupTags.concat(- tags.map(tagTitle => ({- id: uuidv1(),- type:- taggroupTags.length > 0 ? taggroupTags[0].type : 'sidecar',- title: tagTitle.trim(),- functionality: '',- description: '',- icon: '',- color: state[indexForEditing].color- ? state[indexForEditing].color- : '', // default color- textcolor: state[indexForEditing].textcolor- ? state[indexForEditing].textcolor- : '', // default color- style: taggroupTags.length > 0 ? taggroupTags[0].style : '',- created_date: new Date(),- modified_date: new Date()- }))- )- },- ...state.slice(indexForEditing + 1)- ];- }- return state;- }- case types.UPDATE_TAG: {- let tagIndexForUpdating = -1;- let indexForUpdating = -1;- state.forEach((tagGroup, index) => {- if (tagGroup.uuid === action.uuid) {- indexForUpdating = index;- }- tagGroup.children.forEach((tag, tagIndex) => {- if (tag.id === action.entry.id) {- tagIndexForUpdating = tagIndex;- }- });- });- if (tagIndexForUpdating >= 0) {- const modifiedEntry = extend(- { created_date: new Date() },- action.entry,- { modified_date: new Date() }- );- return [- ...state.slice(0, indexForUpdating),- {- ...state[indexForUpdating],- children: [- ...state[indexForUpdating].children.slice(0, tagIndexForUpdating),- modifiedEntry,- ...state[indexForUpdating].children.slice(tagIndexForUpdating + 1)- ]- },- ...state.slice(indexForUpdating + 1)- ];- }- return state;- }- case types.REMOVE_TAG: {- let tagIndexForRemoving = -1;- let indexForEditing = -1;- state.forEach((tagGroup, index) => {- if (tagGroup.uuid === action.uuid) {- indexForEditing = index;- }- tagGroup.children.forEach((tag, tagIndex) => {- if (tag.id === action.tagID) {- tagIndexForRemoving = tagIndex;- }- });- });- if (tagIndexForRemoving >= 0) {- return [- ...state.slice(0, indexForEditing),- {- ...state[indexForEditing],- children: [- ...state[indexForEditing].children.slice(0, tagIndexForRemoving),- ...state[indexForEditing].children.slice(tagIndexForRemoving + 1)- ]- },- ...state.slice(indexForEditing + 1)- ];- }- return state;- }- case types.TOGGLE_TAGGROUP: {- let indexForUpdating = -1;- state.forEach((tagGroup, index) => {- if (tagGroup.uuid === action.uuid) {- indexForUpdating = index;- }- });- if (indexForUpdating >= 0) {- return [- ...state.slice(0, indexForUpdating),- {- ...state[indexForUpdating],- expanded: !action.expanded- },- ...state.slice(indexForUpdating + 1)- ];- }- return state;- }- case types.MOVE_TAG_GROUP_DOWN: {- let indexForUpdating = -1;- state.forEach((tagGroup, index) => {- if (tagGroup.uuid === action.uuid) {- indexForUpdating = index;- }- });- if (indexForUpdating >= 0 && indexForUpdating < state.length - 1) {- const secondIndex = indexForUpdating + 1;- return immutablySwapItems(state, indexForUpdating, secondIndex);- }- return state;- }- case types.MOVE_TAG_GROUP_UP: {- let indexForUpdating = -1;- state.forEach((tagGroup, index) => {- if (tagGroup.uuid === action.uuid) {- indexForUpdating = index;- }- });- if (indexForUpdating > 0) {- const secondIndex = indexForUpdating - 1;- return immutablySwapItems(state, indexForUpdating, secondIndex);- }- return state;- }- case types.SORT_TAG_GROUP_UP: {- let indexForUpdating = -1;- state.forEach((tagGroup, index) => {- if (tagGroup.uuid === action.uuid) {- indexForUpdating = index;- }- });- if (indexForUpdating >= 0) {- return [- ...state.slice(0, indexForUpdating),- {- ...state[indexForUpdating],- children: state[indexForUpdating].children.sort((a, b) =>- a.title > b.title ? 1 : a.title < b.title ? -1 : 0- )- },- ...state.slice(indexForUpdating + 1)- ];- }- return state;- }- case types.MOVE_TAG: {- let tagIndexForRemoving = -1;- let indexFromGroup = -1;- let indexToGroup = -1;- state.forEach((tagGroup, index) => {- if (tagGroup.uuid === action.fromTagGroupId) {- indexFromGroup = index;- }- if (tagGroup.uuid === action.toTagGroupId) {- indexToGroup = index;- }- });- if (indexFromGroup >= 0 && state[indexFromGroup].children) {- state[indexFromGroup].children.forEach((tag, tagIndex) => {- if (tag.id === action.tagID) {- tagIndexForRemoving = tagIndex;- }- return true;- });- }- if (indexToGroup >= 0 && indexToGroup >= 0 && tagIndexForRemoving >= 0) {- const newTagLibrary = [...state];- const tag = { ...state[indexFromGroup].children[tagIndexForRemoving] };- const found = newTagLibrary[indexToGroup].children.find(- t => t.title === tag.title- );- if (!found) {- newTagLibrary[indexToGroup].children.push(tag);- newTagLibrary[indexFromGroup].children = [- ...newTagLibrary[indexFromGroup].children.slice(- 0,- tagIndexForRemoving- ),- ...newTagLibrary[indexFromGroup].children.slice(- tagIndexForRemoving + 1- )- ];- return newTagLibrary;- }- console.warn(- 'Tag with this title alread exists in the target tag group'- );- }- return state;- }- case types.IMPORT_TAGGROUP: {- const arr = [...state];- console.log(arr);- if (action.entry[0].key) {- action.entry.forEach((tagGroup, index) => {- // migration of old tag groups 2.9 or less in the new version 3.0-present- if (tagGroup.key === state.uuid || tagGroup.key !== state.uuid) {- tagGroup = {- title: tagGroup.title,- uuid: tagGroup.key,- expanded: true,- children: tagGroup.children- };- const tagsArr = [];- tagGroup.children.forEach(tag => {- if (!tag.id) {- tag = {- id: uuidv1(),- type: tag.type,- title: tag.title,- functionality: tag.title,- color: tag.color,- textcolor: tag.textcolor,- description: tag.description,- icon: tag.icon,- style: tag.style- };- tagsArr.push(tag);- }- tagGroup.children = tagsArr;- arr.push(tagGroup);- });- }- });- } else {- action.entry.forEach(tagGroup => {- const index = state.findIndex(obj => obj.uuid === tagGroup.uuid);- if (index > -1) {- tagGroup.children.forEach(tag => {- const stateTag = state[index].children.find(- obj => obj.id === tag.id- );- if (stateTag === undefined) {- arr[index].children.push(tag);- }- });- } else {- arr.push(tagGroup);- }- });- }+ const taggroupTags = state[indexForEditing].children;+ taggroupTags.forEach(tag => {+ // filter out duplicated tags+ tags = tags.filter(e => e !== tag.title);+ });+ return [+ ...state.slice(0, indexForEditing),+ {+ ...state[indexForEditing],+ children: taggroupTags.concat(+ tags.map(tagTitle => ({+ id: uuidv1(),+ type:+ taggroupTags.length > 0 ? taggroupTags[0].type : 'sidecar',+ title: tagTitle.trim(),+ functionality: '',+ description: '',+ icon: '',+ color: state[indexForEditing].color+ ? state[indexForEditing].color+ : '', // default color+ textcolor: state[indexForEditing].textcolor+ ? state[indexForEditing].textcolor+ : '', // default color+ style: taggroupTags.length > 0 ? taggroupTags[0].style : '',+ created_date: new Date(),+ modified_date: new Date()+ }))+ )+ },+ ...state.slice(indexForEditing + 1)+ ];+ }+ return state;+ }+ case types.UPDATE_TAG: {+ let tagIndexForUpdating = -1;+ let indexForUpdating = -1;+ state.forEach((tagGroup, index) => {+ if (tagGroup.uuid === action.uuid) {+ indexForUpdating = index;+ }+ tagGroup.children.forEach((tag, tagIndex) => {+ if (tag.id === action.entry.id) {+ tagIndexForUpdating = tagIndex;+ }+ });+ });+ if (tagIndexForUpdating >= 0) {+ const modifiedEntry = extend(+ { created_date: new Date() },+ action.entry,+ { modified_date: new Date() }+ );+ return [+ ...state.slice(0, indexForUpdating),+ {+ ...state[indexForUpdating],+ children: [+ ...state[indexForUpdating].children.slice(0, tagIndexForUpdating),+ modifiedEntry,+ ...state[indexForUpdating].children.slice(tagIndexForUpdating + 1)+ ]+ },+ ...state.slice(indexForUpdating + 1)+ ];+ }+ return state;+ }+ case types.REMOVE_TAG: {+ let tagIndexForRemoving = -1;+ let indexForEditing = -1;+ state.forEach((tagGroup, index) => {+ if (tagGroup.uuid === action.uuid) {+ indexForEditing = index;+ }+ tagGroup.children.forEach((tag, tagIndex) => {+ if (tag.id === action.tagID) {+ tagIndexForRemoving = tagIndex;+ }+ });+ });+ if (tagIndexForRemoving >= 0) {+ return [+ ...state.slice(0, indexForEditing),+ {+ ...state[indexForEditing],+ children: [+ ...state[indexForEditing].children.slice(0, tagIndexForRemoving),+ ...state[indexForEditing].children.slice(tagIndexForRemoving + 1)+ ]+ },+ ...state.slice(indexForEditing + 1)+ ];+ }+ return state;+ }+ case types.TOGGLE_TAGGROUP: {+ let indexForUpdating = -1;+ state.forEach((tagGroup, index) => {+ if (tagGroup.uuid === action.uuid) {+ indexForUpdating = index;+ }+ });+ if (indexForUpdating >= 0) {+ return [+ ...state.slice(0, indexForUpdating),+ {+ ...state[indexForUpdating],+ expanded: !action.expanded+ },+ ...state.slice(indexForUpdating + 1)+ ];+ }+ return state;+ }+ case types.MOVE_TAG_GROUP_DOWN: {+ let indexForUpdating = -1;+ state.forEach((tagGroup, index) => {+ if (tagGroup.uuid === action.uuid) {+ indexForUpdating = index;+ }+ });+ if (indexForUpdating >= 0 && indexForUpdating < state.length - 1) {+ const secondIndex = indexForUpdating + 1;+ return immutablySwapItems(state, indexForUpdating, secondIndex);+ }+ return state;+ }+ case types.MOVE_TAG_GROUP_UP: {+ let indexForUpdating = -1;+ state.forEach((tagGroup, index) => {+ if (tagGroup.uuid === action.uuid) {+ indexForUpdating = index;+ }+ });+ if (indexForUpdating > 0) {+ const secondIndex = indexForUpdating - 1;+ return immutablySwapItems(state, indexForUpdating, secondIndex);+ }+ return state;+ }+ case types.SORT_TAG_GROUP_UP: {+ let indexForUpdating = -1;+ state.forEach((tagGroup, index) => {+ if (tagGroup.uuid === action.uuid) {+ indexForUpdating = index;+ }+ });+ if (indexForUpdating >= 0) {+ return [+ ...state.slice(0, indexForUpdating),+ {+ ...state[indexForUpdating],+ children: state[indexForUpdating].children.sort((a, b) =>+ a.title > b.title ? 1 : a.title < b.title ? -1 : 0+ )+ },+ ...state.slice(indexForUpdating + 1)+ ];+ }+ return state;+ }+ case types.MOVE_TAG: {+ let tagIndexForRemoving = -1;+ let indexFromGroup = -1;+ let indexToGroup = -1;+ state.forEach((tagGroup, index) => {+ if (tagGroup.uuid === action.fromTagGroupId) {+ indexFromGroup = index;+ }+ if (tagGroup.uuid === action.toTagGroupId) {+ indexToGroup = index;+ }+ });+ if (indexFromGroup >= 0 && state[indexFromGroup].children) {+ state[indexFromGroup].children.forEach((tag, tagIndex) => {+ if (tag.id === action.tagID) {+ tagIndexForRemoving = tagIndex;+ }+ return true;+ });+ }+ if (indexToGroup >= 0 && indexToGroup >= 0 && tagIndexForRemoving >= 0) {+ const newTagLibrary = [...state];+ const tag = { ...state[indexFromGroup].children[tagIndexForRemoving] };+ const found = newTagLibrary[indexToGroup].children.find(+ t => t.title === tag.title+ );+ if (!found) {+ newTagLibrary[indexToGroup].children.push(tag);+ newTagLibrary[indexFromGroup].children = [+ ...newTagLibrary[indexFromGroup].children.slice(+ 0,+ tagIndexForRemoving+ ),+ ...newTagLibrary[indexFromGroup].children.slice(+ tagIndexForRemoving + 1+ )+ ];+ return newTagLibrary;+ }+ console.warn(+ 'Tag with this title alread exists in the target tag group'+ );+ }+ return state;+ }+ case types.IMPORT_TAGGROUP: {+ const arr = [...state];+ console.log(arr);+ if (action.entry[0].key) {+ action.entry.forEach((tagGroup, index) => {+ // migration of old tag groups 2.9 or less in the new version 3.0-present+ if (tagGroup.key === state.uuid || tagGroup.key !== state.uuid) {+ tagGroup = {+ title: tagGroup.title,+ uuid: tagGroup.key,+ expanded: true,+ children: tagGroup.children+ };+ const tagsArr = [];+ tagGroup.children.forEach(tag => {+ if (!tag.id) {+ tag = {+ id: uuidv1(),+ type: tag.type,+ title: tag.title,+ functionality: tag.title,+ color: tag.color,+ textcolor: tag.textcolor,+ description: tag.description,+ icon: tag.icon,+ style: tag.style+ };+ tagsArr.push(tag);+ }+ tagGroup.children = tagsArr;+ arr.push(tagGroup);+ });+ }+ });+ } else {+ action.entry.forEach(tagGroup => {+ const index = state.findIndex(obj => obj.uuid === tagGroup.uuid);+ if (index > -1) {+ tagGroup.children.forEach(tag => {+ const stateTag = state[index].children.find(+ obj => obj.id === tag.id+ );+ if (stateTag === undefined) {+ arr[index].children.push(tag);+ }+ });+ } else {+ arr.push(tagGroup);+ }+ });+ }- return arr;- }- default: {- return state;- }- }+ return arr;+ }+ default: {+ return state;+ }+ }};export const actions = {- createTagGroup: (entry: TagGroup) => ({ type: types.CREATE_TAGGROUP, entry }),- editTagGroup: (entry: TagGroup) => ({ type: types.UPDATE_TAGGROUP, entry }),- removeTagGroup: (parentTagGroupUuid: Uuid) => ({- type: types.REMOVE_TAGGROUP,- uuid: parentTagGroupUuid- }),- toggleTagGroup: (expanded: boolean, parentTagGroupUuid: Uuid) => ({- type: types.TOGGLE_TAGGROUP,- expanded,- uuid: parentTagGroupUuid- }),- addTagGroup: (entry: TagGroup) => ({ type: types.ADD_TAGGROUP, entry }),- mergeTagGroup: (entry: TagGroup) => ({ type: types.MERGE_TAGGROUP, entry }),- addTag: (tag: string, parentTagGroupUuid: Uuid) => {- console.log('INSIDE ADD TAG');- console.log(tag, parentTagGroupUuid);- return { type: types.ADD_TAG, tag, uuid: parentTagGroupUuid };- },- editTag: (entry: Tag, parentTagGroupUuid: Uuid) => ({- type: types.UPDATE_TAG,- entry,- uuid: parentTagGroupUuid- }),- deleteTag: (tagID: string, parentTagGroupUuid: Uuid) => ({- type: types.REMOVE_TAG,- tagID,- uuid: parentTagGroupUuid- }),- moveTagGroupUp: (parentTagGroupUuid: Uuid) => ({- type: types.MOVE_TAG_GROUP_UP,- uuid: parentTagGroupUuid- }),- moveTagGroupDown: (parentTagGroupUuid: Uuid) => ({- type: types.MOVE_TAG_GROUP_DOWN,- uuid: parentTagGroupUuid- }),- sortTagGroup: (parentTagGroupUuid: Uuid) => ({- type: types.SORT_TAG_GROUP_UP,- uuid: parentTagGroupUuid- }),- moveTag: (tagID: string, fromTagGroupUuid: Uuid, toTagGroupUuid: Uuid) => ({- type: types.MOVE_TAG,- tagID,- fromTagGroupId: fromTagGroupUuid,- toTagGroupId: toTagGroupUuid- }),- importTagGroups: entry => ({ type: types.IMPORT_TAGGROUP, entry }),- exportTagGroups: (entry: Array<Object>) => (- dispatch: (actions: Object) => void,- getState: () => Object- ) => {- const { settings } = getState();- const tagLibrary = entry;- const jsonFormat =- '{ "appName": "' +- versionMeta.name +- '", "appVersion": "' +- versionMeta.version +- '", "settingsVersion": ' +- settings.settingsVersion +- ', "tagGroups": ';- const getAllTags = [];- tagLibrary.forEach(value => {- getAllTags.push(value);- });+ createTagGroup: (entry: TagGroup) => ({ type: types.CREATE_TAGGROUP, entry }),+ editTagGroup: (entry: TagGroup) => ({ type: types.UPDATE_TAGGROUP, entry }),+ removeTagGroup: (parentTagGroupUuid: Uuid) => ({+ type: types.REMOVE_TAGGROUP,+ uuid: parentTagGroupUuid+ }),+ toggleTagGroup: (expanded: boolean, parentTagGroupUuid: Uuid) => ({+ type: types.TOGGLE_TAGGROUP,+ expanded,+ uuid: parentTagGroupUuid+ }),+ addTagGroup: (entry: TagGroup) => ({ type: types.ADD_TAGGROUP, entry }),+ mergeTagGroup: (entry: TagGroup) => ({ type: types.MERGE_TAGGROUP, entry }),+ addTag: (tag: string, parentTagGroupUuid: Uuid) => {+ console.log('INSIDE ADD TAG');+ console.log(tag, parentTagGroupUuid);+ return { type: types.ADD_TAG, tag, uuid: parentTagGroupUuid };+ },+ editTag: (entry: Tag, parentTagGroupUuid: Uuid) => ({+ type: types.UPDATE_TAG,+ entry,+ uuid: parentTagGroupUuid+ }),+ deleteTag: (tagID: string, parentTagGroupUuid: Uuid) => ({+ type: types.REMOVE_TAG,+ tagID,+ uuid: parentTagGroupUuid+ }),+ moveTagGroupUp: (parentTagGroupUuid: Uuid) => ({+ type: types.MOVE_TAG_GROUP_UP,+ uuid: parentTagGroupUuid+ }),+ moveTagGroupDown: (parentTagGroupUuid: Uuid) => ({+ type: types.MOVE_TAG_GROUP_DOWN,+ uuid: parentTagGroupUuid+ }),+ sortTagGroup: (parentTagGroupUuid: Uuid) => ({+ type: types.SORT_TAG_GROUP_UP,+ uuid: parentTagGroupUuid+ }),+ moveTag: (tagID: string, fromTagGroupUuid: Uuid, toTagGroupUuid: Uuid) => ({+ type: types.MOVE_TAG,+ tagID,+ fromTagGroupId: fromTagGroupUuid,+ toTagGroupId: toTagGroupUuid+ }),+ importTagGroups: entry => ({ type: types.IMPORT_TAGGROUP, entry }),+ exportTagGroups: (entry: Array<Object>) => (+ dispatch: (actions: Object) => void,+ getState: () => Object+ ) => {+ const { settings } = getState();+ const tagLibrary = entry;+ const jsonFormat =+ '{ "appName": "' ++ versionMeta.name ++ '", "appVersion": "' ++ versionMeta.version ++ '", "settingsVersion": ' ++ settings.settingsVersion ++ ', "tagGroups": ';+ const getAllTags = [];+ tagLibrary.forEach(value => {+ getAllTags.push(value);+ });- const blob = new Blob([jsonFormat + JSON.stringify(getAllTags) + '}'], {- type: 'application/json'- });- const dateTimeTag = formatDateTime4Tag(new Date(), true);- saveAsTextFile(blob, 'tag-library [tagspaces ' + dateTimeTag + '].json');- console.log('Tag library exported...');- }+ const blob = new Blob([jsonFormat + JSON.stringify(getAllTags) + '}'], {+ type: 'application/json'+ });+ const dateTimeTag = formatDateTime4Tag(new Date(), true);+ saveAsTextFile(blob, 'tag-library [tagspaces ' + dateTimeTag + '].json');+ console.log('Tag library exported...');+ }};// Selectorsexport const getTagGroups = (state: Object) => state.taglibrary;export const getAllTags = (state: Object) => {- const allTags: Array<Tag> = [];- state.taglibrary.forEach(tagGroup => {- tagGroup.children.forEach(tag => {- allTags.push(tag);- });- });- return allTags.sort((a, b) =>- a.title > b.title ? 1 : a.title < b.title ? -1 : 0- );+ const allTags: Array<Tag> = [];+ state.taglibrary.forEach(tagGroup => {+ tagGroup.children.forEach(tag => {+ allTags.push(tag);+ });+ });+ return allTags.sort((a, b) =>+ a.title > b.title ? 1 : a.title < b.title ? -1 : 0+ );};export const getTagColors = (state: Object, tagTitle: string) => {- const tagColors = {- textcolor: state.settings.tagTextColor,- color: state.settings.tagBackgroundColor- };- state.taglibrary.forEach(tagGroup => {- tagGroup.children.forEach((tag: Tag) => {- if (tag.title === tagTitle) {- tagColors.textcolor = tag.textcolor;- tagColors.color = tag.color;- }- });- });- return tagColors;+ const tagColors = {+ textcolor: state.settings.tagTextColor,+ color: state.settings.tagBackgroundColor+ };+ state.taglibrary.forEach(tagGroup => {+ tagGroup.children.forEach((tag: Tag) => {+ if (tag.title === tagTitle) {+ tagColors.textcolor = tag.textcolor;+ tagColors.color = tag.color;+ }+ });+ });+ return tagColors;};diff --git a/app/routes.ts b/app/routes.tsindex 7023c50bf..1d27c75a4 100644--- a/app/routes.ts+++ b/app/routes.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*//* eslint flowtype-errors/show-errors: 0 */diff --git a/app/services/cordova-io.ts b/app/services/cordova-io.tsindex 3b2b0a7dd..a2c6589e3 100644--- a/app/services/cordova-io.ts+++ b/app/services/cordova-io.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*//* globals cordova */diff --git a/app/services/electron-io.ts b/app/services/electron-io.tsindex 524acb8cb..4f649a9b4 100644--- a/app/services/electron-io.ts+++ b/app/services/electron-io.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import fsextra from 'fs-extra';diff --git a/app/services/electron-menus.ts b/app/services/electron-menus.tsindex 80dbe6591..dea4f81a5 100644--- a/app/services/electron-menus.ts+++ b/app/services/electron-menus.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import i18n from './i18n';@@ -24,69 +23,69 @@ import AppConfig from '../config';let ipcRenderer;if (AppConfig.isElectron && window.require) {- const electron = window.require('electron');- ipcRenderer = electron.ipcRenderer;+ const electron = window.require('electron');+ ipcRenderer = electron.ipcRenderer;}-export default function buildDesktopMenu(mainPageProps: Object) {- if (!AppConfig.isElectron) {- return;- }+export default function buildDesktopMenu(mainPageProps: any) {+ if (!AppConfig.isElectron) {+ return;+ }- ipcRenderer.on('file', (event, arg) => {- // console.log('Global events: ' + arg);- switch (arg) {- case 'new-text-file':- mainPageProps.toggleCreateFileDialog();- break;- case 'audio':- // console.log('showAudioRecordingDialog');- break;- case 'next-file': {- const path = mainPageProps.getNextFile();- mainPageProps.openFile(path);- mainPageProps.setLastSelectedEntry(path);- break;- }- case 'previous-file': {- const path = mainPageProps.getPrevFile();- mainPageProps.openFile(path);- mainPageProps.setLastSelectedEntry(path);- break;- }- default:- return false;- }- });+ ipcRenderer.on('file', (event, arg) => {+ // console.log('Global events: ' + arg);+ switch (arg) {+ case 'new-text-file':+ mainPageProps.toggleCreateFileDialog();+ break;+ case 'audio':+ // console.log('showAudioRecordingDialog');+ break;+ case 'next-file': {+ const path = mainPageProps.getNextFile();+ mainPageProps.openFile(path);+ mainPageProps.setLastSelectedEntry(path);+ break;+ }+ case 'previous-file': {+ const path = mainPageProps.getPrevFile();+ mainPageProps.openFile(path);+ mainPageProps.setLastSelectedEntry(path);+ break;+ }+ default:+ return false;+ }+ });- ipcRenderer.on('play-pause', (event, arg) => {- // Create the event.- const audioEvent = new CustomEvent('toggle-resume', { detail: '' });- window.dispatchEvent(audioEvent);- });+ ipcRenderer.on('play-pause', (event, arg) => {+ // Create the event.+ const audioEvent = new CustomEvent('toggle-resume', { detail: '' });+ window.dispatchEvent(audioEvent);+ });- const templateDefault = [- {- label: i18n.t('core:file'),- submenu: [- /* {+ const templateDefault = [+ {+ label: i18n.t('core:file'),+ submenu: [+ /* {label: i18n.t('core:openNewInstance'),accelerator: '',click: () => {// ipcRenderer.send('new-win', 'newWin');}}, */- /* {+ /* {type: 'separator'}, */- {- label: i18n.t('core:newFileNote'),- // accelerator: 'CommandOrControl+Alt+N',- click: () => {- mainPageProps.toggleCreateFileDialog();- }- },- /* {+ {+ label: i18n.t('core:newFileNote'),+ // accelerator: 'CommandOrControl+Alt+N',+ click: () => {+ mainPageProps.toggleCreateFileDialog();+ }+ },+ /* {label: i18n.t('core:createMarkdown'),accelerator: '',// click: createMDFile@@ -97,20 +96,20 @@ export default function buildDesktopMenu(mainPageProps: Object) {// click: createHTMLFile},*/- {- type: 'separator'- },- {- label: i18n.t('core:createDirectory'),- accelerator: '',- click: () => {- mainPageProps.showCreateDirectoryDialog();- }- },- {- type: 'separator'- },- /* {+ {+ type: 'separator'+ },+ {+ label: i18n.t('core:createDirectory'),+ accelerator: '',+ click: () => {+ mainPageProps.showCreateDirectoryDialog();+ }+ },+ {+ type: 'separator'+ },+ /* {label: i18n.t('core:saveFile'),accelerator: mainPageProps.keyBindings.saveDocument,click: () => {@@ -120,236 +119,236 @@ export default function buildDesktopMenu(mainPageProps: Object) {{type: 'separator'}, */- /* {+ /* {label: i18n.t('core:closeWin'),accelerator: '',click: (item, focusedWindow) => {focusedWindow.destroy();}}, */- {- label: i18n.t('core:exitApp'),- accelerator: 'CmdOrCtrl+Q',- click: PlatformIO.quitApp- }- ]- },- {- label: i18n.t('core:edit'),- submenu: [- {- label: i18n.t('core:undo'),- accelerator: 'CmdOrCtrl+Z',- role: 'undo'- },- {- label: i18n.t('core:redo'),- accelerator: 'Shift+CmdOrCtrl+Z',- role: 'redo'- },- {- type: 'separator'- },- {- label: i18n.t('core:cut'),- accelerator: 'CmdOrCtrl+X',- role: 'cut'- },- {- label: i18n.t('core:copy'),- accelerator: 'CmdOrCtrl+C',- role: 'copy'- },- {- label: i18n.t('core:paste'),- accelerator: 'CmdOrCtrl+V',- role: 'paste'- },- {- label: i18n.t('core:selectAll'),- accelerator: 'CmdOrCtrl+A',- role: 'selectall'- }- ]- },- {- label: i18n.t('core:view'),- submenu: [- {- label: i18n.t('core:showLocationManager'),- accelerator: mainPageProps.keyBindings.showLocationManager,- click: () => {- mainPageProps.openLocationManagerPanel();- }- },- {- label: i18n.t('core:showTagLibrary'),- accelerator: mainPageProps.keyBindings.showTagLibrary,- click: () => {- mainPageProps.openTagLibraryPanel();- }- },- {- label: i18n.t('core:showSearch'),- accelerator: mainPageProps.keyBindings.showSearch,- click: () => {- mainPageProps.openSearchPanel();- }- },- {- label: i18n.t('core:showDevTools'),- accelerator: mainPageProps.keyBindings.openDevTools,- click: (item, focusedWindow) => {- focusedWindow.toggleDevTools();- }- },- {- label: i18n.t('core:reloadApplication'),- accelerator: mainPageProps.keyBindings.reloadApplication,- click: (item, focusedWindow) => {- // ipcRenderer.send('relaunch-app', 'relaunch');- focusedWindow.webContents.reload();- }- },- {- type: 'separator'- },- {- label: i18n.t('core:zoomReset'),- accelerator: 'CmdOrCtrl+0',- click: () => {- mainPageProps.setZoomResetApp();- }- },- {- label: i18n.t('core:zoomIn'),- accelerator: 'CmdOrCtrl+Plus',- click: () => {- mainPageProps.setZoomInApp();- }- },- {- label: i18n.t('core:zoomOut'),- accelerator: 'CmdOrCtrl+-',- click: () => {- mainPageProps.setZoomOutApp();- }- },- {- label: i18n.t('core:toggleFullScreen'),- accelerator: mainPageProps.keyBindings.toggleFullScreen,- click: (item, focusedWindow) => {- focusedWindow.setFullScreen(!focusedWindow.isFullScreen());- }- },- {- type: 'separator'- },- {- label: i18n.t('core:settings'),- click: () => {- mainPageProps.toggleSettingsDialog();- }- }- ]- },- {- label: '&' + i18n.t('core:help'),- submenu: [- {- label: '&' + i18n.t('core:documentation'),- accelerator: mainPageProps.keyBindings.showHelp,- click: () => {- // mainPageProps.openURLExternally(AppConfig.documentationLinks.general);- mainPageProps.openHelpFeedbackPanel();- }- },- {- label: '&' + i18n.t('core:shortcutKeys'),- click: () => {- mainPageProps.toggleKeysDialog();- }- },- {- label: 'Welcome Wizzard',- click: () => {- mainPageProps.toggleOnboardingDialog();- }- },- {- label: '&' + i18n.t('core:whatsNew'),- click: () => {- mainPageProps.openURLExternally(AppConfig.links.changelogURL);- }- },- {- type: 'separator'- },- {- label: '&' + i18n.t('core:likeUsOnFacebook'),- click: () => {- mainPageProps.openURLExternally(AppConfig.links.facebook);- }- },- {- label: '&' + i18n.t('core:followOnTwitter'),- click: () => {- mainPageProps.openURLExternally(AppConfig.links.twitter);- }- },- {- type: 'separator'- },- {- label: '&' + i18n.t('core:suggestNewFeatures'),- click: () => {- mainPageProps.openURLExternally(AppConfig.links.suggestFeature);- }- },- {- label: '&' + i18n.t('core:reportIssues'),- click: () => {- mainPageProps.openURLExternally(AppConfig.links.reportIssue);- }- },- {- type: 'separator'- },- {- label: i18n.t('core:webClipperChrome'),- click: () => {- mainPageProps.openURLExternally(AppConfig.links.webClipperChrome);- }- },- {- label: i18n.t('core:webClipperFirefox'),- click: () => {- mainPageProps.openURLExternally(AppConfig.links.webClipperFirefox);- }- },- {- type: 'separator'- },- {- label: '&' + i18n.t('core:license'),- click: () => {- mainPageProps.toggleLicenseDialog();- }- },- {- label: '&' + i18n.t('core:thirdPartyLibs'),- click: () => {- mainPageProps.toggleThirdPartyLibsDialog();- }- },- {- label: '&' + i18n.t('core:aboutTagSpaces'),- click: () => {- mainPageProps.toggleAboutDialog();- }- }- ]- }- ];- PlatformIO.initMainMenu(templateDefault);+ {+ label: i18n.t('core:exitApp'),+ accelerator: 'CmdOrCtrl+Q',+ click: PlatformIO.quitApp+ }+ ]+ },+ {+ label: i18n.t('core:edit'),+ submenu: [+ {+ label: i18n.t('core:undo'),+ accelerator: 'CmdOrCtrl+Z',+ role: 'undo'+ },+ {+ label: i18n.t('core:redo'),+ accelerator: 'Shift+CmdOrCtrl+Z',+ role: 'redo'+ },+ {+ type: 'separator'+ },+ {+ label: i18n.t('core:cut'),+ accelerator: 'CmdOrCtrl+X',+ role: 'cut'+ },+ {+ label: i18n.t('core:copy'),+ accelerator: 'CmdOrCtrl+C',+ role: 'copy'+ },+ {+ label: i18n.t('core:paste'),+ accelerator: 'CmdOrCtrl+V',+ role: 'paste'+ },+ {+ label: i18n.t('core:selectAll'),+ accelerator: 'CmdOrCtrl+A',+ role: 'selectall'+ }+ ]+ },+ {+ label: i18n.t('core:view'),+ submenu: [+ {+ label: i18n.t('core:showLocationManager'),+ accelerator: mainPageProps.keyBindings.showLocationManager,+ click: () => {+ mainPageProps.openLocationManagerPanel();+ }+ },+ {+ label: i18n.t('core:showTagLibrary'),+ accelerator: mainPageProps.keyBindings.showTagLibrary,+ click: () => {+ mainPageProps.openTagLibraryPanel();+ }+ },+ {+ label: i18n.t('core:showSearch'),+ accelerator: mainPageProps.keyBindings.showSearch,+ click: () => {+ mainPageProps.openSearchPanel();+ }+ },+ {+ label: i18n.t('core:showDevTools'),+ accelerator: mainPageProps.keyBindings.openDevTools,+ click: (item, focusedWindow) => {+ focusedWindow.toggleDevTools();+ }+ },+ {+ label: i18n.t('core:reloadApplication'),+ accelerator: mainPageProps.keyBindings.reloadApplication,+ click: (item, focusedWindow) => {+ // ipcRenderer.send('relaunch-app', 'relaunch');+ focusedWindow.webContents.reload();+ }+ },+ {+ type: 'separator'+ },+ {+ label: i18n.t('core:zoomReset'),+ accelerator: 'CmdOrCtrl+0',+ click: () => {+ mainPageProps.setZoomResetApp();+ }+ },+ {+ label: i18n.t('core:zoomIn'),+ accelerator: 'CmdOrCtrl+Plus',+ click: () => {+ mainPageProps.setZoomInApp();+ }+ },+ {+ label: i18n.t('core:zoomOut'),+ accelerator: 'CmdOrCtrl+-',+ click: () => {+ mainPageProps.setZoomOutApp();+ }+ },+ {+ label: i18n.t('core:toggleFullScreen'),+ accelerator: mainPageProps.keyBindings.toggleFullScreen,+ click: (item, focusedWindow) => {+ focusedWindow.setFullScreen(!focusedWindow.isFullScreen());+ }+ },+ {+ type: 'separator'+ },+ {+ label: i18n.t('core:settings'),+ click: () => {+ mainPageProps.toggleSettingsDialog();+ }+ }+ ]+ },+ {+ label: '&' + i18n.t('core:help'),+ submenu: [+ {+ label: '&' + i18n.t('core:documentation'),+ accelerator: mainPageProps.keyBindings.showHelp,+ click: () => {+ // mainPageProps.openURLExternally(AppConfig.documentationLinks.general);+ mainPageProps.openHelpFeedbackPanel();+ }+ },+ {+ label: '&' + i18n.t('core:shortcutKeys'),+ click: () => {+ mainPageProps.toggleKeysDialog();+ }+ },+ {+ label: 'Welcome Wizzard',+ click: () => {+ mainPageProps.toggleOnboardingDialog();+ }+ },+ {+ label: '&' + i18n.t('core:whatsNew'),+ click: () => {+ mainPageProps.openURLExternally(AppConfig.links.changelogURL);+ }+ },+ {+ type: 'separator'+ },+ {+ label: '&' + i18n.t('core:likeUsOnFacebook'),+ click: () => {+ mainPageProps.openURLExternally(AppConfig.links.facebook);+ }+ },+ {+ label: '&' + i18n.t('core:followOnTwitter'),+ click: () => {+ mainPageProps.openURLExternally(AppConfig.links.twitter);+ }+ },+ {+ type: 'separator'+ },+ {+ label: '&' + i18n.t('core:suggestNewFeatures'),+ click: () => {+ mainPageProps.openURLExternally(AppConfig.links.suggestFeature);+ }+ },+ {+ label: '&' + i18n.t('core:reportIssues'),+ click: () => {+ mainPageProps.openURLExternally(AppConfig.links.reportIssue);+ }+ },+ {+ type: 'separator'+ },+ {+ label: i18n.t('core:webClipperChrome'),+ click: () => {+ mainPageProps.openURLExternally(AppConfig.links.webClipperChrome);+ }+ },+ {+ label: i18n.t('core:webClipperFirefox'),+ click: () => {+ mainPageProps.openURLExternally(AppConfig.links.webClipperFirefox);+ }+ },+ {+ type: 'separator'+ },+ {+ label: '&' + i18n.t('core:license'),+ click: () => {+ mainPageProps.toggleLicenseDialog();+ }+ },+ {+ label: '&' + i18n.t('core:thirdPartyLibs'),+ click: () => {+ mainPageProps.toggleThirdPartyLibsDialog();+ }+ },+ {+ label: '&' + i18n.t('core:aboutTagSpaces'),+ click: () => {+ mainPageProps.toggleAboutDialog();+ }+ }+ ]+ }+ ];+ PlatformIO.initMainMenu(templateDefault);}diff --git a/app/services/electron-tray-menu.ts b/app/services/electron-tray-menu.tsindex 3e7de714b..e4cae9d6e 100644--- a/app/services/electron-tray-menu.ts+++ b/app/services/electron-tray-menu.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/// import { webFrame, ipcRenderer } from 'electron';@@ -22,67 +21,67 @@ import PlatformIO from './platform-io';import i18n from './i18n';import AppConfig from '../config';-export default function buildTrayIconMenu(mainPageProps: Object) {- if (!AppConfig.isElectron) {- return;- }+export default function buildTrayIconMenu(mainPageProps: any) {+ if (!AppConfig.isElectron) {+ return;+ }- const cKey = AppConfig.isMacLike ? ' - Cmd' : ' - Ctrl';+ const cKey = AppConfig.isMacLike ? ' - Cmd' : ' - Ctrl';- function openNextFile() {- const path = mainPageProps.getNextFile();- mainPageProps.openFile(path);- mainPageProps.setLastSelectedEntry(path);- }+ function openNextFile() {+ const path = mainPageProps.getNextFile();+ mainPageProps.openFile(path);+ mainPageProps.setLastSelectedEntry(path);+ }- function openPrevFile() {- const path = mainPageProps.getPrevFile();- mainPageProps.openFile(path);- mainPageProps.setLastSelectedEntry(path);- }+ function openPrevFile() {+ const path = mainPageProps.getPrevFile();+ mainPageProps.openFile(path);+ mainPageProps.setLastSelectedEntry(path);+ }- function playResumePlayback() {- const audioEvent = new CustomEvent('toggle-resume', { detail: '' });- window.dispatchEvent(audioEvent);- }+ function playResumePlayback() {+ const audioEvent = new CustomEvent('toggle-resume', { detail: '' });+ window.dispatchEvent(audioEvent);+ }- const trayMenuTemplate = [- {- label: i18n.t('core:showTagSpaces') + cKey + '+Shift+W',- click: PlatformIO.showMainWindow- },- {- type: 'separator'- },- {- label: i18n.t('core:newFileNote') + cKey + '+Shift+N',- click: mainPageProps.toggleCreateFileDialog- },- {- type: 'separator'- },- {- label: i18n.t('core:openNextFileTooltip') + cKey + '+Shift+D',- click: openNextFile- },- {- label: i18n.t('core:openPrevFileTooltip') + cKey + '+Shift+A',- click: openPrevFile- },- {- type: 'separator'- },- {- label: i18n.t('core:pauseResumePlayback') + cKey + '+Shift+P',- click: playResumePlayback- },- {- type: 'separator'- },- {- label: i18n.t('core:quitTagSpaces') + cKey + '+Q',- click: PlatformIO.quitApp- }- ];- PlatformIO.initTrayMenu(trayMenuTemplate);+ const trayMenuTemplate = [+ {+ label: i18n.t('core:showTagSpaces') + cKey + '+Shift+W',+ click: PlatformIO.showMainWindow+ },+ {+ type: 'separator'+ },+ {+ label: i18n.t('core:newFileNote') + cKey + '+Shift+N',+ click: mainPageProps.toggleCreateFileDialog+ },+ {+ type: 'separator'+ },+ {+ label: i18n.t('core:openNextFileTooltip') + cKey + '+Shift+D',+ click: openNextFile+ },+ {+ label: i18n.t('core:openPrevFileTooltip') + cKey + '+Shift+A',+ click: openPrevFile+ },+ {+ type: 'separator'+ },+ {+ label: i18n.t('core:pauseResumePlayback') + cKey + '+Shift+P',+ click: playResumePlayback+ },+ {+ type: 'separator'+ },+ {+ label: i18n.t('core:quitTagSpaces') + cKey + '+Q',+ click: PlatformIO.quitApp+ }+ ];+ PlatformIO.initTrayMenu(trayMenuTemplate);}diff --git a/app/services/i18n.ts b/app/services/i18n.tsindex 37db601c5..16e9891f9 100644--- a/app/services/i18n.ts+++ b/app/services/i18n.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import i18n from 'i18next';diff --git a/app/services/onlineListener.ts b/app/services/onlineListener.tsindex 78f443235..13a73d3ca 100644--- a/app/services/onlineListener.ts+++ b/app/services/onlineListener.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import { actions as CommonActions } from '../reducers/app';diff --git a/app/services/platform-io.ts b/app/services/platform-io.tsindex c4537155c..f59216e83 100644--- a/app/services/platform-io.ts+++ b/app/services/platform-io.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import AppConfig from '../config';diff --git a/app/services/search.ts b/app/services/search.tsindex 61c6c24b0..e035a6577 100644--- a/app/services/search.ts+++ b/app/services/search.ts@@ -14,58 +14,57 @@* 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/>.*- * @flow*/import Fuse from 'fuse.js';import jmespath from 'jmespath';-import { type Tag } from '../reducers/taglibrary';+import { Tag } from '../reducers/taglibrary';import { Pro } from '../pro';// export type FileTypeGroups = 'images' | 'notes' | 'documents' | 'audio' | 'video' | 'archives';export const FileTypeGroups = {- any: [''],- images: [- 'jpg',- 'jpeg',- 'png',- 'gif',- 'bmp',- 'tif',- 'tiff',- 'ico',- 'webp',- 'psd'- ],- notes: ['md', 'mdown', 'txt', 'html'],- documents: ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'odt', 'ods'],- audio: ['ogg', 'mp3', 'wav', 'wave'],- video: ['ogv', 'mp4', 'webm', 'm4v', 'mkv', 'avi'],- archives: ['zip', 'rar', 'gz', 'tgz', 'arc', '7z'],- bookmarks: ['url', 'lnk', 'sym'],- ebooks: ['epub', 'mobi', 'azw', 'prc', 'azw1', 'azw3', 'azw4', 'azw8', 'azk'],- folders: ['folders'],- files: ['files'],- untagged: ['untagged']+ any: [''],+ images: [+ 'jpg',+ 'jpeg',+ 'png',+ 'gif',+ 'bmp',+ 'tif',+ 'tiff',+ 'ico',+ 'webp',+ 'psd'+ ],+ notes: ['md', 'mdown', 'txt', 'html'],+ documents: ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'odt', 'ods'],+ audio: ['ogg', 'mp3', 'wav', 'wave'],+ video: ['ogv', 'mp4', 'webm', 'm4v', 'mkv', 'avi'],+ archives: ['zip', 'rar', 'gz', 'tgz', 'arc', '7z'],+ bookmarks: ['url', 'lnk', 'sym'],+ ebooks: ['epub', 'mobi', 'azw', 'prc', 'azw1', 'azw3', 'azw4', 'azw8', 'azk'],+ folders: ['folders'],+ files: ['files'],+ untagged: ['untagged']};export type SearchQuery = {- textQuery?: string,- fileTypes?: Array<string>,- tagsAND?: Array<Tag>,- tagsOR?: Array<Tag>,- tagsNOT?: Array<Tag>,- lastModified: string,- fileSize: string,- searchBoxing: 'location' | 'folder',- currentDirectory: string,- tagTimePeriodFrom?: number | null,- tagTimePeriodTo?: number | null,- tagPlaceLat?: number | null,- tagPlaceLong?: number | null,- tagPlaceRadius?: number | null,- maxSearchResults?: number+ textQuery?: string;+ fileTypes?: Array<string>;+ tagsAND?: Array<Tag>;+ tagsOR?: Array<Tag>;+ tagsNOT?: Array<Tag>;+ lastModified: string;+ fileSize: string;+ searchBoxing: 'location' | 'folder';+ currentDirectory: string;+ tagTimePeriodFrom?: number | null;+ tagTimePeriodTo?: number | null;+ tagPlaceLat?: number | null;+ tagPlaceLong?: number | null;+ tagPlaceRadius?: number | null;+ maxSearchResults?: number;};// id, name, isFile, tags, extension, size, lmdt, path@@ -102,35 +101,35 @@ export type SearchQuery = {*/const fuseOptions = {- shouldSort: true,- threshold: 0.3,- location: 0,- distance: 100,- tokenize: true,- maxPatternLength: 32,- minMatchCharLength: 1,- keys: [- {- name: 'name',- weight: 0.4- },- {- name: 'description',- weight: 0.4- },- {- name: 'textContent',- weight: 0.4- },- {- name: 'tags',- weight: 0.3- },- {- name: 'path', // TODO ignore .ts folder, should not be in the index- weight: 0.1- }- ]+ shouldSort: true,+ threshold: 0.3,+ location: 0,+ distance: 100,+ tokenize: true,+ maxPatternLength: 32,+ minMatchCharLength: 1,+ keys: [+ {+ name: 'name',+ weight: 0.4+ },+ {+ name: 'description',+ weight: 0.4+ },+ {+ name: 'textContent',+ weight: 0.4+ },+ {+ name: 'tags',+ weight: 0.3+ },+ {+ name: 'path', // TODO ignore .ts folder, should not be in the index+ weight: 0.1+ }+ ]};// Constructs the string for the JMESPath search query. We first filter for all ORTags, then continuously pipe the result in to the@@ -138,169 +137,169 @@ const fuseOptions = {// The final string for the tag search should look like this:// index[? tags[? title=='ORTag1' || title=='ORTag2']] | [? tags[? title=='ANDTag1']] | [? tags[? title=='ANDTag2']] | [?!(tags[? title=='NOTTag1'])] | [?!(tags[? title=='NOTTag2'])] | extensionFilterfunction constructjmespathQuery(searchQuery: SearchQuery): string {- let jmespathQuery = '';- const ANDtagsExist = searchQuery.tagsAND && searchQuery.tagsAND.length >= 1;- const ORtagsExist = searchQuery.tagsOR && searchQuery.tagsOR.length >= 1;- const NOTtagsExist = searchQuery.tagsNOT && searchQuery.tagsNOT.length >= 1;- if (ANDtagsExist || ORtagsExist || NOTtagsExist) {- jmespathQuery = '[?';+ let jmespathQuery = '';+ const ANDtagsExist = searchQuery.tagsAND && searchQuery.tagsAND.length >= 1;+ const ORtagsExist = searchQuery.tagsOR && searchQuery.tagsOR.length >= 1;+ const NOTtagsExist = searchQuery.tagsNOT && searchQuery.tagsNOT.length >= 1;+ if (ANDtagsExist || ORtagsExist || NOTtagsExist) {+ jmespathQuery = '[?';- if (ORtagsExist) {- jmespathQuery += ' tags[? ';- searchQuery.tagsOR.forEach(tag => {- const cleanedTagTitle = tag.title.trim().toLowerCase();- if (cleanedTagTitle.length > 0) {- jmespathQuery += "title=='" + cleanedTagTitle + "' || ";- }- return true;- });- }+ if (ORtagsExist) {+ jmespathQuery += ' tags[? ';+ searchQuery.tagsOR.forEach(tag => {+ const cleanedTagTitle = tag.title.trim().toLowerCase();+ if (cleanedTagTitle.length > 0) {+ jmespathQuery += "title=='" + cleanedTagTitle + "' || ";+ }+ return true;+ });+ }- if (ANDtagsExist) {- if (jmespathQuery.endsWith(' || ')) {- jmespathQuery =- jmespathQuery.substring(0, jmespathQuery.length - 4) +- ']] | [? tags[? ';- } else {- jmespathQuery += ' tags[? ';- }- searchQuery.tagsAND.forEach(tag => {- const cleanedTagTitle = tag.title.trim().toLowerCase();- if (cleanedTagTitle.length > 0) {- jmespathQuery += "title=='" + cleanedTagTitle + "']] | [? tags[? ";- }- });- }+ if (ANDtagsExist) {+ if (jmespathQuery.endsWith(' || ')) {+ jmespathQuery =+ jmespathQuery.substring(0, jmespathQuery.length - 4) ++ ']] | [? tags[? ';+ } else {+ jmespathQuery += ' tags[? ';+ }+ searchQuery.tagsAND.forEach(tag => {+ const cleanedTagTitle = tag.title.trim().toLowerCase();+ if (cleanedTagTitle.length > 0) {+ jmespathQuery += "title=='" + cleanedTagTitle + "']] | [? tags[? ";+ }+ });+ }- if (NOTtagsExist) {- if (jmespathQuery.endsWith(' || ')) {- jmespathQuery =- jmespathQuery.substring(0, jmespathQuery.length - 4) +- ']] | [?!(tags[? ';- } else if (jmespathQuery.endsWith('[? tags[? ')) {- jmespathQuery =- jmespathQuery.substring(0, jmespathQuery.length - 10) + '[?!(tags[? ';- } else {- jmespathQuery += '!(tags[? ';- }- searchQuery.tagsNOT.forEach(tag => {- const cleanedTagTitle = tag.title.trim().toLowerCase();- if (cleanedTagTitle.length > 0) {- jmespathQuery += "title=='" + cleanedTagTitle + "'])] | [?!(tags[? ";- }- return true;- });- }+ if (NOTtagsExist) {+ if (jmespathQuery.endsWith(' || ')) {+ jmespathQuery =+ jmespathQuery.substring(0, jmespathQuery.length - 4) ++ ']] | [?!(tags[? ';+ } else if (jmespathQuery.endsWith('[? tags[? ')) {+ jmespathQuery =+ jmespathQuery.substring(0, jmespathQuery.length - 10) + '[?!(tags[? ';+ } else {+ jmespathQuery += '!(tags[? ';+ }+ searchQuery.tagsNOT.forEach(tag => {+ const cleanedTagTitle = tag.title.trim().toLowerCase();+ if (cleanedTagTitle.length > 0) {+ jmespathQuery += "title=='" + cleanedTagTitle + "'])] | [?!(tags[? ";+ }+ return true;+ });+ }- if (jmespathQuery.endsWith(' || ')) {- jmespathQuery =- jmespathQuery.substring(0, jmespathQuery.length - 4) + ']]';- } else if (jmespathQuery.endsWith(' | [? tags[? ')) {- jmespathQuery = jmespathQuery.substring(0, jmespathQuery.length - 13);- } else if (jmespathQuery.endsWith(' | [?!(tags[? ')) {- jmespathQuery = jmespathQuery.substring(0, jmespathQuery.length - 14);- }- }+ if (jmespathQuery.endsWith(' || ')) {+ jmespathQuery =+ jmespathQuery.substring(0, jmespathQuery.length - 4) + ']]';+ } else if (jmespathQuery.endsWith(' | [? tags[? ')) {+ jmespathQuery = jmespathQuery.substring(0, jmespathQuery.length - 13);+ } else if (jmespathQuery.endsWith(' | [?!(tags[? ')) {+ jmespathQuery = jmespathQuery.substring(0, jmespathQuery.length - 14);+ }+ }- const extensionQuery = Pro- ? Pro.Search.constructFileTypeQuery(searchQuery)- : '';- if (extensionQuery.length > 0) {- jmespathQuery =- jmespathQuery.length > 0- ? jmespathQuery + ' | ' + extensionQuery- : extensionQuery;- }+ const extensionQuery = Pro+ ? Pro.Search.constructFileTypeQuery(searchQuery)+ : '';+ if (extensionQuery.length > 0) {+ jmespathQuery =+ jmespathQuery.length > 0+ ? jmespathQuery + ' | ' + extensionQuery+ : extensionQuery;+ }- if (jmespathQuery.length > 0) {- return 'index' + jmespathQuery;- }- return jmespathQuery;+ if (jmespathQuery.length > 0) {+ return 'index' + jmespathQuery;+ }+ return jmespathQuery;}function prepareIndex(index: Array<Object>) {- console.time('PreparingIndex');- let resultIndex = [];- if (Pro && Pro.Search && Pro.Search.prepareIndex) {- resultIndex = Pro.Search.prepareIndex(index);- } else {- resultIndex = index.map(entry => {- const tags = [...entry.tags];- if (tags && tags.length) {- tags.map(tag => {- tag.title = tag.title.toLowerCase();- return tag;- });- }- return {- ...entry,- tags- };- });- }- console.timeEnd('PreparingIndex');- return resultIndex;+ console.time('PreparingIndex');+ let resultIndex = [];+ if (Pro && Pro.Search && Pro.Search.prepareIndex) {+ resultIndex = Pro.Search.prepareIndex(index);+ } else {+ resultIndex = index.map(entry => {+ const tags = [...entry.tags];+ if (tags && tags.length) {+ tags.map(tag => {+ tag.title = tag.title.toLowerCase();+ return tag;+ });+ }+ return {+ ...entry,+ tags+ };+ });+ }+ console.timeEnd('PreparingIndex');+ return resultIndex;}export default class Search {- static searchLocationIndex = (- locationContent: Array<Object>,- searchQuery: SearchQuery- ): Promise<Array<Object> | []> =>- new Promise(resolve => {- console.time('searchtime');- const jmespathQuery = constructjmespathQuery(searchQuery);- let results = prepareIndex(locationContent);- let searched = false;+ static searchLocationIndex = (+ locationContent: Array<Object>,+ searchQuery: SearchQuery+ ): Promise<Array<Object> | []> =>+ new Promise(resolve => {+ console.time('searchtime');+ const jmespathQuery = constructjmespathQuery(searchQuery);+ let results = prepareIndex(locationContent);+ let searched = false;- // Limiting the search to current folder only (with sub-folders)- if (searchQuery.searchBoxing === 'folder') {- results = results.filter(entry =>- entry.path.startsWith(searchQuery.currentDirectory)- );- }+ // Limiting the search to current folder only (with sub-folders)+ if (searchQuery.searchBoxing === 'folder') {+ results = results.filter(entry =>+ entry.path.startsWith(searchQuery.currentDirectory)+ );+ }- if (jmespathQuery) {- const resultCount = results.length;- console.log('jmespath query: ' + jmespathQuery);- console.time('jmespath');- results = jmespath.search({ index: results }, jmespathQuery);- console.timeEnd('jmespath');- console.log('jmespath results: ' + results.length);- searched = searched || results.length < resultCount;- }+ if (jmespathQuery) {+ const resultCount = results.length;+ console.log('jmespath query: ' + jmespathQuery);+ console.time('jmespath');+ results = jmespath.search({ index: results }, jmespathQuery);+ console.timeEnd('jmespath');+ console.log('jmespath results: ' + results.length);+ searched = searched || results.length < resultCount;+ }- if (Pro && Pro.Search.filterIndex) {- const resultCount = results.length;- results = Pro.Search.filterIndex(results, searchQuery);- searched = searched || results.length < resultCount;- }+ if (Pro && Pro.Search.filterIndex) {+ const resultCount = results.length;+ results = Pro.Search.filterIndex(results, searchQuery);+ searched = searched || results.length < resultCount;+ }- if (searchQuery.textQuery && searchQuery.textQuery.length > 1) {- const resultCount = results.length;- console.log('fuse query: ' + searchQuery.textQuery);- console.time('fuse');- const fuse = new Fuse(results, fuseOptions);- results = fuse.search(searchQuery.textQuery);- console.timeEnd('fuse');- searched = searched || results.length < resultCount;- }+ if (searchQuery.textQuery && searchQuery.textQuery.length > 1) {+ const resultCount = results.length;+ console.log('fuse query: ' + searchQuery.textQuery);+ console.time('fuse');+ const fuse = new Fuse(results, fuseOptions);+ results = fuse.search(searchQuery.textQuery);+ console.timeEnd('fuse');+ searched = searched || results.length < resultCount;+ }- if (searched) {- console.log('Results found: ' + results.length);- if (- searchQuery.maxSearchResults &&- results.length >= searchQuery.maxSearchResults- ) {- results = results.slice(0, searchQuery.maxSearchResults);- }- console.log('Results send: ' + results.length);- console.timeEnd('searchtime');- resolve(results);- return true;- }- results = [];- console.timeEnd('searchtime');- resolve(results);- });+ if (searched) {+ console.log('Results found: ' + results.length);+ if (+ searchQuery.maxSearchResults &&+ results.length >= searchQuery.maxSearchResults+ ) {+ results = results.slice(0, searchQuery.maxSearchResults);+ }+ console.log('Results send: ' + results.length);+ console.timeEnd('searchtime');+ resolve(results);+ return true;+ }+ results = [];+ console.timeEnd('searchtime');+ resolve(results);+ });}diff --git a/app/services/thumbsgenerator.ts b/app/services/thumbsgenerator.tsindex 6a5b3dc34..98ae74b7f 100644--- a/app/services/thumbsgenerator.ts+++ b/app/services/thumbsgenerator.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import EXIF from 'exif-js';diff --git a/app/services/utils-io.ts b/app/services/utils-io.tsindex 1918f2e6f..b3fb60d5d 100644--- a/app/services/utils-io.ts+++ b/app/services/utils-io.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import { saveAs } from 'file-saver';@@ -22,503 +21,503 @@ import uuidv1 from 'uuid';import PlatformIO from './platform-io';import AppConfig from '../config';import {- extractTagsAsObjects,- extractFileExtension,- cleanTrailingDirSeparator,- getMetaDirectoryPath,- getMetaFileLocationForFile,- getMetaFileLocationForDir,- extractContainingDirectoryPath+ extractTagsAsObjects,+ extractFileExtension,+ cleanTrailingDirSeparator,+ getMetaDirectoryPath,+ getMetaFileLocationForFile,+ getMetaFileLocationForDir,+ extractContainingDirectoryPath} from '../utils/paths';// import { formatDateTime4Tag } from '../utils/misc';import versionMeta from '../version.json';-import { type Tag } from '../reducers/taglibrary';+import { Tag } from '../reducers/taglibrary';export type FileSystemEntry = {- uuid: string,- name: string,- isFile: boolean,- extension: string,- thumbPath?: string,- color?: string,- textContent?: string,- description: string,- tags: Array<Tag>,- size: number,- lmdt: number,- path: string+ uuid: string;+ name: string;+ isFile: boolean;+ extension: string;+ thumbPath?: string;+ color?: string;+ textContent?: string;+ description: string;+ tags: Array<Tag>;+ size: number;+ lmdt: number;+ path: string;};export type FileSystemEntryMeta = {- description: string,- tags: Array<Tag>,- color?: string,- appVersionCreated: string,- appName: string,- appVersionUpdated: string,- lastUpdated: string+ description: string;+ tags: Array<Tag>;+ color?: string;+ appVersionCreated: string;+ appName: string;+ appVersionUpdated: string;+ lastUpdated: string;};export function enhanceEntry(entry: any): FileSystemEntry {- let fileNameTags = [];- if (entry.isFile) {- fileNameTags = extractTagsAsObjects(entry.name);- }- let sidecarDescription = '';- let sidecarColor = '';- let uuid;- let sidecarTags = [];- if (entry.meta) {- sidecarDescription = entry.meta.description || '';- sidecarColor = entry.meta.color || '';- sidecarTags = entry.meta.tags || [];- sidecarTags.map(tag => {- tag.type = 'sidecar';- return true;- });- uuid = entry.meta.uuid || undefined;- }- const enhancedEntry = {- uuid: uuid || uuidv1(),- name: entry.name,- isFile: entry.isFile,- extension: entry.isFile ? extractFileExtension(entry.name) : '',- thumbPath: entry.thumbPath,- description: sidecarDescription,- color: sidecarColor,- textContent: entry.textContent,- tags: [...sidecarTags, ...fileNameTags],- size: entry.size,- lmdt: entry.lmdt,- path: entry.path- };- // console.log('Enhancing ' + entry.path); console.log(enhancedEntry);- return enhancedEntry;+ let fileNameTags = [];+ if (entry.isFile) {+ fileNameTags = extractTagsAsObjects(entry.name);+ }+ let sidecarDescription = '';+ let sidecarColor = '';+ let uuid;+ let sidecarTags = [];+ if (entry.meta) {+ sidecarDescription = entry.meta.description || '';+ sidecarColor = entry.meta.color || '';+ sidecarTags = entry.meta.tags || [];+ sidecarTags.map(tag => {+ tag.type = 'sidecar';+ return true;+ });+ uuid = entry.meta.uuid || undefined;+ }+ const enhancedEntry = {+ uuid: uuid || uuidv1(),+ name: entry.name,+ isFile: entry.isFile,+ extension: entry.isFile ? extractFileExtension(entry.name) : '',+ thumbPath: entry.thumbPath,+ description: sidecarDescription,+ color: sidecarColor,+ textContent: entry.textContent,+ tags: [...sidecarTags, ...fileNameTags],+ size: entry.size,+ lmdt: entry.lmdt,+ path: entry.path+ };+ // console.log('Enhancing ' + entry.path); console.log(enhancedEntry);+ return enhancedEntry;}export function createDirectoryIndex(- directoryPath: string,- extractText: boolean = false+ directoryPath: string,+ extractText: boolean = false): Promise<Array<Object>> {- const dirPath = cleanTrailingDirSeparator(directoryPath);- if (PlatformIO.isWorkerAvailable() && !PlatformIO.haveObjectStoreSupport()) {- // Start indexing in worker if not in the object store mode- return PlatformIO.createDirectoryIndexInWorker(dirPath, extractText);- }+ const dirPath = cleanTrailingDirSeparator(directoryPath);+ if (PlatformIO.isWorkerAvailable() && !PlatformIO.haveObjectStoreSupport()) {+ // Start indexing in worker if not in the object store mode+ return PlatformIO.createDirectoryIndexInWorker(dirPath, extractText);+ }- return new Promise((resolve, reject) => {- setTimeout(() => {- const directoryIndex = [];- let counter = 0;- console.time('createDirectoryIndex');- walkDirectory(- dirPath,- {- recursive: true,- skipMetaFolder: true,- skipDotHiddenFolder: true,- extractText- },- fileEntry => {- counter += 1;- if (counter > AppConfig.indexerLimit) {- console.warn('Walk canceled by ' + AppConfig.indexerLimit);- window.walkCanceled = true;- }- directoryIndex.push(enhanceEntry(fileEntry));- },- directoryEntry => {- if (directoryEntry.name !== AppConfig.metaFolder) {- counter += 1;- directoryIndex.push(enhanceEntry(directoryEntry));- }- }- )- .then(() => {- // entries - can be used for further processing- window.walkCanceled = false;- console.log(- 'Directory index created ' +- dirPath +- ' containing ' +- directoryIndex.length- );- console.timeEnd('createDirectoryIndex');- resolve(directoryIndex);- return true;- })- .catch(err => {- window.walkCanceled = false;- console.timeEnd('createDirectoryIndex');- console.warn('Error creating index: ' + err);- reject(err);- });- }, 2000);- });+ return new Promise((resolve, reject) => {+ setTimeout(() => {+ const directoryIndex = [];+ let counter = 0;+ console.time('createDirectoryIndex');+ walkDirectory(+ dirPath,+ {+ recursive: true,+ skipMetaFolder: true,+ skipDotHiddenFolder: true,+ extractText+ },+ fileEntry => {+ counter += 1;+ if (counter > AppConfig.indexerLimit) {+ console.warn('Walk canceled by ' + AppConfig.indexerLimit);+ window.walkCanceled = true;+ }+ directoryIndex.push(enhanceEntry(fileEntry));+ },+ directoryEntry => {+ if (directoryEntry.name !== AppConfig.metaFolder) {+ counter += 1;+ directoryIndex.push(enhanceEntry(directoryEntry));+ }+ }+ )+ .then(() => {+ // entries - can be used for further processing+ window.walkCanceled = false;+ console.log(+ 'Directory index created ' ++ dirPath ++ ' containing ' ++ directoryIndex.length+ );+ console.timeEnd('createDirectoryIndex');+ resolve(directoryIndex);+ return true;+ })+ .catch(err => {+ window.walkCanceled = false;+ console.timeEnd('createDirectoryIndex');+ console.warn('Error creating index: ' + err);+ reject(err);+ });+ }, 2000);+ });}export function walkDirectory(- path: string,- options: Object = {},- fileCallback: any,- dirCallback: any+ path: string,+ options: Object = {},+ fileCallback: any,+ dirCallback: any) {- const mergedOptions = {- recursive: false,- skipMetaFolder: true,- skipDotHiddenFolder: false,- loadMetaDate: true,- extractText: false,- ...options- };- return PlatformIO.listDirectoryPromise(path, false, mergedOptions.extractText)- .then(entries => {- if (window.walkCanceled) {- return false;- }- return Promise.all(- entries.map(entry => {- if (window.walkCanceled) {- return false;- }+ const mergedOptions = {+ recursive: false,+ skipMetaFolder: true,+ skipDotHiddenFolder: false,+ loadMetaDate: true,+ extractText: false,+ ...options+ };+ return PlatformIO.listDirectoryPromise(path, false, mergedOptions.extractText)+ .then(entries => {+ if (window.walkCanceled) {+ return false;+ }+ return Promise.all(+ entries.map(entry => {+ if (window.walkCanceled) {+ return false;+ }- if (entry.isFile) {- if (fileCallback) {- fileCallback(entry);- }- return entry;- }+ if (entry.isFile) {+ if (fileCallback) {+ fileCallback(entry);+ }+ return entry;+ }- if (dirCallback) {- dirCallback(entry);- }+ if (dirCallback) {+ dirCallback(entry);+ }- if (mergedOptions.recursive) {- if (- mergedOptions.skipDotHiddenFolder &&- entry.name.startsWith('.')- ) {- return entry;- }- if (- mergedOptions.skipMetaFolder &&- entry.name === AppConfig.metaFolder- ) {- return entry;- }- return walkDirectory(- entry.path,- mergedOptions,- fileCallback,- dirCallback- );- }- return entry;- })- );- })- .catch(err => {- console.warn('Error walking directory ' + err);- return err;- });+ if (mergedOptions.recursive) {+ if (+ mergedOptions.skipDotHiddenFolder &&+ entry.name.startsWith('.')+ ) {+ return entry;+ }+ if (+ mergedOptions.skipMetaFolder &&+ entry.name === AppConfig.metaFolder+ ) {+ return entry;+ }+ return walkDirectory(+ entry.path,+ mergedOptions,+ fileCallback,+ dirCallback+ );+ }+ return entry;+ })+ );+ })+ .catch(err => {+ console.warn('Error walking directory ' + err);+ return err;+ });}export async function getAllPropertiesPromise(- entryPath: string+ entryPath: string): Promise<FileSystemEntry> {- const entryProps = await PlatformIO.getPropertiesPromise(entryPath);- let metaFilePath;- if (entryProps.isFile) {- metaFilePath = getMetaFileLocationForFile(entryPath);- } else {- metaFilePath = getMetaFileLocationForDir(entryPath);- }- const metaFileProps = await PlatformIO.getPropertiesPromise(metaFilePath);- if (metaFileProps.isFile) {- entryProps.meta = await loadJSONFile(metaFilePath);- }- return enhanceEntry(entryProps);+ const entryProps = await PlatformIO.getPropertiesPromise(entryPath);+ let metaFilePath;+ if (entryProps.isFile) {+ metaFilePath = getMetaFileLocationForFile(entryPath);+ } else {+ metaFilePath = getMetaFileLocationForDir(entryPath);+ }+ const metaFileProps = await PlatformIO.getPropertiesPromise(metaFilePath);+ if (metaFileProps.isFile) {+ entryProps.meta = await loadJSONFile(metaFilePath);+ }+ return enhanceEntry(entryProps);}export async function loadJSONFile(filePath: string): any {- let jsonObject;- let jsonContent = await PlatformIO.loadTextFilePromise(filePath);- const UTF8_BOM = '\ufeff';- if (jsonContent.indexOf(UTF8_BOM) === 0) {- jsonContent = jsonContent.substring(1, jsonContent.length);- }- try {- jsonObject = JSON.parse(jsonContent);- } catch (err) {- console.warn('Error parsing meta json file for ' + filePath + ' - ' + err);- }- return jsonObject;+ let jsonObject;+ let jsonContent = await PlatformIO.loadTextFilePromise(filePath);+ const UTF8_BOM = '\ufeff';+ if (jsonContent.indexOf(UTF8_BOM) === 0) {+ jsonContent = jsonContent.substring(1, jsonContent.length);+ }+ try {+ jsonObject = JSON.parse(jsonContent);+ } catch (err) {+ console.warn('Error parsing meta json file for ' + filePath + ' - ' + err);+ }+ return jsonObject;}export function saveAsTextFile(blob: any, filename: string) {- saveAs(blob, filename);+ saveAs(blob, filename);}export function openLinkExternally(uri: string) {- const decodedURI = decodeURIComponent(uri);- if (- decodedURI.startsWith('http://') ||- decodedURI.startsWith('https://') ||- decodedURI.startsWith('file://')- ) {- PlatformIO.openFile(decodedURI);- } else {- console.log('Not supported URL format: ' + decodedURI);- }+ const decodedURI = decodeURIComponent(uri);+ if (+ decodedURI.startsWith('http://') ||+ decodedURI.startsWith('https://') ||+ decodedURI.startsWith('file://')+ ) {+ PlatformIO.openFile(decodedURI);+ } else {+ console.log('Not supported URL format: ' + decodedURI);+ }}export function deleteFilesPromise(filePathList: Array<string>) {- const fileDeletionPromises = [];- filePathList.forEach(filePath => {- fileDeletionPromises.push(PlatformIO.deleteFilePromise(filePath));- });- return Promise.all(fileDeletionPromises);+ const fileDeletionPromises = [];+ filePathList.forEach(filePath => {+ fileDeletionPromises.push(PlatformIO.deleteFilePromise(filePath));+ });+ return Promise.all(fileDeletionPromises);}export function renameFilesPromise(renameJobs: Array<Array<string>>) {- const fileRenamePromises = [];- renameJobs.forEach(renameJob => {- fileRenamePromises.push(- PlatformIO.renameFilePromise(renameJob[0], renameJob[1])- );- });- return Promise.all(fileRenamePromises);+ const fileRenamePromises = [];+ renameJobs.forEach(renameJob => {+ fileRenamePromises.push(+ PlatformIO.renameFilePromise(renameJob[0], renameJob[1])+ );+ });+ return Promise.all(fileRenamePromises);}export function copyFilesPromise(copyJobs: Array<Array<string>>) {- const ioJobPromises = [];- copyJobs.forEach(copyJob => {- ioJobPromises.push(PlatformIO.copyFilePromise(copyJob[0], copyJob[1]));- });- return Promise.all(ioJobPromises);+ const ioJobPromises = [];+ copyJobs.forEach(copyJob => {+ ioJobPromises.push(PlatformIO.copyFilePromise(copyJob[0], copyJob[1]));+ });+ return Promise.all(ioJobPromises);}export async function loadSubFolders(- path: string,- loadHidden: boolean = false+ path: string,+ loadHidden: boolean = false) {- const folderContent = await PlatformIO.listDirectoryPromise(path, true);- const subfolders = [];- let i = 0;- let isHidden = false;- folderContent.map(entry => {- if (!entry.isFile) {- isHidden = entry.name.startsWith('.');- if (isHidden) {- if (loadHidden) {- subfolders.push({- key: '0-' + (i += 1),- isLeaf: false,- name: entry.name,- isFile: entry.isFile,- lmdt: entry.lmdt,- meta: entry.meta,- path: entry.path,- tags: entry.tags- });- } else {- // do nothing- }- } else {- subfolders.push({- key: '0-' + (i += 1),- isLeaf: false,- name: entry.name,- isFile: entry.isFile,- lmdt: entry.lmdt,- meta: entry.meta,- path: entry.path,- tags: entry.tags- });- }- }- return true;- });- return subfolders;+ const folderContent = await PlatformIO.listDirectoryPromise(path, true);+ const subfolders = [];+ let i = 0;+ let isHidden = false;+ folderContent.map(entry => {+ if (!entry.isFile) {+ isHidden = entry.name.startsWith('.');+ if (isHidden) {+ if (loadHidden) {+ subfolders.push({+ key: '0-' + (i += 1),+ isLeaf: false,+ name: entry.name,+ isFile: entry.isFile,+ lmdt: entry.lmdt,+ meta: entry.meta,+ path: entry.path,+ tags: entry.tags+ });+ } else {+ // do nothing+ }+ } else {+ subfolders.push({+ key: '0-' + (i += 1),+ isLeaf: false,+ name: entry.name,+ isFile: entry.isFile,+ lmdt: entry.lmdt,+ meta: entry.meta,+ path: entry.path,+ tags: entry.tags+ });+ }+ }+ return true;+ });+ return subfolders;}export function generateFileName(- fileName: string,- tags: Array<string>,- tagDelimiter: string+ fileName: string,+ tags: Array<string>,+ tagDelimiter: string) {- let tagsString = '';- const prefixTagContainer = AppConfig.prefixTagContainer;- // Creating the string will all the tags by more that 0 tags- if (tags && tags.length > 0) {- tagsString = AppConfig.beginTagContainer;- for (let i = 0; i < tags.length; i += 1) {- if (i === tags.length - 1) {- tagsString += tags[i].trim();- } else {- tagsString += tags[i].trim() + tagDelimiter;- }- }- tagsString = tagsString.trim() + AppConfig.endTagContainer;- }- // console.log('The tags string: ' + tagsString);- const fileExt = extractFileExtension(fileName);- // console.log('Filename: ' + fileName + ' file extension: ' + fileExt);- // Assembling the new filename with the tags- let newFileName = '';- const beginTagContainer = fileName.indexOf(AppConfig.beginTagContainer);- const endTagContainer = fileName.indexOf(AppConfig.endTagContainer);- const lastDotPosition = fileName.lastIndexOf('.');- if (- beginTagContainer < 0 ||- endTagContainer < 0 ||- beginTagContainer >= endTagContainer- ) {- // Filename does not contains tags.- if (lastDotPosition < 0) {- // File does not have an extension- newFileName = fileName.trim() + tagsString;- } else {- // File has an extension- newFileName =- fileName.substring(0, lastDotPosition).trim() +- prefixTagContainer +- tagsString +- '.' +- fileExt;- }- } else {- // File does not have an extension- newFileName =- fileName.substring(0, beginTagContainer).trim() +- prefixTagContainer +- tagsString +- fileName.substring(endTagContainer + 1, fileName.length).trim();- }- if (newFileName.length < 1) {- throw new Error('Generated filename is invalid');- }- // Removing double prefix- newFileName = newFileName- .split(prefixTagContainer + '' + prefixTagContainer)- .join(prefixTagContainer);- return newFileName;+ let tagsString = '';+ const prefixTagContainer = AppConfig.prefixTagContainer;+ // Creating the string will all the tags by more that 0 tags+ if (tags && tags.length > 0) {+ tagsString = AppConfig.beginTagContainer;+ for (let i = 0; i < tags.length; i += 1) {+ if (i === tags.length - 1) {+ tagsString += tags[i].trim();+ } else {+ tagsString += tags[i].trim() + tagDelimiter;+ }+ }+ tagsString = tagsString.trim() + AppConfig.endTagContainer;+ }+ // console.log('The tags string: ' + tagsString);+ const fileExt = extractFileExtension(fileName);+ // console.log('Filename: ' + fileName + ' file extension: ' + fileExt);+ // Assembling the new filename with the tags+ let newFileName = '';+ const beginTagContainer = fileName.indexOf(AppConfig.beginTagContainer);+ const endTagContainer = fileName.indexOf(AppConfig.endTagContainer);+ const lastDotPosition = fileName.lastIndexOf('.');+ if (+ beginTagContainer < 0 ||+ endTagContainer < 0 ||+ beginTagContainer >= endTagContainer+ ) {+ // Filename does not contains tags.+ if (lastDotPosition < 0) {+ // File does not have an extension+ newFileName = fileName.trim() + tagsString;+ } else {+ // File has an extension+ newFileName =+ fileName.substring(0, lastDotPosition).trim() ++ prefixTagContainer ++ tagsString ++ '.' ++ fileExt;+ }+ } else {+ // File does not have an extension+ newFileName =+ fileName.substring(0, beginTagContainer).trim() ++ prefixTagContainer ++ tagsString ++ fileName.substring(endTagContainer + 1, fileName.length).trim();+ }+ if (newFileName.length < 1) {+ throw new Error('Generated filename is invalid');+ }+ // Removing double prefix+ newFileName = newFileName+ .split(prefixTagContainer + '' + prefixTagContainer)+ .join(prefixTagContainer);+ return newFileName;}export async function loadMetaDataPromise(- path: string+ path: string): Promise<FileSystemEntryMeta> {- const entryProperties = await PlatformIO.getPropertiesPromise(path);- let metaDataObject;- if (entryProperties.isFile) {- const metaFilePath = getMetaFileLocationForFile(path);- const metaData = await loadJSONFile(metaFilePath);- metaDataObject = {- description: metaData.description || '',- color: metaData.color || '',- tags: metaData.tags || [],- appVersionCreated: metaData.appVersionCreated || '',- appName: metaData.appName || '',- appVersionUpdated: metaData.appVersionUpdated || '',- lastUpdated: metaData.lastUpdated || ''- };- } else {- const metaFilePath = getMetaFileLocationForDir(path);- const metaData = await loadJSONFile(metaFilePath);- metaDataObject = {- description: metaData.description || '',- color: metaData.color || '',- tags: metaData.tags || [],- appVersionCreated: metaData.appVersionCreated || '',- appName: metaData.appName || '',- appVersionUpdated: metaData.appVersionUpdated || '',- lastUpdated: metaData.lastUpdated || ''- };- }- return metaDataObject;+ const entryProperties = await PlatformIO.getPropertiesPromise(path);+ let metaDataObject;+ if (entryProperties.isFile) {+ const metaFilePath = getMetaFileLocationForFile(path);+ const metaData = await loadJSONFile(metaFilePath);+ metaDataObject = {+ description: metaData.description || '',+ color: metaData.color || '',+ tags: metaData.tags || [],+ appVersionCreated: metaData.appVersionCreated || '',+ appName: metaData.appName || '',+ appVersionUpdated: metaData.appVersionUpdated || '',+ lastUpdated: metaData.lastUpdated || ''+ };+ } else {+ const metaFilePath = getMetaFileLocationForDir(path);+ const metaData = await loadJSONFile(metaFilePath);+ metaDataObject = {+ description: metaData.description || '',+ color: metaData.color || '',+ tags: metaData.tags || [],+ appVersionCreated: metaData.appVersionCreated || '',+ appName: metaData.appName || '',+ appVersionUpdated: metaData.appVersionUpdated || '',+ lastUpdated: metaData.lastUpdated || ''+ };+ }+ return metaDataObject;}export async function saveMetaDataPromise(- path: string,- metaData: Object+ path: string,+ metaData: Object): Promise<any> {- const entryProperties = await PlatformIO.getPropertiesPromise(path);- let metaFilePath;- let newFsEntryMeta;+ const entryProperties = await PlatformIO.getPropertiesPromise(path);+ let metaFilePath;+ let newFsEntryMeta;- if (entryProperties.isFile) {- metaFilePath = getMetaFileLocationForFile(path);- // check and create meta folder if not exist- await PlatformIO.createDirectoryPromise(- extractContainingDirectoryPath(metaFilePath)- );+ if (entryProperties.isFile) {+ metaFilePath = getMetaFileLocationForFile(path);+ // check and create meta folder if not exist+ await PlatformIO.createDirectoryPromise(+ extractContainingDirectoryPath(metaFilePath)+ );- newFsEntryMeta = {- ...metaData,- appName: versionMeta.name,- appVersionUpdated: versionMeta.version,- lastUpdated: new Date().toJSON()- };- } else {- // check and create meta folder if not exist- // todo not need to check if folder exist first createDirectoryPromise() recursively will skip creation of existing folders https://nodejs.org/api/fs.html#fs_fs_mkdir_path_options_callback- const metaDirectoryPath = getMetaDirectoryPath(path);- const metaDirectoryProperties = await PlatformIO.getPropertiesPromise(- metaDirectoryPath- );- if (!metaDirectoryProperties) {- await PlatformIO.createDirectoryPromise(metaDirectoryPath);- }+ newFsEntryMeta = {+ ...metaData,+ appName: versionMeta.name,+ appVersionUpdated: versionMeta.version,+ lastUpdated: new Date().toJSON()+ };+ } else {+ // check and create meta folder if not exist+ // todo not need to check if folder exist first createDirectoryPromise() recursively will skip creation of existing folders https://nodejs.org/api/fs.html#fs_fs_mkdir_path_options_callback+ const metaDirectoryPath = getMetaDirectoryPath(path);+ const metaDirectoryProperties = await PlatformIO.getPropertiesPromise(+ metaDirectoryPath+ );+ if (!metaDirectoryProperties) {+ await PlatformIO.createDirectoryPromise(metaDirectoryPath);+ }- metaFilePath = getMetaFileLocationForDir(path);- newFsEntryMeta = {- ...metaData,- appName: versionMeta.name,- appVersionUpdated: versionMeta.version,- lastUpdated: new Date().toJSON()- };- }- const content = JSON.stringify(newFsEntryMeta);- return PlatformIO.saveTextFilePromise(metaFilePath, content, true);+ metaFilePath = getMetaFileLocationForDir(path);+ newFsEntryMeta = {+ ...metaData,+ appName: versionMeta.name,+ appVersionUpdated: versionMeta.version,+ lastUpdated: new Date().toJSON()+ };+ }+ const content = JSON.stringify(newFsEntryMeta);+ return PlatformIO.saveTextFilePromise(metaFilePath, content, true);}export function findColorForFileEntry(- fileExtension: string,- isFile: boolean,- supportedFileTypes: Array<Object>+ fileExtension: string,+ isFile: boolean,+ supportedFileTypes: Array<Object>): string {- if (!isFile) {- return AppConfig.defaultFolderColor;- }- let color = AppConfig.defaultFileColor;- supportedFileTypes.map(fileType => {- if (fileType.type.toLowerCase() === fileExtension.toLowerCase()) {- if (fileType.color) {- color = fileType.color;- }- }- return true;- });- return color;+ if (!isFile) {+ return AppConfig.defaultFolderColor;+ }+ let color = AppConfig.defaultFileColor;+ supportedFileTypes.map(fileType => {+ if (fileType.type.toLowerCase() === fileExtension.toLowerCase()) {+ if (fileType.color) {+ color = fileType.color;+ }+ }+ return true;+ });+ return color;}export function loadFileContentPromise(- fullPath: string,- type: string+ fullPath: string,+ type: string): Promise<any> {- return new Promise((resolve, reject) => {- const xhr = new XMLHttpRequest();- xhr.open('GET', fullPath, true);- xhr.responseType = type || 'arraybuffer';- xhr.onerror = reject;- xhr.onload = () => {- const response = xhr.response || xhr.responseText;- if (response) {- resolve(response);- } else {- reject('loadFileContentPromise error');- }- };- xhr.send();- });+ return new Promise((resolve, reject) => {+ const xhr = new XMLHttpRequest();+ xhr.open('GET', fullPath, true);+ xhr.responseType = type || 'arraybuffer';+ xhr.onerror = reject;+ xhr.onload = () => {+ const response = xhr.response || xhr.responseText;+ if (response) {+ resolve(response);+ } else {+ reject('loadFileContentPromise error');+ }+ };+ xhr.send();+ });}diff --git a/app/services/webdav-io.ts b/app/services/webdav-io.tsindex 88d7db758..fe533ea13 100644--- a/app/services/webdav-io.ts+++ b/app/services/webdav-io.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import nl from 'js-webdav-client';diff --git a/app/splash-worker.ts b/app/splash-worker.tsindex 0b5c9c920..a296f0bf5 100644--- a/app/splash-worker.ts+++ b/app/splash-worker.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import { ipcRenderer } from 'electron';diff --git a/app/store/configureStore.dev.ts b/app/store/configureStore.dev.tsindex cbb4299df..4eb7c28e4 100644--- a/app/store/configureStore.dev.ts+++ b/app/store/configureStore.dev.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import { createStore, applyMiddleware, compose } from 'redux';diff --git a/app/store/configureStore.prod.ts b/app/store/configureStore.prod.tsindex 9e336e78c..42a96711b 100644--- a/app/store/configureStore.prod.ts+++ b/app/store/configureStore.prod.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/import { compose, createStore, applyMiddleware } from 'redux';diff --git a/app/store/configureStore.ts b/app/store/configureStore.tsindex 2b1c84421..a23279dd7 100644--- a/app/store/configureStore.ts+++ b/app/store/configureStore.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*/if (process.env.NODE_ENV === 'production') {diff --git a/app/utils/dates.ts b/app/utils/dates.tsindex cb8a5f50a..2b9b916af 100644--- a/app/utils/dates.ts+++ b/app/utils/dates.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*//** Returns true if the input is one of the following formats:diff --git a/app/utils/misc.ts b/app/utils/misc.tsindex edd6c3392..478509af5 100644--- a/app/utils/misc.ts+++ b/app/utils/misc.ts@@ -14,7 +14,6 @@* 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/>.*- * @flow*//** Returns true is a string is plus code e.g. 8FWH4HVG+3V 8FWH4HVG+ 8FWH4H+ */diff --git a/app/utils/paths.ts b/app/utils/paths.tsindex 487e38a18..58577b0bd 100644--- a/app/utils/paths.ts+++ b/app/utils/paths.ts@@ -14,118 +14,117 @@* 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/>.*- * @flow*/import AppConfig from '../config';-import { type Tag } from '../reducers/taglibrary';+import { Tag } from '../reducers/taglibrary';export function baseName(dirPath: string) {- const fileName = dirPath.substring(- dirPath.lastIndexOf(AppConfig.dirSeparator) + 1,- dirPath.length- );- return fileName || dirPath;+ const fileName = dirPath.substring(+ dirPath.lastIndexOf(AppConfig.dirSeparator) + 1,+ dirPath.length+ );+ return fileName || dirPath;}export function extractFileExtension(filePath: string) {- const lastindexDirSeparator = filePath.lastIndexOf(AppConfig.dirSeparator);- const lastIndexEndTagContainer = filePath.lastIndexOf(- AppConfig.endTagContainer- );- const lastindexDot = filePath.lastIndexOf('.');- if (lastindexDot < 0) {- return '';- } else if (lastindexDot < lastindexDirSeparator) {- // case: "../remote.php/webdav/somefilename"- return '';- } else if (lastindexDot < lastIndexEndTagContainer) {- // case: "[20120125 89.4kg 19.5% 60.5% 39.8% 2.6kg]"- return '';- }- let extension = filePath- .substring(lastindexDot + 1, filePath.length)- .toLowerCase()- .trim();- const lastindexQuestionMark = extension.lastIndexOf('?');- if (lastindexQuestionMark > 0) {- // Removing everything after ? in URLs .png?queryParam1=2342- extension = extension.substring(0, lastindexQuestionMark);- }- return extension;+ const lastindexDirSeparator = filePath.lastIndexOf(AppConfig.dirSeparator);+ const lastIndexEndTagContainer = filePath.lastIndexOf(+ AppConfig.endTagContainer+ );+ const lastindexDot = filePath.lastIndexOf('.');+ if (lastindexDot < 0) {+ return '';+ } else if (lastindexDot < lastindexDirSeparator) {+ // case: "../remote.php/webdav/somefilename"+ return '';+ } else if (lastindexDot < lastIndexEndTagContainer) {+ // case: "[20120125 89.4kg 19.5% 60.5% 39.8% 2.6kg]"+ return '';+ }+ let extension = filePath+ .substring(lastindexDot + 1, filePath.length)+ .toLowerCase()+ .trim();+ const lastindexQuestionMark = extension.lastIndexOf('?');+ if (lastindexQuestionMark > 0) {+ // Removing everything after ? in URLs .png?queryParam1=2342+ extension = extension.substring(0, lastindexQuestionMark);+ }+ return extension;- /* alternative implementation+ /* alternative implementationconst ext = fileURL.split('.').pop();return (ext === fileURL) ? '' : ext; */}export function getMetaDirectoryPath(- directoryPath: string,- dirSeparator: string = AppConfig.dirSeparator+ directoryPath: string,+ dirSeparator: string = AppConfig.dirSeparator) {- return normalizePath(directoryPath) + dirSeparator + AppConfig.metaFolder;+ return normalizePath(directoryPath) + dirSeparator + AppConfig.metaFolder;}export function getMetaFileLocationForFile(- entryPath: string,- dirSeparator: string = AppConfig.dirSeparator+ entryPath: string,+ dirSeparator: string = AppConfig.dirSeparator) {- const containingFolder = extractContainingDirectoryPath(- entryPath,- dirSeparator- );- const metaFolder = getMetaDirectoryPath(containingFolder, dirSeparator);- return (- metaFolder +- dirSeparator +- extractFileName(entryPath, dirSeparator) +- AppConfig.metaFileExt- );+ const containingFolder = extractContainingDirectoryPath(+ entryPath,+ dirSeparator+ );+ const metaFolder = getMetaDirectoryPath(containingFolder, dirSeparator);+ return (+ metaFolder ++ dirSeparator ++ extractFileName(entryPath, dirSeparator) ++ AppConfig.metaFileExt+ );}export function getThumbFileLocationForFile(- entryPath: string,- dirSeparator: string = AppConfig.dirSeparator+ entryPath: string,+ dirSeparator: string = AppConfig.dirSeparator) {- const containingFolder = extractContainingDirectoryPath(- entryPath,- dirSeparator- );- const metaFolder = getMetaDirectoryPath(containingFolder, dirSeparator);- return (- metaFolder +- dirSeparator +- extractFileName(entryPath, dirSeparator) +- AppConfig.thumbFileExt- );+ const containingFolder = extractContainingDirectoryPath(+ entryPath,+ dirSeparator+ );+ const metaFolder = getMetaDirectoryPath(containingFolder, dirSeparator);+ return (+ metaFolder ++ dirSeparator ++ extractFileName(entryPath, dirSeparator) ++ AppConfig.thumbFileExt+ );}export function getMetaFileLocationForDir(entryPath: string) {- const metaFolder = getMetaDirectoryPath(entryPath);- return metaFolder + AppConfig.dirSeparator + AppConfig.metaFolderFile;+ const metaFolder = getMetaDirectoryPath(entryPath);+ return metaFolder + AppConfig.dirSeparator + AppConfig.metaFolderFile;}export function extractFileName(- filePath: string,- dirSeparator: string = AppConfig.dirSeparator+ filePath: string,+ dirSeparator: string = AppConfig.dirSeparator): string {- return filePath.substring(- filePath.lastIndexOf(dirSeparator) + 1,- filePath.length- );+ return filePath.substring(+ filePath.lastIndexOf(dirSeparator) + 1,+ filePath.length+ );}export function cleanTrailingDirSeparator(dirPath: string): string {- if (dirPath) {- if (dirPath.lastIndexOf('\\') === dirPath.length - 1) {- return dirPath.substring(0, dirPath.length - 1);- } else if (dirPath.lastIndexOf('/') === dirPath.length - 1) {- return dirPath.substring(0, dirPath.length - 1);- }- return dirPath;- }- // console.log('Directory Path ' + dirPath + ' undefined');- return '';+ if (dirPath) {+ if (dirPath.lastIndexOf('\\') === dirPath.length - 1) {+ return dirPath.substring(0, dirPath.length - 1);+ } else if (dirPath.lastIndexOf('/') === dirPath.length - 1) {+ return dirPath.substring(0, dirPath.length - 1);+ }+ return dirPath;+ }+ // console.log('Directory Path ' + dirPath + ' undefined');+ return '';}/**@@ -134,176 +133,176 @@ export function cleanTrailingDirSeparator(dirPath: string): string {* @returns {string} -> root/subFolder*/export function normalizePath(path: string): string {- return cleanTrailingDirSeparator(path.replace(/\/\//g, '/'));+ return cleanTrailingDirSeparator(path.replace(/\/\//g, '/'));}export function extractFileNameWithoutExt(filePath: string): string {- const fileName = extractFileName(filePath);- const indexOfDot = fileName.lastIndexOf('.');- const lastIndexBeginTagContainer = fileName.lastIndexOf(- AppConfig.beginTagContainer- );- const lastIndexEndTagContainer = fileName.lastIndexOf(- AppConfig.endTagContainer- );- if (- lastIndexBeginTagContainer === 0 &&- lastIndexEndTagContainer + 1 === fileName.length- ) {- // case: "[tag1 tag.2]"- return '';- } else if (indexOfDot > 0) {- // case: regular- return fileName.substring(0, indexOfDot);- } else if (indexOfDot === 0) {- // case ".txt"- return '';- }- return fileName;+ const fileName = extractFileName(filePath);+ const indexOfDot = fileName.lastIndexOf('.');+ const lastIndexBeginTagContainer = fileName.lastIndexOf(+ AppConfig.beginTagContainer+ );+ const lastIndexEndTagContainer = fileName.lastIndexOf(+ AppConfig.endTagContainer+ );+ if (+ lastIndexBeginTagContainer === 0 &&+ lastIndexEndTagContainer + 1 === fileName.length+ ) {+ // case: "[tag1 tag.2]"+ return '';+ } else if (indexOfDot > 0) {+ // case: regular+ return fileName.substring(0, indexOfDot);+ } else if (indexOfDot === 0) {+ // case ".txt"+ return '';+ }+ return fileName;}export function extractContainingDirectoryPath(- filePath: string,- dirSeparator: string = AppConfig.dirSeparator+ filePath: string,+ dirSeparator: string = AppConfig.dirSeparator) {- return filePath.substring(0, filePath.lastIndexOf(dirSeparator));+ return filePath.substring(0, filePath.lastIndexOf(dirSeparator));}export function extractParentDirectoryPath(- dirPath: string,- dirSeparator: string = AppConfig.dirSeparator+ dirPath: string,+ dirSeparator: string = AppConfig.dirSeparator) {- if (!dirPath) return;- let path = dirPath;- if (path.endsWith(dirSeparator)) {- path = path.substring(0, path.lastIndexOf(dirSeparator));- }- return path.substring(0, path.lastIndexOf(dirSeparator));+ if (!dirPath) return;+ let path = dirPath;+ if (path.endsWith(dirSeparator)) {+ path = path.substring(0, path.lastIndexOf(dirSeparator));+ }+ return path.substring(0, path.lastIndexOf(dirSeparator));}export function extractDirectoryName(- dirPath: string,- dirSeparator: string = AppConfig.dirSeparator+ dirPath: string,+ dirSeparator: string = AppConfig.dirSeparator): string {- if (!dirPath) return '';- let directoryName;- if (dirPath.endsWith(dirSeparator)) {- directoryName = dirPath.substring(0, dirPath.lastIndexOf(dirSeparator));- }- directoryName = dirPath.substring(- dirPath.lastIndexOf(dirSeparator) + 1,- dirPath.length- );- return directoryName;+ if (!dirPath) return '';+ let directoryName;+ if (dirPath.endsWith(dirSeparator)) {+ directoryName = dirPath.substring(0, dirPath.lastIndexOf(dirSeparator));+ }+ directoryName = dirPath.substring(+ dirPath.lastIndexOf(dirSeparator) + 1,+ dirPath.length+ );+ return directoryName;}export function extractShortDirectoryName(- dirPath: string,- dirSeparator: string = AppConfig.dirSeparator+ dirPath: string,+ dirSeparator: string = AppConfig.dirSeparator) {- let shortDirName: string = extractDirectoryName(dirPath, dirSeparator);- if (shortDirName.length > 20) {- shortDirName = shortDirName.substr(0, 20) + '...';- }- return shortDirName;+ let shortDirName: string = extractDirectoryName(dirPath, dirSeparator);+ if (shortDirName.length > 20) {+ shortDirName = shortDirName.substr(0, 20) + '...';+ }+ return shortDirName;}export function extractContainingDirectoryName(filePath: string) {- const tmpStr = filePath.substring(- 0,- filePath.lastIndexOf(AppConfig.dirSeparator)- );- return tmpStr.substring(- tmpStr.lastIndexOf(AppConfig.dirSeparator) + 1,- tmpStr.length- );+ const tmpStr = filePath.substring(+ 0,+ filePath.lastIndexOf(AppConfig.dirSeparator)+ );+ return tmpStr.substring(+ tmpStr.lastIndexOf(AppConfig.dirSeparator) + 1,+ tmpStr.length+ );}export function extractTitle(entryPath: string, isDirectory?: boolean = false) {- let title;- if (isDirectory) {- title = extractDirectoryName(entryPath);- return title;- }- title = extractFileNameWithoutExt(entryPath);+ let title;+ if (isDirectory) {+ title = extractDirectoryName(entryPath);+ return title;+ }+ title = extractFileNameWithoutExt(entryPath);- const beginTagContainer = title.indexOf(AppConfig.beginTagContainer);- const endTagContainer = title.lastIndexOf(AppConfig.endTagContainer);- /* cases like "", "t", "["+ const beginTagContainer = title.indexOf(AppConfig.beginTagContainer);+ const endTagContainer = title.lastIndexOf(AppConfig.endTagContainer);+ /* cases like "", "t", "["if( fileName.length <= 1) {// cases like "asd ] asd ["else if (beginTagContainer > endTagContainer) {// case: [ not found in the filenameelse if ( beginTagContainer < 0 )else if ( endTagContainer < 0 ) */- if (beginTagContainer >= 0 && beginTagContainer < endTagContainer) {- if (beginTagContainer === 0 && endTagContainer === title.trim().length) {- // case: "[tag1, tag2]"- return '';- } else if (endTagContainer === title.trim().length) {- // case: "asd[tag1, tag2]"- return title.slice(0, beginTagContainer);- }- // case: "title1 [tag1 tag2] title2"- return (- title.slice(0, beginTagContainer) +- title.slice(endTagContainer + 1, title.length)- );- }- try {- title = decodeURIComponent(title);- } catch (e) {- console.warn('Decoding URI failed on: ' + title + ' with ' + e);- }- return title;+ if (beginTagContainer >= 0 && beginTagContainer < endTagContainer) {+ if (beginTagContainer === 0 && endTagContainer === title.trim().length) {+ // case: "[tag1, tag2]"+ return '';+ } else if (endTagContainer === title.trim().length) {+ // case: "asd[tag1, tag2]"+ return title.slice(0, beginTagContainer);+ }+ // case: "title1 [tag1 tag2] title2"+ return (+ title.slice(0, beginTagContainer) ++ title.slice(endTagContainer + 1, title.length)+ );+ }+ try {+ title = decodeURIComponent(title);+ } catch (e) {+ console.warn('Decoding URI failed on: ' + title + ' with ' + e);+ }+ return title;}export function extractTagsAsObjects(- filePath: string,- tagDelimiter?: string+ filePath: string,+ tagDelimiter?: string): Array<Tag> {- const tagsInFileName = extractTags(filePath, tagDelimiter);- const tagArray = [];- tagsInFileName.map(tag => {- tagArray.push({- title: '' + tag,- type: 'plain'- });- return true;- });- return tagArray;+ const tagsInFileName = extractTags(filePath, tagDelimiter);+ const tagArray = [];+ tagsInFileName.map(tag => {+ tagArray.push({+ title: '' + tag,+ type: 'plain'+ });+ return true;+ });+ return tagArray;}export function extractTags(filePath: string, tagDelimiter?: string) {- if (tagDelimiter === undefined) {- // TODO get tagDelimiter from settings reducer only- // eslint-disable-next-line no-param-reassign- tagDelimiter = AppConfig.tagDelimiter;- }- // console.log('Extracting tags from: ' + filePath);- const fileName = extractFileName(filePath);- // WithoutExt- let tags = [];- const beginTagContainer = fileName.indexOf(AppConfig.beginTagContainer);- const endTagContainer = fileName.indexOf(AppConfig.endTagContainer);- if (- beginTagContainer < 0 ||- endTagContainer < 0 ||- beginTagContainer >= endTagContainer- ) {- // console.log('Filename does not contains tags. Aborting extraction.');- return tags;- }- const cleanedTags = [];- const tagContainer = fileName- .slice(beginTagContainer + 1, endTagContainer)- .trim();- tags = tagContainer.split(tagDelimiter);- for (let i = 0; i < tags.length; i += 1) {- // Min tag length set to 1 character- if (tags[i].trim().length > 0) {- cleanedTags.push(tags[i]);- }- }- return cleanedTags;+ if (tagDelimiter === undefined) {+ // TODO get tagDelimiter from settings reducer only+ // eslint-disable-next-line no-param-reassign+ tagDelimiter = AppConfig.tagDelimiter;+ }+ // console.log('Extracting tags from: ' + filePath);+ const fileName = extractFileName(filePath);+ // WithoutExt+ let tags = [];+ const beginTagContainer = fileName.indexOf(AppConfig.beginTagContainer);+ const endTagContainer = fileName.indexOf(AppConfig.endTagContainer);+ if (+ beginTagContainer < 0 ||+ endTagContainer < 0 ||+ beginTagContainer >= endTagContainer+ ) {+ // console.log('Filename does not contains tags. Aborting extraction.');+ return tags;+ }+ const cleanedTags = [];+ const tagContainer = fileName+ .slice(beginTagContainer + 1, endTagContainer)+ .trim();+ tags = tagContainer.split(tagDelimiter);+ for (let i = 0; i < tags.length; i += 1) {+ // Min tag length set to 1 character+ if (tags[i].trim().length > 0) {+ cleanedTags.push(tags[i]);+ }+ }+ return cleanedTags;}