Skip to content

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

Cannot collapse the Smart Tags group (#1246)

Stanimir9e6ce869f259
diff --git a/app/components/TagLibrary.tsx b/app/components/TagLibrary.tsx
index 96567bfef..586f651ab 100644
--- a/app/components/TagLibrary.tsx
+++ b/app/components/TagLibrary.tsx
@@ -53,7 +53,11 @@ import {
} from '../reducers/taglibrary';
import TaggingActions from '../reducers/tagging-actions';
import i18n from '../services/i18n';
-import { getTagColor, getTagTextColor } from '../reducers/settings';
+import {
+ actions as SettingsActions,
+ getTagColor,
+ getTagTextColor
+} from '../reducers/settings';
import {
actions as AppActions,
getSelectedEntries,
@@ -74,7 +78,7 @@ interface Props {
tagGroups: Array<TagGroup>;
allTags: Array<Tag>;
openURLExternally: (path: string) => void;
- toggleTagGroup: (expanded: boolean, uuid: string) => void;
+ toggleTagGroup: (uuid: string) => void;
removeTagGroup: (uuid: string) => void;
moveTagGroupUp: (uuid: string) => void;
moveTagGroupDown: (uuid: string) => void;
@@ -90,6 +94,7 @@ interface Props {
editTag: () => void;
deleteTag: () => void;
selectedEntries: Array<FileSystemEntry>;
+ tagGroupCollapsed: Array<string>;
}
interface State {
@@ -130,7 +135,7 @@ class TagLibrary extends React.Component<Props, State> {
};
handleTagGroupTitleClick = (event: Object, tagGroup) => {
- this.props.toggleTagGroup(tagGroup.expanded, tagGroup.uuid);
+ this.props.toggleTagGroup(tagGroup.uuid);
};
handleTagGroupMenu = (
@@ -211,6 +216,11 @@ class TagLibrary extends React.Component<Props, State> {
};
renderTagGroup = tagGroup => {
+ // eslint-disable-next-line no-param-reassign
+ tagGroup.expanded = !(
+ this.props.tagGroupCollapsed &&
+ this.props.tagGroupCollapsed.includes(tagGroup.uuid)
+ );
const isReadOnly = tagGroup.readOnly || isTagLibraryReadOnly;
return (
<div key={tagGroup.uuid}>
@@ -409,7 +419,7 @@ class TagLibrary extends React.Component<Props, State> {
className={classes.taggroupsArea}
data-tid="tagLibraryTagGroupList"
>
- <List style={{ paddingTop: 0 }}>
+ <List style={{ paddingTop: 0, paddingBottom: 0 }}>
{SmartTags(i18n).map(this.renderTagGroup)}
</List>
<List style={{ paddingTop: 0 }}>
@@ -428,14 +438,15 @@ function mapStateToProps(state) {
tagTextColor: getTagTextColor(state),
selectedEntries: getSelectedEntries(state),
allTags: getAllTags(state),
- isReadOnlyMode: isReadOnlyMode(state)
+ isReadOnlyMode: isReadOnlyMode(state),
+ tagGroupCollapsed: state.settings.tagGroupCollapsed
};
}
function mapDispatchToProps(dispatch) {
return bindActionCreators(
{
- toggleTagGroup: TagLibraryActions.toggleTagGroup,
+ toggleTagGroup: SettingsActions.toggleTagGroup,
removeTagGroup: TagLibraryActions.removeTagGroup,
moveTagGroupUp: TagLibraryActions.moveTagGroupUp,
moveTagGroupDown: TagLibraryActions.moveTagGroupDown,
diff --git a/app/components/dialogs/CreateTagGroupDialog.tsx b/app/components/dialogs/CreateTagGroupDialog.tsx
index cc66908ed..d707b6123 100644
--- a/app/components/dialogs/CreateTagGroupDialog.tsx
+++ b/app/components/dialogs/CreateTagGroupDialog.tsx
@@ -84,7 +84,6 @@ class CreateTagGroupDialog extends React.Component<Props, State> {
this.props.createTagGroup({
uuid: this.state.uuid,
title: this.state.title,
- expanded: true,
color: this.state.color,
textcolor: this.state.textcolor,
children: []
diff --git a/app/components/dialogs/ImportExportTagGroupsDialog.tsx b/app/components/dialogs/ImportExportTagGroupsDialog.tsx
index 12ab0a069..c786aa4e7 100644
--- a/app/components/dialogs/ImportExportTagGroupsDialog.tsx
+++ b/app/components/dialogs/ImportExportTagGroupsDialog.tsx
@@ -81,7 +81,6 @@ class ImportExportTagGroupsDialog extends React.Component<Props, State> {
color: entry.color,
textcolor: entry.textcolor,
children: entry.children,
- expanded: entry.expanded,
selected: true
});
return true;
@@ -104,7 +103,6 @@ class ImportExportTagGroupsDialog extends React.Component<Props, State> {
color: entry.color,
textcolor: entry.textcolor,
children: entry.children,
- expanded: entry.expanded,
selected: !this.state.selectedAll
});
return true;
@@ -154,8 +152,7 @@ class ImportExportTagGroupsDialog extends React.Component<Props, State> {
title: tagGroup.title,
color: tagGroup.color,
textcolor: tagGroup.textcolor,
- children: tagGroup.children,
- expanded: tagGroup.expanded
+ children: tagGroup.children
});
}
return true;
diff --git a/app/reducers/settings.ts b/app/reducers/settings.ts
index 1eb850e20..b5160b0f3 100644
--- a/app/reducers/settings.ts
+++ b/app/reducers/settings.ts
@@ -65,7 +65,8 @@ export const types = {
SET_ENTRY_PROPERTIES_SPLIT_SIZE: 'SETTINGS/SET_ENTRY_PROPERTIES_SPLIT_SIZE',
SET_MAIN_VSPLIT_SIZE: 'SETTINGS/SET_MAIN_VSPLIT_SIZE',
SET_LEFT_VSPLIT_SIZE: 'SETTINGS/SET_LEFT_VSPLIT_SIZE',
- SET_FIRST_RUN: 'SETTINGS/SET_FIRST_RUN'
+ SET_FIRST_RUN: 'SETTINGS/SET_FIRST_RUN',
+ TOGGLE_TAGGROUP: 'TOGGLE_TAGGROUP'
};
export default (state: any = defaultSettings, action: any) => {
@@ -285,6 +286,24 @@ export default (state: any = defaultSettings, action: any) => {
lastPublishedVersion: action.lastPublishedVersion
};
}
+ case types.TOGGLE_TAGGROUP: {
+ let tagGroupCollapsed;
+ if (state.tagGroupCollapsed) {
+ if (state.tagGroupCollapsed.includes(action.uuid)) {
+ tagGroupCollapsed = state.tagGroupCollapsed.filter(
+ tagGroupUUID => tagGroupUUID !== action.uuid
+ );
+ } else {
+ tagGroupCollapsed = [...state.tagGroupCollapsed, action.uuid];
+ }
+ } else {
+ tagGroupCollapsed = [action.uuid];
+ }
+ return {
+ ...state,
+ tagGroupCollapsed
+ };
+ }
default: {
return state;
}
@@ -292,6 +311,10 @@ export default (state: any = defaultSettings, action: any) => {
};
export const actions = {
+ toggleTagGroup: (tagGroupUUID: string) => ({
+ type: types.TOGGLE_TAGGROUP,
+ uuid: tagGroupUUID
+ }),
setTagDelimiter: (delimiter: string) => ({
type: types.SET_TAG_DELIMITER,
delimiter
diff --git a/app/reducers/smart-tags.ts b/app/reducers/smart-tags.ts
index c3f2534b3..0be5852f3 100644
--- a/app/reducers/smart-tags.ts
+++ b/app/reducers/smart-tags.ts
@@ -2,7 +2,6 @@ export default i18n => [
{
title: i18n.t('core:smartTags'),
uuid: 'd4b5c16a-1c3a-4561-96c7-686696cb2004',
- expanded: true,
description: '',
color: '#4986e7',
textcolor: '#ffffff',
diff --git a/app/reducers/tagging-actions.ts b/app/reducers/tagging-actions.ts
index 55445a6d7..bed1c4ca0 100644
--- a/app/reducers/tagging-actions.ts
+++ b/app/reducers/tagging-actions.ts
@@ -124,7 +124,6 @@ const actions = {
const tagGroup = {
uuid: 'collected_tag_group_id', // uuid needs to be constant here (see mergeTagGroup)
title: i18n.t('core:collectedTags'),
- expanded: true,
color: settings.tagBackgroundColor,
textcolor: settings.tagTextColor,
children: uniqueTags,
@@ -473,7 +472,6 @@ const actions = {
const tagGroup = {
uuid: 'collected_tag_group_id', // uuid needs to be constant here (see mergeTagGroup)
title: i18n.t('core:collectedTags'),
- expanded: true,
color: settings.tagBackgroundColor,
textcolor: settings.tagTextColor,
children: uniqueTags,
diff --git a/app/reducers/taglibrary-default.ts b/app/reducers/taglibrary-default.ts
index d98181f0d..fdde9e999 100644
--- a/app/reducers/taglibrary-default.ts
+++ b/app/reducers/taglibrary-default.ts
@@ -23,7 +23,6 @@ export default [
{
title: 'ToDo Workflow',
uuid: '50567824-16ba-4fda-a128-3865df97472f',
- expanded: true,
color: '#008000',
textcolor: '#ffffff',
children: [
@@ -68,7 +67,6 @@ export default [
{
title: 'Common Tags',
uuid: '17882854-44a7-4b2d-a2b1-b022846ac41d',
- expanded: true,
color: '#008000',
textcolor: '#ffffff',
children: [
@@ -98,7 +96,6 @@ export default [
{
title: 'Priorities',
uuid: 'e21711da-ee78-4c83-bae3-e0007fe426a3',
- expanded: true,
color: '#008000',
textcolor: '#ffffff',
children: [
@@ -128,7 +125,6 @@ export default [
{
title: 'Ratings',
uuid: '5cf5173d-738c-4413-9386-3f4411aa7b64',
- expanded: true,
color: '#ffcc24',
textcolor: '#ffffff',
children: [
diff --git a/app/reducers/taglibrary.ts b/app/reducers/taglibrary.ts
index d45fd314f..8cc6369e6 100644
--- a/app/reducers/taglibrary.ts
+++ b/app/reducers/taglibrary.ts
@@ -31,7 +31,7 @@ export const types = {
MERGE_TAGGROUP: 'MERGE_TAGGROUP',
REMOVE_TAGGROUP: 'REMOVE_TAGGROUP',
UPDATE_TAGGROUP: 'UPDATE_TAGGROUP',
- TOGGLE_TAGGROUP: 'TOGGLE_TAGGROUP',
+ // TOGGLE_TAGGROUP: 'TOGGLE_TAGGROUP',
ADD_TAG: 'ADD_TAG',
REMOVE_TAG: 'REMOVE_TAG',
UPDATE_TAG: 'UPDATE_TAG',
@@ -62,7 +62,7 @@ export interface Tag {
export interface TagGroup {
uuid: Uuid;
title: string;
- expanded: boolean;
+ expanded?: boolean;
description?: string;
categoryId?: string;
readOnly?: boolean;
@@ -79,7 +79,6 @@ export default (state: Array<TagGroup> = defaultTagLibrary, action: any) => {
{
uuid: uuidv1(),
title: action.entry.title,
- expanded: action.entry.expanded,
color: action.entry.color,
textcolor: action.entry.textcolor,
children: [],
@@ -101,7 +100,6 @@ export default (state: Array<TagGroup> = defaultTagLibrary, action: any) => {
{
uuid: action.entry.uuid,
title: action.entry.title,
- expanded: action.entry.expanded,
children: [
...state[indexForEditing].children,
action.entry.children[0]
@@ -129,7 +127,6 @@ export default (state: Array<TagGroup> = defaultTagLibrary, action: any) => {
{
uuid: action.entry.uuid,
title: action.entry.title,
- expanded: action.entry.expanded,
children: tags,
created_date: action.entry.created_date,
modified_date: new Date()
@@ -142,7 +139,6 @@ export default (state: Array<TagGroup> = defaultTagLibrary, action: any) => {
{
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,
@@ -308,25 +304,6 @@ export default (state: Array<TagGroup> = defaultTagLibrary, action: any) => {
}
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) => {
@@ -430,7 +407,6 @@ export default (state: Array<TagGroup> = defaultTagLibrary, action: any) => {
tagGroup = {
title: tagGroup.title,
uuid: tagGroup.key,
- expanded: true,
children: tagGroup.children
};
const tagsArr = [];
@@ -468,19 +444,26 @@ export default (state: Array<TagGroup> = defaultTagLibrary, action: any) => {
};
export const actions = {
- createTagGroup: (entry: TagGroup) => ({ type: types.CREATE_TAGGROUP, entry }),
- editTagGroup: (entry: TagGroup) => ({ type: types.UPDATE_TAGGROUP, entry }),
+ 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
}),
- 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);