From 009ce803e2e5b23cfd7b44fcfb15460f85e23f4d Mon Sep 17 00:00:00 2001
From: Dirk Klimpel <5740567+dklimpel@users.noreply.github.com>
Date: Wed, 6 May 2020 09:03:33 +0200
Subject: [PATCH 01/42] Add ServerNoticeButton to UserBulkActionButtons (#41)
This adds the button to send "Server Notices" to many users at once.
---
src/components/ServerNotices.js | 48 +++++++++++++++++++++++++++++++++
src/components/users.js | 3 ++-
src/synapse/dataProvider.js | 23 ++++++++++++++++
3 files changed, 73 insertions(+), 1 deletion(-)
diff --git a/src/components/ServerNotices.js b/src/components/ServerNotices.js
index a0f37da..2a3e8bd 100644
--- a/src/components/ServerNotices.js
+++ b/src/components/ServerNotices.js
@@ -7,8 +7,10 @@ import {
Toolbar,
required,
useCreate,
+ useMutation,
useNotify,
useTranslate,
+ useUnselectAll,
} from "react-admin";
import MessageIcon from "@material-ui/icons/Message";
import IconCancel from "@material-ui/icons/Cancel";
@@ -98,3 +100,49 @@ export const ServerNoticeButton = ({ record }) => {
);
};
+
+export const ServerNoticeBulkButton = ({ selectedIds }) => {
+ const [open, setOpen] = useState(false);
+ const notify = useNotify();
+ const unselectAll = useUnselectAll();
+ const [createMany, { loading }] = useMutation();
+
+ const handleDialogOpen = () => setOpen(true);
+ const handleDialogClose = () => setOpen(false);
+
+ const handleSend = values => {
+ createMany(
+ {
+ type: "createMany",
+ resource: "servernotices",
+ payload: { ids: selectedIds, data: values },
+ },
+ {
+ onSuccess: ({ data }) => {
+ notify("resources.servernotices.action.send_success");
+ unselectAll("users");
+ handleDialogClose();
+ },
+ onFailure: error =>
+ notify("resources.servernotices.action.send_failure", "error"),
+ }
+ );
+ };
+
+ return (
+
+
+
+
+ );
+};
diff --git a/src/components/users.js b/src/components/users.js
index 8e6c75b..16167a0 100644
--- a/src/components/users.js
+++ b/src/components/users.js
@@ -30,7 +30,7 @@ import {
useTranslate,
Pagination,
} from "react-admin";
-import { ServerNoticeButton } from "./ServerNotices";
+import { ServerNoticeButton, ServerNoticeBulkButton } from "./ServerNotices";
const UserPagination = props => (
@@ -51,6 +51,7 @@ const UserBulkActionButtons = props => {
const translate = useTranslate();
return (
+
{
+ console.log("createMany " + resource);
+ const homeserver = localStorage.getItem("base_url");
+ if (!homeserver || !(resource in resourceMap)) return Promise.reject();
+
+ const res = resourceMap[resource];
+ if (!("create" in res)) return Promise.reject();
+
+ return Promise.all(
+ params.ids.map(id => {
+ params.data.id = id;
+ const cre = res["create"](params.data);
+ const endpoint_url = homeserver + cre.endpoint;
+ return jsonClient(endpoint_url, {
+ method: cre.method,
+ body: JSON.stringify(cre.body, filterNullValues),
+ });
+ })
+ ).then(responses => ({
+ data: responses.map(({ json }) => json),
+ }));
+ },
+
delete: (resource, params) => {
console.log("delete " + resource);
const homeserver = localStorage.getItem("base_url");
From 300e22a5378841d65119941bfde5a0c3fe6be4dd Mon Sep 17 00:00:00 2001
From: Michael Albert
Date: Thu, 14 May 2020 11:17:00 +0200
Subject: [PATCH 02/42] Show version of Synapse-Admin
Change-Id: I354e3f3b3e4f45e5ca72318ce70b66bee433f3d6
---
package.json | 6 +++---
public/index.html | 9 ++++++++-
src/components/LoginPage.js | 3 ++-
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/package.json b/package.json
index 7d754fe..002f90d 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "synapse-admin",
- "version": "0.1.0",
+ "version": "0.2.1",
"description": "Admin GUI for the Matrix.org server Synapse",
"author": "Awesome Technologies Innovationslabor GmbH",
"license": "Apache-2.0",
@@ -29,8 +29,8 @@
"react-scripts": "^3.4.1"
},
"scripts": {
- "start": "react-scripts start",
- "build": "react-scripts build",
+ "start": "REACT_APP_VERSION=$(git describe --tags) react-scripts start",
+ "build": "REACT_APP_VERSION=$(git describe --tags) react-scripts build",
"fix:other": "yarn prettier --write",
"fix:code": "yarn test:lint --fix",
"fix": "yarn fix:code && yarn fix:other",
diff --git a/public/index.html b/public/index.html
index 4209361..2b90907 100644
--- a/public/index.html
+++ b/public/index.html
@@ -38,5 +38,12 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
+