Skip to content

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

implementing configurable readonly mode for taglibrary and locations

Ilian Sapundshiev8c45f9b17da3
diff --git a/app/components/LocationManager.js b/app/components/LocationManager.js
index ab254c2a3..2232377c8 100644
--- a/app/components/LocationManager.js
+++ b/app/components/LocationManager.js
@@ -69,6 +69,8 @@ import TargetMoveFileBox from './TargetMoveFileBox';
import DragItemTypes from './DragItemTypes';
import IOActions from '../reducers/io-actions';
+const isLocationsReadOnly = window.ExtLocationsReadOnly;
+
type Props = {
classes: Object,
locations: Array<Location>,
@@ -616,20 +618,22 @@ class LocationManager extends React.Component<Props, State> {
{location.name}
</Typography>
</div>
- <ListItemSecondaryAction>
- <IconButton
- aria-label={i18n.t('core:options')}
- aria-haspopup="true"
- data-tid={'locationMoreButton_' + location.name}
- onClick={event => this.handleLocationContextMenuClick(event, location)}
- onContextMenu={event => this.handleLocationContextMenuClick(event, location)}
- >
- {location.isDefault && (
- <DefaultLocationIcon data-tid="startupIndication" />
- )}
- <MoreVertIcon />
- </IconButton>
- </ListItemSecondaryAction>
+ { !isLocationsReadOnly && (
+ <ListItemSecondaryAction>
+ <IconButton
+ aria-label={i18n.t('core:options')}
+ aria-haspopup="true"
+ data-tid={'locationMoreButton_' + location.name}
+ onClick={event => this.handleLocationContextMenuClick(event, location)}
+ onContextMenu={event => this.handleLocationContextMenuClick(event, location)}
+ >
+ {location.isDefault && (
+ <DefaultLocationIcon data-tid="startupIndication" />
+ )}
+ <MoreVertIcon />
+ </IconButton>
+ </ListItemSecondaryAction>
+ )}
</ListItem>
{table}
</div>
@@ -646,21 +650,23 @@ class LocationManager extends React.Component<Props, State> {
{i18n.t('core:locationManager')}
</Typography>
</div>
- <div style={{ width: '100%', textAlign: 'center', marginBottom: 10 }}>
- <Button
- data-tid="createNewLocation"
- onClick={this.showCreateLocationDialog}
- title={i18n.t('core:createLocationTitle')}
- className={classes.mainActionButton}
- size="small"
- variant="outlined"
- color="primary"
- style={{ width: '95%' }}
- >
- {/* <CreateLocationIcon className={classNames(classes.leftIcon)} /> */}
- {i18n.t('core:createLocationTitle')}
- </Button>
- </div>
+ { !isLocationsReadOnly && (
+ <div style={{ width: '100%', textAlign: 'center', marginBottom: 10 }}>
+ <Button
+ data-tid="createNewLocation"
+ onClick={this.showCreateLocationDialog}
+ title={i18n.t('core:createLocationTitle')}
+ className={classes.mainActionButton}
+ size="small"
+ variant="outlined"
+ color="primary"
+ style={{ width: '95%' }}
+ >
+ {/* <CreateLocationIcon className={classNames(classes.leftIcon)} /> */}
+ {i18n.t('core:createLocationTitle')}
+ </Button>
+ </div>
+ )}
<div>
<CreateLocationDialog
key={this.state.createLocationDialogKey}
diff --git a/app/components/TagLibrary.js b/app/components/TagLibrary.js
index 885df81bd..43e7e61c9 100644
--- a/app/components/TagLibrary.js
+++ b/app/components/TagLibrary.js
@@ -56,6 +56,8 @@ import i18n from '../services/i18n';
import { getTagColor, getTagTextColor } from '../reducers/settings';
import { getSelectedEntries, isReadOnlyMode } from '../reducers/app';
+const isTagLibraryReadOnly = (window.ExtTagLibrary && window.ExtTagLibrary.length > 0);
+
type Props = {
classes: Object,
style: Object,
@@ -232,24 +234,25 @@ class TagLibrary extends React.Component<Props, State> {
<span className={this.props.classes.badge}>{tagGroup.children.length}</span>
)}
</Typography>
- <ListItemSecondaryAction>
- <IconButton
- aria-label={i18n.t('core:options')}
- aria-haspopup="true"
- data-tid={'tagLibraryMoreButton_' + tagGroup.title.replace(/ /g,'_')}
- style={{ marginRight: -4 }}
- onClick={event => this.handleTagGroupMenu(event, tagGroup)}
- onContextMenu={event => this.handleTagGroupMenu(event, tagGroup)}
- >
- <MoreVertIcon />
- </IconButton>
- </ListItemSecondaryAction>
+ { !isTagLibraryReadOnly && (
+ <ListItemSecondaryAction>
+ <IconButton
+ aria-label={i18n.t('core:options')}
+ aria-haspopup="true"
+ data-tid={'tagLibraryMoreButton_' + tagGroup.title.replace(/ /g,'_')}
+ style={{ marginRight: -4 }}
+ 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) => {
- const isReadOnly = this.props.isReadOnlyMode;
- return isReadOnly ? (
+ return (this.props.isReadOnlyMode || isTagLibraryReadOnly) ? (
<TagContainer
key={tag.id}
tag={tag}
@@ -290,13 +293,15 @@ class TagLibrary extends React.Component<Props, State> {
>
{i18n.t('core:tagLibrary')}
</Typography>
- <IconButton
- style={{ paddingTop: 0 }}
- data-tid="tagLibraryMenu"
- onClick={this.handleTagLibraryMenu}
- >
- <MoreVertIcon />
- </IconButton>
+ { !isTagLibraryReadOnly && (
+ <IconButton
+ style={{ paddingTop: 0 }}
+ data-tid="tagLibraryMenu"
+ onClick={this.handleTagLibraryMenu}
+ >
+ <MoreVertIcon />
+ </IconButton>
+ )}
</div>
<ConfirmDialog
open={this.state.isDeleteTagGroupDialogOpened}
diff --git a/app/components/menus/TagMenu.js b/app/components/menus/TagMenu.js
index 3c9f39bf1..d1eebcc37 100644
--- a/app/components/menus/TagMenu.js
+++ b/app/components/menus/TagMenu.js
@@ -36,6 +36,8 @@ import { type SearchQuery } from '../../services/search';
import { getMaxSearchResults } from '../../reducers/settings';
import { AppVerticalPanels } from '../VerticalNavigation';
+const isTagLibraryReadOnly = (window.ExtTagLibrary && window.ExtTagLibrary.length > 0);
+
type Props = {
anchorEl?: Object,
open?: boolean,
@@ -109,21 +111,25 @@ const TagLibraryMenu = (props: Props) => {
</ListItemIcon>
<ListItemText inset primary={i18n.t('core:showFilesWithThisTag')} />
</MenuItem>
- <MenuItem data-tid="editTagDialog" onClick={showEditTagDialog}>
- <ListItemIcon>
- <Edit />
- </ListItemIcon>
- <ListItemText inset primary={i18n.t('core:editTag')} />
- </MenuItem>
- <MenuItem data-tid="deleteTagDialog" onClick={showDeleteTagDialog}>
- <ListItemIcon>
- <DeleteIcon />
- </ListItemIcon>
- <ListItemText
- inset
- primary={i18n.t('core:deleteTagFromTagGroup')}
- />
- </MenuItem>
+ {!isTagLibraryReadOnly && (
+ <MenuItem data-tid="editTagDialog" onClick={showEditTagDialog}>
+ <ListItemIcon>
+ <Edit />
+ </ListItemIcon>
+ <ListItemText inset primary={i18n.t('core:editTag')} />
+ </MenuItem>
+ )}
+ {!isTagLibraryReadOnly && (
+ <MenuItem data-tid="deleteTagDialog" onClick={showDeleteTagDialog}>
+ <ListItemIcon>
+ <DeleteIcon />
+ </ListItemIcon>
+ <ListItemText
+ inset
+ primary={i18n.t('core:deleteTagFromTagGroup')}
+ />
+ </MenuItem>
+ )}
</Menu>
<EditTagDialog
open={isEditTagDialogOpened}