From 8a0fc78eb36890a910327c85387be5a3ac495246 Mon Sep 17 00:00:00 2001 From: Pierre Jeanjean Date: Mon, 27 Jan 2025 12:16:23 +0100 Subject: [PATCH] CRISTAL-83: Basic Move/Rename is possible * Small fixes --- core/backends/backend-github/src/githubStorage.ts | 2 +- core/backends/backend-nextcloud/src/nextcloudStorage.ts | 2 +- core/backends/backend-xwiki/src/xwikiStorage.ts | 2 +- core/page-actions/page-actions-ui/src/PageManagement.ts | 6 ++++++ core/page-actions/page-actions-ui/tsdoc.json | 4 ++++ core/rename/rename-api/src/index.ts | 3 ++- .../rename-default/src/components/componentsInit.ts | 8 ++++---- core/rename/rename-default/src/index.ts | 4 ++-- .../rename-filesystem/src/components/componentsInit.ts | 2 +- core/rename/rename-filesystem/src/index.ts | 4 ++-- ds/shoelace/src/vue/x-navigation-tree.vue | 2 -- ds/vuetify/src/vue/form/x-checkbox.vue | 2 -- electron/storage/src/electron/main/index.ts | 4 +++- 13 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 core/page-actions/page-actions-ui/tsdoc.json diff --git a/core/backends/backend-github/src/githubStorage.ts b/core/backends/backend-github/src/githubStorage.ts index 3bfc9884e..820e75b32 100644 --- a/core/backends/backend-github/src/githubStorage.ts +++ b/core/backends/backend-github/src/githubStorage.ts @@ -145,7 +145,7 @@ export class GitHubStorage extends AbstractStorage { } async move(): Promise<{ success: boolean; error?: string }> { - // TODO: to be implemented + // TODO: to be implemented in CRISTAL-436. throw new Error("Move not supported"); } } diff --git a/core/backends/backend-nextcloud/src/nextcloudStorage.ts b/core/backends/backend-nextcloud/src/nextcloudStorage.ts index f8614a422..cdfc8a590 100644 --- a/core/backends/backend-nextcloud/src/nextcloudStorage.ts +++ b/core/backends/backend-nextcloud/src/nextcloudStorage.ts @@ -287,7 +287,7 @@ export class NextcloudStorage extends AbstractStorage { } async move(): Promise<{ success: boolean; error?: string }> { - // TODO: to be implemented + // TODO: to be implemented in CRISTAL-435. throw new Error("Move not supported"); } diff --git a/core/backends/backend-xwiki/src/xwikiStorage.ts b/core/backends/backend-xwiki/src/xwikiStorage.ts index ec7ed6691..29ef7cf48 100644 --- a/core/backends/backend-xwiki/src/xwikiStorage.ts +++ b/core/backends/backend-xwiki/src/xwikiStorage.ts @@ -375,7 +375,7 @@ export class XWikiStorage extends AbstractStorage { } async move(): Promise<{ success: boolean; error?: string }> { - // TODO: to be implemented + // TODO: to be implemented in CRISTAL-434. throw new Error("Move not supported"); } diff --git a/core/page-actions/page-actions-ui/src/PageManagement.ts b/core/page-actions/page-actions-ui/src/PageManagement.ts index cec7ca880..9d5b2e576 100644 --- a/core/page-actions/page-actions-ui/src/PageManagement.ts +++ b/core/page-actions/page-actions-ui/src/PageManagement.ts @@ -38,6 +38,9 @@ class PageManagementActionCategory extends AbstractPageActionCategory { order = 1000; } +/** + * @since 0.14 + */ @injectable() class PageMoveAction implements PageAction { constructor( @@ -58,6 +61,9 @@ class PageMoveAction implements PageAction { } } +/** + * @since 0.14 + */ @injectable() class PageRenameAction implements PageAction { constructor( diff --git a/core/page-actions/page-actions-ui/tsdoc.json b/core/page-actions/page-actions-ui/tsdoc.json new file mode 100644 index 000000000..81c5a8a2a --- /dev/null +++ b/core/page-actions/page-actions-ui/tsdoc.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json", + "extends": ["../../../tsdoc.json"] +} diff --git a/core/rename/rename-api/src/index.ts b/core/rename/rename-api/src/index.ts index 5f14223a2..fee9baf78 100644 --- a/core/rename/rename-api/src/index.ts +++ b/core/rename/rename-api/src/index.ts @@ -40,7 +40,8 @@ interface PageRenameManager { preserveChildren: boolean, ): Promise<{ success: boolean; error?: string }>; - // TODO: add operations to update backlinks and set-up automatic redirects. + /* TODO: Fix CRISTAL-84 and add operations to update backlinks and set-up + automatic redirects. */ } /** diff --git a/core/rename/rename-default/src/components/componentsInit.ts b/core/rename/rename-default/src/components/componentsInit.ts index bc30ab74c..b4fa35ab5 100644 --- a/core/rename/rename-default/src/components/componentsInit.ts +++ b/core/rename/rename-default/src/components/componentsInit.ts @@ -18,7 +18,7 @@ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ -import { name as PageRenameManagerName } from "@xwiki/cristal-rename-api"; +import { name as pageRenameManagerName } from "@xwiki/cristal-rename-api"; import { inject, injectable } from "inversify"; import type { CristalApp } from "@xwiki/cristal-api"; import type { @@ -27,7 +27,7 @@ import type { } from "@xwiki/cristal-rename-api"; /** - * Default implementation for PageRenameManagerProvider. + * Default implementation for {@link PageRenameManagerProvider}. * * @since 0.14 **/ @@ -40,14 +40,14 @@ class DefaultPageRenameManagerProvider implements PageRenameManagerProvider { has(): boolean { const container = this.cristalApp.getContainer(); const wikiConfigType = this.cristalApp.getWikiConfig().getType(); - return container.isBoundNamed(PageRenameManagerName, wikiConfigType); + return container.isBoundNamed(pageRenameManagerName, wikiConfigType); } get(): PageRenameManager { const container = this.cristalApp.getContainer(); const wikiConfigType = this.cristalApp.getWikiConfig().getType(); return container.getNamed( - PageRenameManagerName, + pageRenameManagerName, wikiConfigType, ); } diff --git a/core/rename/rename-default/src/index.ts b/core/rename/rename-default/src/index.ts index 66ae6aee8..d14750337 100644 --- a/core/rename/rename-default/src/index.ts +++ b/core/rename/rename-default/src/index.ts @@ -19,14 +19,14 @@ */ import { DefaultPageRenameManagerProvider } from "./components/componentsInit"; -import { name as PageRenameManagerName } from "@xwiki/cristal-rename-api"; +import { name as pageRenameManagerName } from "@xwiki/cristal-rename-api"; import type { PageRenameManagerProvider } from "@xwiki/cristal-rename-api"; import type { Container } from "inversify"; export class ComponentInit { constructor(container: Container) { container - .bind(`${PageRenameManagerName}Provider`) + .bind(`${pageRenameManagerName}Provider`) .to(DefaultPageRenameManagerProvider) .inSingletonScope() .whenTargetIsDefault(); diff --git a/core/rename/rename-filesystem/src/components/componentsInit.ts b/core/rename/rename-filesystem/src/components/componentsInit.ts index b77451adf..fe5a7c46b 100644 --- a/core/rename/rename-filesystem/src/components/componentsInit.ts +++ b/core/rename/rename-filesystem/src/components/componentsInit.ts @@ -24,7 +24,7 @@ import type { StorageProvider } from "@xwiki/cristal-backend-api"; import type { PageRenameManager } from "@xwiki/cristal-rename-api"; /** - * Implementation of PageRenameManagerProvider for FileSystem backend. + * Implementation of {@link PageRenameManager} for FileSystem backend. * * @since 0.14 **/ diff --git a/core/rename/rename-filesystem/src/index.ts b/core/rename/rename-filesystem/src/index.ts index 6b5582923..68648e276 100644 --- a/core/rename/rename-filesystem/src/index.ts +++ b/core/rename/rename-filesystem/src/index.ts @@ -19,14 +19,14 @@ */ import { FileSystemPageRenameManager } from "./components/componentsInit"; -import { name as PageRenameManagerName } from "@xwiki/cristal-rename-api"; +import { name as pageRenameManagerName } from "@xwiki/cristal-rename-api"; import type { PageRenameManager } from "@xwiki/cristal-rename-api"; import type { Container } from "inversify"; export class ComponentInit { constructor(container: Container) { container - .bind(PageRenameManagerName) + .bind(pageRenameManagerName) .to(FileSystemPageRenameManager) .inSingletonScope() .whenTargetNamed("FileSystem"); diff --git a/ds/shoelace/src/vue/x-navigation-tree.vue b/ds/shoelace/src/vue/x-navigation-tree.vue index 99711620c..817187c7e 100644 --- a/ds/shoelace/src/vue/x-navigation-tree.vue +++ b/ds/shoelace/src/vue/x-navigation-tree.vue @@ -173,5 +173,3 @@ async function onDocumentUpdate(page: PageData) { - - diff --git a/ds/vuetify/src/vue/form/x-checkbox.vue b/ds/vuetify/src/vue/form/x-checkbox.vue index 3f16c198c..ab86286c3 100644 --- a/ds/vuetify/src/vue/form/x-checkbox.vue +++ b/ds/vuetify/src/vue/form/x-checkbox.vue @@ -28,5 +28,3 @@ const checked = defineModel(); - - diff --git a/electron/storage/src/electron/main/index.ts b/electron/storage/src/electron/main/index.ts index a8a75d1b2..9faa67036 100644 --- a/electron/storage/src/electron/main/index.ts +++ b/electron/storage/src/electron/main/index.ts @@ -368,6 +368,7 @@ async function movePage( const directory = dirname(path); const newDirectory = dirname(newPath); + // TODO: Fix CRISTAL-437 instead of doing this check here. const success: boolean = await movePageDeep(directory, newDirectory); if (!success) { throw "Some child pages were not moved because they overlapped with children of the target."; @@ -413,7 +414,8 @@ async function movePageDeepRecursive( const newFilePath = join(newDirectory, file); if (await isDirectory(filePath)) { success = - success && (await movePageDeep(filePath, join(newDirectory, file))); + (await movePageDeepRecursive(filePath, join(newDirectory, file))) && + success; await cleanEmptyArborescence(filePath); } else if (!(await pathExists(newFilePath))) { await fs.promises.rename(filePath, newFilePath);