Skip to content

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

Kanban improvements, fix md links in folder container (#1810)

Stanimirb0edd6b81ab4
diff --git a/.prettierignore b/.prettierignore
index 3b50da514..09ed86b77 100755
--- a/.prettierignore
+++ b/.prettierignore
@@ -5,6 +5,7 @@ web
web/files
app/node_modules
app/version.json
+app/tagspaces.namespace.d.ts
flow-typed
app/dist
app/main.prod.js
diff --git a/app/components/EntryContainer.tsx b/app/components/EntryContainer.tsx
index 4e36488cd..ec78e6d2b 100644
--- a/app/components/EntryContainer.tsx
+++ b/app/components/EntryContainer.tsx
@@ -156,7 +156,7 @@ interface Props {
openPrevFile: (path: string) => void;
openNextFile: (path: string) => void;
openFileNatively: (path: string) => void;
- openLink: (url: string) => void;
+ openLink: (url: string, options?: any) => void;
openDirectory: (path: string) => void;
showNotification: (
text: string,
@@ -416,7 +416,7 @@ function EntryContainer(props: Props) {
openNextFile();
break;
case 'openLinkExternally':
- openLink(data.link);
+ // openLink(data.link);
break;
case 'loadDefaultTextContent':
if (!openedFile || !openedFile.path) {
diff --git a/app/components/FolderContainer.tsx b/app/components/FolderContainer.tsx
index cb3ca6558..8b1521143 100644
--- a/app/components/FolderContainer.tsx
+++ b/app/components/FolderContainer.tsx
@@ -214,7 +214,7 @@ interface Props {
setSearchQuery: (searchQuery: TS.SearchQuery) => void;
openURLExternally?: (url: string, skipConfirmation: boolean) => void;
language: string;
- editedEntryPaths: Array<string>;
+ editedEntryPaths: Array<TS.EditedEntryPath>;
goBack: () => void;
goForward: () => void;
}
@@ -266,29 +266,18 @@ function FolderContainer(props: Props) {
props.editedEntryPaths &&
props.editedEntryPaths.length > 0
) {
- let action = 'createNew'; // todo set action in editedEntryPaths
for (const editedEntryPath of props.editedEntryPaths) {
- let path;
- if (typeof editedEntryPath === 'string') {
- path = editedEntryPath;
- action = 'createNew';
- } else if (typeof editedEntryPath === 'object') {
- path = Object.keys(editedEntryPath)[0];
- action = 'addTag';
- }
- if (path && action === 'addTag') {
+ const action = editedEntryPath.action;
+ if (editedEntryPath.path && action.startsWith('edit')) {
// update opened file after delete sidecar tags
if (props.openedFiles.length > 0) {
const openedFile = props.openedFiles[0];
- if (openedFile.path === path) {
- props.openEntry(path);
+ if (openedFile.path === editedEntryPath.path) {
+ props.openEntry(editedEntryPath.path);
}
}
}
}
- /*if (props.editedEntryPaths.length === 2) {
- action = 'renameFile';
- }*/
}
}, [props.editedEntryPaths]);
diff --git a/app/components/menus/DirectoryMenu.tsx b/app/components/menus/DirectoryMenu.tsx
index 6eaaefd86..47fa8363c 100644
--- a/app/components/menus/DirectoryMenu.tsx
+++ b/app/components/menus/DirectoryMenu.tsx
@@ -104,6 +104,7 @@ interface Props {
openURLExternally?: (url: string, skipConfirmation: boolean) => void;
currentLocation?: TS.Location;
locations?: Array<TS.Location>;
+ toggleCreateDirectoryDialog: () => void;
}
function DirectoryMenu(props: Props) {
@@ -151,10 +152,10 @@ function DirectoryMenu(props: Props) {
}
}
- const [
+ /* const [
isCreateDirectoryDialogOpened,
setIsCreateDirectoryDialogOpened
- ] = useState(false);
+ ] = useState(false);*/
function reloadDirectory() {
props.loadDirectoryContent(props.directoryPath, true, true);
@@ -239,9 +240,9 @@ function DirectoryMenu(props: Props) {
props.openRenameDirectoryDialog();
}
- function showCreateDirectoryDialog() {
+ /*function showCreateDirectoryDialog() {
setIsCreateDirectoryDialogOpened(true);
- }
+ }*/
function createNewFile() {
props.toggleCreateFileDialog();
@@ -424,7 +425,7 @@ Do you want to continue?`)
showDeleteDirectoryDialog,
showInFileManager,
createNewFile,
- showCreateDirectoryDialog,
+ props.toggleCreateDirectoryDialog,
addExistingFile,
setFolderThumbnail,
copySharingLink,
@@ -436,14 +437,6 @@ Do you want to continue?`)
return (
<div style={{ overflowY: 'hidden' }}>
- {isCreateDirectoryDialogOpened && ( // TODO move dialogs in MainContainer and don't include the Menu HTML always
- <CreateDirectoryDialog
- key={'createDir' + props.directoryPath}
- open={isCreateDirectoryDialogOpened}
- onClose={() => setIsCreateDirectoryDialogOpened(false)}
- selectedDirectoryPath={props.directoryPath}
- />
- )}
<Menu
anchorEl={props.anchorEl}
open={props.open}
@@ -490,6 +483,7 @@ function mapDispatchToProps(dispatch) {
toggleUploadDialog: AppActions.toggleUploadDialog,
toggleProgressDialog: AppActions.toggleProgressDialog,
toggleCreateFileDialog: AppActions.toggleCreateFileDialog,
+ toggleCreateDirectoryDialog: AppActions.toggleCreateDirectoryDialog,
toggleProTeaser: AppActions.toggleProTeaser,
resetProgress: AppActions.resetProgress,
reflectCreateEntries: AppActions.reflectCreateEntries,
diff --git a/app/containers/MainPage.tsx b/app/containers/MainPage.tsx
index dbc045b58..39b508863 100644
--- a/app/containers/MainPage.tsx
+++ b/app/containers/MainPage.tsx
@@ -157,7 +157,7 @@ interface Props {
toggleEditTagDialog: (tag: TS.Tag) => void;
setEntryFullWidth: (isFullWidth: boolean) => void;
loadParentDirectoryContent: () => void;
- openLink: (linkURL: string, options: any) => void;
+ openLink: (linkURL: string, options?: any) => void;
saveFile: () => void; // needed by electron-menus
setZoomResetApp: () => void; // needed by electron-menus
setZoomInApp: () => void; // needed by electron-menus
@@ -360,6 +360,23 @@ function MainPage(props: Props) {
undefined
);
+ useEventListener('message', e => {
+ if (typeof e.data === 'string') {
+ // console.log(e.data);
+ try {
+ const data = JSON.parse(e.data);
+ if(data.command === 'openLinkExternally'){
+ openLink(data.link);
+ }
+ } catch (ex) {
+ console.debug(
+ 'useEventListener message:' + e.data + ' parse error:',
+ ex
+ );
+ }
+ }
+ });
+
function goForward() {
window.history.forward();
window.addEventListener(
diff --git a/app/locales/en/core.json b/app/locales/en/core.json
index f7496b529..6cd982826 100644
--- a/app/locales/en/core.json
+++ b/app/locales/en/core.json
@@ -249,6 +249,7 @@
"file": "File",
"newFileNote": "New File / Note",
"createNewContent": "Add or create new files",
+ "createNewColumn": "Create new column",
"createFileTitle": "Create File / Note",
"createNote": "Create Note",
"createNoteTitle": "Use to create a document with rich text formatting.",
diff --git a/app/perspectives/grid-perspective/components/GridPagination.tsx b/app/perspectives/grid-perspective/components/GridPagination.tsx
index 269458f63..6f81c25b1 100644
--- a/app/perspectives/grid-perspective/components/GridPagination.tsx
+++ b/app/perspectives/grid-perspective/components/GridPagination.tsx
@@ -544,6 +544,7 @@ function GridPagination(props: Props) {
readOnly={true}
dark={theme.palette.mode === 'dark'}
currentFolder={currentDirectoryPath}
+ lightMode={true}
/>
</Grid>
)}
diff --git a/app/reducers/app.ts b/app/reducers/app.ts
index ee627ed8f..624da1dd1 100644
--- a/app/reducers/app.ts
+++ b/app/reducers/app.ts
@@ -601,13 +601,14 @@ export default (state: any = initialState, action: any) => {
const newOpenedFiles = state.openedFiles.filter(
entry => entry.path !== action.path
);
+ const editedEntryPaths = [{ action: 'delete', path: action.path }];
if (
state.currentDirectoryEntries.length > newDirectoryEntries.length ||
state.openedFiles.length > newOpenedFiles.length
) {
return {
...state,
- editedEntryPaths: [action.path],
+ editedEntryPaths,
currentDirectoryEntries: newDirectoryEntries,
openedFiles: newOpenedFiles,
isEntryInFullWidth: false
@@ -615,14 +616,22 @@ export default (state: any = initialState, action: any) => {
}
return {
...state,
- editedEntryPaths: [action.path]
+ editedEntryPaths
};
}
case types.REFLECT_CREATE_ENTRY: {
+ const newEntry: TS.FileSystemEntry = action.newEntry;
// Prevent adding entry twice e.g. by the watcher
const entryIndex = state.currentDirectoryEntries.findIndex(
- entry => entry.path === action.newEntry.path
+ entry => entry.path === newEntry.path
);
+ const editedEntryPaths: Array<TS.EditedEntryPath> = [
+ {
+ action: newEntry.isFile ? 'createFile' : 'createDir',
+ path: newEntry.path,
+ uuid: newEntry.uuid
+ }
+ ];
// clean all dir separators to have platform independent path match
if (
entryIndex < 0 &&
@@ -634,7 +643,7 @@ export default (state: any = initialState, action: any) => {
) {
return {
...state,
- editedEntryPaths: [action.newEntry.path],
+ editedEntryPaths,
currentDirectoryEntries: [
...state.currentDirectoryEntries,
action.newEntry
@@ -643,7 +652,7 @@ export default (state: any = initialState, action: any) => {
}
return {
...state,
- editedEntryPaths: [action.newEntry.path]
+ editedEntryPaths
};
}
case types.REFLECT_RENAME_ENTRY: {
@@ -653,9 +662,14 @@ export default (state: any = initialState, action: any) => {
PlatformIO.getDirSeparator()
);
+ const editedEntryPaths = [
+ { action: 'rename', path: action.path },
+ { action: 'rename', path: action.newPath }
+ ];
+
return {
...state,
- editedEntryPaths: [action.path, action.newPath],
+ editedEntryPaths,
currentDirectoryEntries: state.currentDirectoryEntries.map(entry => {
if (entry.path !== action.path) {
return entry;
@@ -755,7 +769,7 @@ export default (state: any = initialState, action: any) => {
case types.REFLECT_EDITED_ENTRY_PATHS: {
return {
...state,
- editedEntryPaths: action.paths
+ editedEntryPaths: action.editedEntryPaths // .map(path => ({ action: 'edit', path }))
};
}
case types.UPDATE_CURRENTDIR_ENTRY: {
@@ -2134,7 +2148,7 @@ export const actions = {
dispatch(actions.reflectDeleteEntryInt(path));
dispatch(LocationIndexActions.reflectDeleteEntry(path));
},
- reflectCreateEntryInt: newEntry => ({
+ reflectCreateEntryInt: (newEntry: TS.FileSystemEntry) => ({
type: types.REFLECT_CREATE_ENTRY,
newEntry
}),
@@ -2185,9 +2199,9 @@ export const actions = {
type: types.UPDATE_CURRENTDIR_ENTRIES,
dirEntries
}),
- reflectEditedEntryPaths: (paths: Array<any>) => ({
+ reflectEditedEntryPaths: (editedEntryPaths: Array<TS.EditedEntryPath>) => ({
type: types.REFLECT_EDITED_ENTRY_PATHS,
- paths
+ editedEntryPaths
}),
/**
* @param path
@@ -2201,7 +2215,10 @@ export const actions = {
) => (dispatch: (action) => void, getState: () => any) => {
const { openedFiles, selectedEntries } = getState().app;
// to reload cell in KanBan if add/remove sidecar tags
- dispatch(actions.reflectEditedEntryPaths([{ [path]: tags }]));
+ const action: TS.EditedEntryAction = `edit${tags
+ .map(tag => tag.title)
+ .join()}`;
+ dispatch(actions.reflectEditedEntryPaths([{ action, path }])); //[{ [path]: tags }]));
/**
* if its have openedFiles updateCurrentDirEntry is called from FolderContainer (useEffect -> ... if (openedFile.changed)
*/
diff --git a/app/tagspaces.namespace.d.ts b/app/tagspaces.namespace.d.ts
index fa918ad48..53bf2dc39 100644
--- a/app/tagspaces.namespace.d.ts
+++ b/app/tagspaces.namespace.d.ts
@@ -149,6 +149,15 @@ export namespace TS {
folders?: Array<OrderVisibilitySettings>;
files?: Array<OrderVisibilitySettings>;
}
+ // editTag1Tag2 - prevent edit action react component cache and not reload component if add/remove tags
+ // todo fix prettier SyntaxError: Type expected and remove file from .prettierignore
+ type EditedEntryAction = `edit${string}` | 'delete' | 'rename' | 'createFile' | 'createDir';
+
+ interface EditedEntryPath {
+ action: EditedEntryAction;
+ path: string;
+ uuid?: Uuid;
+ }
interface HistoryItem {
path: string;
url: string;