Skip to content

Commit

Permalink
CRISTAL-83: Basic Move/Rename is possible
Browse files Browse the repository at this point in the history
* Small fixes
  • Loading branch information
pjeanjean committed Jan 27, 2025
1 parent 20a128b commit 8a0fc78
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion core/backends/backend-github/src/githubStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
2 changes: 1 addition & 1 deletion core/backends/backend-nextcloud/src/nextcloudStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
2 changes: 1 addition & 1 deletion core/backends/backend-xwiki/src/xwikiStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
6 changes: 6 additions & 0 deletions core/page-actions/page-actions-ui/src/PageManagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class PageManagementActionCategory extends AbstractPageActionCategory {
order = 1000;
}

/**
* @since 0.14
*/
@injectable()
class PageMoveAction implements PageAction {
constructor(
Expand All @@ -58,6 +61,9 @@ class PageMoveAction implements PageAction {
}
}

/**
* @since 0.14
*/
@injectable()
class PageRenameAction implements PageAction {
constructor(
Expand Down
4 changes: 4 additions & 0 deletions core/page-actions/page-actions-ui/tsdoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
"extends": ["../../../tsdoc.json"]
}
3 changes: 2 additions & 1 deletion core/rename/rename-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
}

/**
Expand Down
8 changes: 4 additions & 4 deletions core/rename/rename-default/src/components/componentsInit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -27,7 +27,7 @@ import type {
} from "@xwiki/cristal-rename-api";

/**
* Default implementation for PageRenameManagerProvider.
* Default implementation for {@link PageRenameManagerProvider}.
*
* @since 0.14
**/
Expand All @@ -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<PageRenameManager>(
PageRenameManagerName,
pageRenameManagerName,
wikiConfigType,
);
}
Expand Down
4 changes: 2 additions & 2 deletions core/rename/rename-default/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PageRenameManagerProvider>(`${PageRenameManagerName}Provider`)
.bind<PageRenameManagerProvider>(`${pageRenameManagerName}Provider`)
.to(DefaultPageRenameManagerProvider)
.inSingletonScope()
.whenTargetIsDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
**/
Expand Down
4 changes: 2 additions & 2 deletions core/rename/rename-filesystem/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<PageRenameManager>(PageRenameManagerName)
.bind<PageRenameManager>(pageRenameManagerName)
.to(FileSystemPageRenameManager)
.inSingletonScope()
.whenTargetNamed("FileSystem");
Expand Down
2 changes: 0 additions & 2 deletions ds/shoelace/src/vue/x-navigation-tree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,3 @@ async function onDocumentUpdate(page: PageData) {
</x-navigation-tree-item>
</sl-tree>
</template>

<style scoped></style>
2 changes: 0 additions & 2 deletions ds/vuetify/src/vue/form/x-checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,3 @@ const checked = defineModel<boolean>();
<template>
<v-checkbox v-model="checked" :label="label" :messages="help"></v-checkbox>
</template>

<style scoped></style>
4 changes: 3 additions & 1 deletion electron/storage/src/electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.";
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 8a0fc78

Please sign in to comment.