TagSpaces is an offline, open source, document manager with tagging support
fix: taking isreadonly mode for a location into account for enabling the apply tag functionality
Ilian Sapundshievc7cfab21eed1
diff --git a/app/components/TagLibrary.tsx b/app/components/TagLibrary.tsxindex ef5bc6532..ee30f4ff1 100644--- a/app/components/TagLibrary.tsx+++ b/app/components/TagLibrary.tsx@@ -305,6 +305,7 @@ const TagLibrary = (props: Props) => {classes,allTags,showNotification,+ isReadOnlyMode,reduceHeightBy} = props;@@ -415,6 +416,7 @@ const TagLibrary = (props: Props) => {onClose={() => setTagMenuAnchorEl(null)}showEditTagDialog={() => setIsEditTagDialogOpened(true)}showDeleteTagDialog={() => setIsDeleteTagDialogOpened(true)}+ isReadOnlyMode={isReadOnlyMode}selectedTag={selectedTag}/>)}diff --git a/app/components/menus/TagMenu.tsx b/app/components/menus/TagMenu.tsxindex d45193285..e7de6fda3 100644--- a/app/components/menus/TagMenu.tsx+++ b/app/components/menus/TagMenu.tsx@@ -47,6 +47,7 @@ interface Props {showDeleteTagDialog: () => void;maxSearchResults: number;selectedEntries: Array<any>;+ isReadOnlyMode: boolean;addTags: (paths: Array<string>,tags: Array<TS.Tag>,@@ -55,36 +56,48 @@ interface Props {}const TagMenu = (props: Props) => {+ const {+ isReadOnlyMode,+ selectedTag,+ setSearchQuery,+ onClose,+ showEditTagDialog,+ maxSearchResults,+ selectedEntries,+ addTags,+ anchorEl,+ open+ } = props;+function showFilesWithThisTag() {- if (props.selectedTag) {- // props.openSearchPanel();- props.setSearchQuery({- tagsAND: [props.selectedTag],- maxSearchResults: props.maxSearchResults+ if (selectedTag) {+ setSearchQuery({+ tagsAND: [selectedTag],+ maxSearchResults: maxSearchResults});}- props.onClose();+ onClose();}- function showEditTagDialog() {- props.onClose();- props.showEditTagDialog();+ function showEditTagMenuDialog() {+ onClose();+ showEditTagDialog();}function showDeleteTagDialog() {- props.onClose();- props.showDeleteTagDialog();+ onClose();+ showDeleteTagDialog();}function applyTag() {- const selectedEntryPaths = props.selectedEntries.map(entry => entry.path);- props.addTags(selectedEntryPaths, [props.selectedTag]);- props.onClose();+ const selectedEntryPaths = selectedEntries.map(entry => entry.path);+ addTags(selectedEntryPaths, [selectedTag]);+ onClose();}return (<div style={{ overflowY: 'hidden' }}>- <Menu anchorEl={props.anchorEl} open={props.open} onClose={props.onClose}>+ <Menu anchorEl={anchorEl} open={open} onClose={onClose}><MenuItemdata-tid="showFilesWithThisTag"onClick={showFilesWithThisTag}@@ -94,7 +107,7 @@ const TagMenu = (props: Props) => {</ListItemIcon><ListItemText primary={i18n.t('core:showFilesWithThisTag')} /></MenuItem>- {props.selectedEntries && props.selectedEntries.length > 0 && (+ {selectedEntries && selectedEntries.length > 0 && !isReadOnlyMode && (<MenuItem data-tid="applyTagTID" onClick={applyTag}><ListItemIcon><ApplyTagIcon />@@ -103,7 +116,7 @@ const TagMenu = (props: Props) => {</MenuItem>)}{!isTagLibraryReadOnly && (- <MenuItem data-tid="editTagDialog" onClick={showEditTagDialog}>+ <MenuItem data-tid="editTagDialog" onClick={showEditTagMenuDialog}><ListItemIcon><Edit /></ListItemIcon>