Skip to content

Commit

Permalink
CRISTAL-371: Shows details about the last edition on pages
Browse files Browse the repository at this point in the history
* Use UserDetails instead of string
* Make use of Date and User UI elements
  • Loading branch information
pjeanjean committed Dec 17, 2024
1 parent 96456e2 commit 9947932
Show file tree
Hide file tree
Showing 24 changed files with 206 additions and 63 deletions.
1 change: 1 addition & 0 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"test": "vitest --run"
},
"dependencies": {
"@xwiki/cristal-authentication-api": "workspace:*",
"inversify": "6.2.0",
"vue": "3.5.13",
"vue-router": "4.5.0"
Expand Down
3 changes: 2 additions & 1 deletion api/src/api/PageData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

import type { Document } from "./document";
import type { UserDetails } from "@xwiki/cristal-authentication-api";

export interface PageData {
id: string;
Expand All @@ -41,7 +42,7 @@ export interface PageData {
* Name of the last user to edit this page.
* @since 0.13
*/
lastAuthor: string | undefined;
lastAuthor: UserDetails | undefined;

// TODO: remove any
toObject(): any; // eslint-disable-line
Expand Down
3 changes: 2 additions & 1 deletion api/src/components/DefaultPageData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import { JSONLDDocument } from "./JSONLDDocument";
import type { PageData } from "../api/PageData";
import type { Document } from "../api/document";
import type { UserDetails } from "@xwiki/cristal-authentication-api";

export class DefaultPageData implements PageData {
id: string;
Expand All @@ -36,7 +37,7 @@ export class DefaultPageData implements PageData {
headline: string = "";
headlineRaw: string = "";
lastModificationDate: Date | undefined;
lastAuthor: string | undefined;
lastAuthor: UserDetails | undefined;

public constructor(
id: string = "",
Expand Down
4 changes: 0 additions & 4 deletions core/authentication/authentication-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
"clean": "rimraf dist",
"lint": "eslint \"./src/**/*.{ts,tsx,vue}\" --max-warnings=0"
},
"dependencies": {
"@xwiki/cristal-api": "workspace:*",
"inversify": "6.2.0"
},
"peerDependencies": {
"reflect-metadata": "0.2.2"
},
Expand Down
18 changes: 1 addition & 17 deletions core/authentication/authentication-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,8 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

import { DefaultAuthenticationManagerProvider } from "./defaultAuthenticationManagerProvider";
import { Container } from "inversify";
import type { AuthenticationManager } from "./authenticationManager";
import type { AuthenticationManagerProvider } from "./authenticationManagerProvider";
import type { UserDetails } from "./userDetails";

class ComponentInit {
constructor(container: Container) {
container
.bind<AuthenticationManagerProvider>("AuthenticationManagerProvider")
.to(DefaultAuthenticationManagerProvider)
.inSingletonScope();
}
}

export {
AuthenticationManager,
AuthenticationManagerProvider,
ComponentInit,
UserDetails,
};
export { AuthenticationManager, AuthenticationManagerProvider, UserDetails };
49 changes: 49 additions & 0 deletions core/authentication/authentication-default/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"name": "@xwiki/cristal-authentication-default",
"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-default",
"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"
},
"dependencies": {
"@xwiki/cristal-api": "workspace:*",
"@xwiki/cristal-authentication-api": "workspace:*",
"inversify": "6.2.0"
},
"peerDependencies": {
"reflect-metadata": "0.2.2"
},
"devDependencies": {
"reflect-metadata": "0.2.2",
"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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

import { AuthenticationManager } from "./authenticationManager";
import { AuthenticationManagerProvider } from "./authenticationManagerProvider";
import {
AuthenticationManager,
AuthenticationManagerProvider,
} from "@xwiki/cristal-authentication-api";
import { inject, injectable } from "inversify";
import type { CristalApp } from "@xwiki/cristal-api";

Expand Down
32 changes: 32 additions & 0 deletions core/authentication/authentication-default/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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 { DefaultAuthenticationManagerProvider } from "./defaultAuthenticationManagerProvider";
import { Container } from "inversify";
import type { AuthenticationManagerProvider } from "@xwiki/cristal-authentication-api";

export class ComponentInit {
constructor(container: Container) {
container
.bind<AuthenticationManagerProvider>("AuthenticationManagerProvider")
.to(DefaultAuthenticationManagerProvider)
.inSingletonScope();
}
}
12 changes: 12 additions & 0 deletions core/authentication/authentication-default/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-default/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-default/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 @@ -23,6 +23,7 @@
},
"dependencies": {
"@xwiki/cristal-api": "workspace:*",
"@xwiki/cristal-authentication-api": "workspace:*",
"@xwiki/cristal-backend-api": "workspace:*",
"inversify": "6.2.0"
},
Expand Down
9 changes: 6 additions & 3 deletions core/backends/backend-nextcloud/src/nextcloudStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
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";
Expand Down Expand Up @@ -71,7 +72,7 @@ export class NextcloudStorage extends AbstractStorage {
);

if (response.status >= 200 && response.status < 300) {
let lastAuthor: string | undefined;
let lastAuthor: UserDetails | undefined;
let lastModificationDate: Date | undefined;
const propResponse = await fetch(
`${this.getWikiConfig().baseRestURL}/${USERNAME}/.cristal/${page}/page.json`,
Expand Down Expand Up @@ -102,8 +103,10 @@ export class NextcloudStorage extends AbstractStorage {
if (modifiedProp) {
lastModificationDate = new Date(Date.parse(modifiedProp));
}
lastAuthor = propData.getElementsByTagName("oc:owner-display-name")[0]
?.innerHTML;
lastAuthor = {
name: propData.getElementsByTagName("oc:owner-display-name")[0]
?.innerHTML,
};
}

const json = await response.json();
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 @@ -185,7 +185,7 @@ export class XWikiStorage extends AbstractStorage {
pageContentData.lastModificationDate = new Date(
Date.parse(json.dateModified),
);
pageContentData.lastAuthor = json.editor;
pageContentData.lastAuthor = { name: json.editor };
return pageContentData;
}

Expand Down
2 changes: 1 addition & 1 deletion electron/storage/src/electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async function readPage(path: string): Promise<PageData | undefined> {
parse.name = basename(dirname(path));
}
parse.lastModificationDate = new Date(pageStats.mtimeMs);
parse.lastAuthor = os.userInfo().username;
parse.lastAuthor = { name: os.userInfo().username };
return parse;
} else {
return undefined;
Expand Down
1 change: 1 addition & 0 deletions lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@xwiki/cristal-attachments-default": "workspace:*",
"@xwiki/cristal-attachments-ui": "workspace:*",
"@xwiki/cristal-authentication-api": "workspace:*",
"@xwiki/cristal-authentication-default": "workspace:*",
"@xwiki/cristal-authentication-ui": "workspace:*",
"@xwiki/cristal-backend-api": "workspace:*",
"@xwiki/cristal-backend-dexie": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions lib/src/staticBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import { ComponentInit as AlertsDefaultComponentInit } from "@xwiki/cristal-alerts-default";
import { ComponentInit as AttachmentsDefaultComponentInit } from "@xwiki/cristal-attachments-default";
import { ComponentInit as AttachmentsUIComponentInit } from "@xwiki/cristal-attachments-ui";
import { ComponentInit as AuthenticationAPIComponentInit } from "@xwiki/cristal-authentication-api";
import { ComponentInit as AuthenticationDefaultComponentInit } from "@xwiki/cristal-authentication-default";
import { ComponentInit as AuthenticationUIComponentInit } from "@xwiki/cristal-authentication-ui";
import { ComponentInit as BackendAPIComponentInit } from "@xwiki/cristal-backend-api";
import { ComponentInit as DexieBackendComponentInit } from "@xwiki/cristal-backend-dexie";
Expand Down Expand Up @@ -98,7 +98,7 @@ export class StaticBuild {
new UIExtensionDefaultComponentInit(container);
new AuthenticationUIComponentInit(container);
new BackendAPIComponentInit(container);
new AuthenticationAPIComponentInit(container);
new AuthenticationDefaultComponentInit(container);
new LinkSuggestComponentInit(container);
new XWikiLinkSuggestComponentInit(container);
new NextcloudLinkSuggestComponentInit(container);
Expand Down
Loading

0 comments on commit 9947932

Please sign in to comment.