Skip to content

Commit

Permalink
Merge branch 'main' into CRISTAL-257
Browse files Browse the repository at this point in the history
  • Loading branch information
pjeanjean committed Dec 23, 2024
2 parents d7f05d4 + a3d0015 commit cc61997
Show file tree
Hide file tree
Showing 97 changed files with 3,440 additions and 579 deletions.
3 changes: 3 additions & 0 deletions core/attachments/attachments-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@
"@xwiki/cristal-api": "workspace:*",
"@xwiki/cristal-attachments-api": "workspace:*",
"@xwiki/cristal-date-ui": "workspace:*",
"@xwiki/cristal-document-api": "workspace:*",
"@xwiki/cristal-dsapi": "workspace:*",
"@xwiki/cristal-extra-tabs-api": "workspace:*",
"@xwiki/cristal-file-preview-ui": "workspace:*",
"@xwiki/cristal-info-actions-api": "workspace:*",
"@xwiki/cristal-model-api": "workspace:*",
"@xwiki/cristal-model-click-listener": "workspace:*",
"@xwiki/cristal-model-reference-api": "workspace:*",
"@xwiki/cristal-uiextension-api": "workspace:*",
"@xwiki/cristal-user-ui": "workspace:*",
"inversify": "6.2.0",
Expand Down
24 changes: 12 additions & 12 deletions core/attachments/attachments-ui/src/vue/AttachmentsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import AttachmentsTable from "./AttachmentsTable.vue";
import { AlertsService } from "@xwiki/cristal-alerts-api";
import { CristalApp } from "@xwiki/cristal-api";
import { AttachmentsService } from "@xwiki/cristal-attachments-api";
import { DocumentService } from "@xwiki/cristal-document-api";
import { inject, ref, watch } from "vue";
import { useRoute } from "vue-router";

Expand All @@ -31,21 +32,25 @@ const attachmentsService = cristal
.getContainer()
.get<AttachmentsService>("AttachmentsService")!;

const documentService = cristal
.getContainer()
.get<DocumentService>("DocumentService")!;

const attachments = attachmentsService.list();
const isLoading = attachmentsService.isLoading();
const errorMessage = attachmentsService.getError();
const isUploading = attachmentsService.isUploading();

// Watch for route change to refresh the tab when a user visits a new page.
const route = useRoute();

function getCurrentPageReference() {
return documentService.getCurrentDocumentReferenceString().value ?? "";
}

watch(
() => route.params.page,
() =>
attachmentsService.refresh(
(route.params.page as string) ||
cristal.getCurrentPage() ||
"Main.WebHome",
),
() => attachmentsService.refresh(getCurrentPageReference()),
{ immediate: true },
);

Expand All @@ -57,12 +62,7 @@ const alertsService = cristal

async function upload(files: File[]) {
try {
await attachmentsService.upload(
(route.params.page as string) ||
cristal.getCurrentPage() ||
("Main.WebHome" as string),
files,
);
await attachmentsService.upload(getCurrentPageReference(), files);
attachmentUpload.value?.reset();
} catch (e) {
if (e instanceof Error) {
Expand Down
22 changes: 21 additions & 1 deletion core/attachments/attachments-ui/src/vue/AttachmentsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import messages from "../translations";
import { Attachment } from "@xwiki/cristal-attachments-api";
import { Date } from "@xwiki/cristal-date-ui";
import { FileSize } from "@xwiki/cristal-file-preview-ui";
import { AttachmentReference, EntityType } from "@xwiki/cristal-model-api";
import { ModelReferenceParserProvider } from "@xwiki/cristal-model-reference-api";
import { User } from "@xwiki/cristal-user-ui";
import { computed, inject } from "vue";
import { useI18n } from "vue-i18n";
Expand All @@ -21,6 +23,10 @@ const props = defineProps<{
const cristal = inject<CristalApp>("cristal")!;
const listener = cristal.getContainer().get<ClickListener>("ClickListener");
const modelReferenceParser = cristal
.getContainer()
.get<ModelReferenceParserProvider>("ModelReferenceParserProvider")
.get()!;
function attachmentPreview(url: string, event: Event) {
event.preventDefault();
Expand All @@ -35,6 +41,19 @@ const hasAuthor = computed(() => {
.length > 0
);
});
function attachmentName(name: string) {
try {
return (
modelReferenceParser.parse(
name,
EntityType.ATTACHMENT,
) as AttachmentReference
).name;
} catch {
return "";
}
}
</script>
<template>
<span v-if="isLoading">{{ t("attachments.tab.loading") }}</span>
Expand All @@ -61,8 +80,9 @@ const hasAuthor = computed(() => {
<a
:href="attachment.href"
@click="attachmentPreview(attachment.href, $event)"
>{{ attachment.name }}</a
>
{{ attachmentName(attachment.name) }}
</a>
</td>
<td>
<span class="mobile-column-name">
Expand Down
40 changes: 40 additions & 0 deletions core/authentication/authentication-nextcloud/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@xwiki/cristal-authentication-nextcloud",
"version": "0.12.0",
"license": "LGPL 2.1",
"author": "XWiki Org Community <[email protected]>",
"homepage": "https://cristal.xwiki.org/",
"repository": {
"type": "git",
"directory": "/core/authentication/authentication-nextcloud",
"url": "https://github.com/xwiki-contrib/cristal/"
},
"bugs": {
"url": "https://jira.xwiki.org/projects/CRISTAL/"
},
"type": "module",
"exports": {
".": "./src/index.ts"
},
"main": "./src/index.ts",
"scripts": {
"build": "tsc --project tsconfig.json && vite build",
"clean": "rimraf dist",
"lint": "eslint \"./src/**/*.{ts,tsx,vue}\" --max-warnings=0"
},
"devDependencies": {
"typescript": "5.6.3",
"vite": "6.0.3"
},
"publishConfig": {
"exports": {
".": {
"import": "./dist/index.es.js",
"require": "./dist/index.umd.js",
"types": "./dist/index.d.ts"
}
},
"main": "./dist/index.es.js",
"types": "./dist/index.d.ts"
}
}
25 changes: 25 additions & 0 deletions core/authentication/authentication-nextcloud/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* See the LICENSE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

// TODO: replace with an actual authentication for nextcloud, see CRISTAL-267
const USERNAME = "test";
const PASSWORD = "test";

export { PASSWORD, USERNAME };
12 changes: 12 additions & 0 deletions core/authentication/authentication-nextcloud/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"resolveJsonModule": true
},
"extends": "../../../tsconfig.json",
"include": [
"./src/index.ts",
"./src/**/*"
]
}
4 changes: 4 additions & 0 deletions core/authentication/authentication-nextcloud/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"]
}
23 changes: 23 additions & 0 deletions core/authentication/authentication-nextcloud/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* See the LICENSE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

import { generateConfig } from "../../../vite.config";

export default generateConfig(import.meta.url);
1 change: 1 addition & 0 deletions core/backends/backend-nextcloud/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"dependencies": {
"@xwiki/cristal-api": "workspace:*",
"@xwiki/cristal-authentication-api": "workspace:*",
"@xwiki/cristal-authentication-nextcloud": "workspace:*",
"@xwiki/cristal-backend-api": "workspace:*",
"inversify": "6.2.0"
},
Expand Down
5 changes: 1 addition & 4 deletions core/backends/backend-nextcloud/src/nextcloudStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,12 @@ import {
PageAttachment,
PageData,
} from "@xwiki/cristal-api";
import { PASSWORD, USERNAME } from "@xwiki/cristal-authentication-nextcloud";
import { AbstractStorage } from "@xwiki/cristal-backend-api";
import { inject, injectable } from "inversify";
import type { Logger } from "@xwiki/cristal-api";
import type { UserDetails } from "@xwiki/cristal-authentication-api";

// TODO: To be replaced by an actual authentication with CRISTAL-267
const USERNAME = "test";
const PASSWORD = "test";

/**
* Access Nextcloud storage through http.
* Read and write files to a ~/.cristal directory where all persistent data is
Expand Down
1 change: 1 addition & 0 deletions core/document/document-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
"dependencies": {
"@xwiki/cristal-api": "workspace:*",
"@xwiki/cristal-model-api": "workspace:*",
"vue": "3.5.13"
},
"devDependencies": {
Expand Down
15 changes: 15 additions & 0 deletions core/document/document-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

import type { PageData } from "@xwiki/cristal-api";
import type { DocumentReference } from "@xwiki/cristal-model-api";
import type { Ref } from "vue";

/**
Expand All @@ -37,6 +38,20 @@ interface DocumentService {
*/
getCurrentDocument(): Ref<PageData | undefined>;

/**
* Returns a reference the document reference for the current document.
*
* @since 0.13
*/
getCurrentDocumentReference(): Ref<DocumentReference | undefined>;

/**
* Returns a serialized string of {@link getCurrentDocumentReference}.
*
* @since 0.13
*/
getCurrentDocumentReferenceString(): Ref<string | undefined>;

/**
* @returns the revision of the current document, or undefined if it's the last one
* @since 0.12
Expand Down
2 changes: 2 additions & 0 deletions core/document/document-default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"dependencies": {
"@xwiki/cristal-api": "workspace:*",
"@xwiki/cristal-document-api": "workspace:*",
"@xwiki/cristal-model-api": "workspace:*",
"@xwiki/cristal-model-reference-api": "workspace:*",
"inversify": "6.2.0",
"pinia": "2.3.0",
"vue": "3.5.13"
Expand Down
Loading

0 comments on commit cc61997

Please sign in to comment.