mirror of
https://github.com/etkecc/synapse-admin.git
synced 2025-02-16 11:29:48 +03:00
Add Contact support
button (#45)
This commit is contained in:
parent
52a2f1c936
commit
bb53d53692
7 changed files with 43 additions and 2 deletions
10
README.md
10
README.md
|
@ -212,6 +212,16 @@ Example for [mautrix-telegram](https://github.com/mautrix/telegram)
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Providing support URL
|
||||||
|
|
||||||
|
Synapse-Admin provides a support link in the main menu - `Contact support`. By default, the link points to the GitHub issues page of the project. You can change this link by providing a `supportURL` in the `config.json`.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"supportURL": "https://example.com/support"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
||||||
![Screenshots](./screenshots.jpg)
|
![Screenshots](./screenshots.jpg)
|
||||||
|
|
|
@ -4,6 +4,7 @@ import polyglotI18nProvider from "ra-i18n-polyglot";
|
||||||
import { Admin, CustomRoutes, Resource, resolveBrowserLocale } from "react-admin";
|
import { Admin, CustomRoutes, Resource, resolveBrowserLocale } from "react-admin";
|
||||||
import { Route } from "react-router-dom";
|
import { Route } from "react-router-dom";
|
||||||
|
|
||||||
|
import { AdminLayout } from "./components/AdminLayout";
|
||||||
import { ImportFeature } from "./components/ImportFeature";
|
import { ImportFeature } from "./components/ImportFeature";
|
||||||
import germanMessages from "./i18n/de";
|
import germanMessages from "./i18n/de";
|
||||||
import englishMessages from "./i18n/en";
|
import englishMessages from "./i18n/en";
|
||||||
|
@ -49,6 +50,7 @@ const App = () => (
|
||||||
<Admin
|
<Admin
|
||||||
disableTelemetry
|
disableTelemetry
|
||||||
requireAuth
|
requireAuth
|
||||||
|
layout={AdminLayout}
|
||||||
loginPage={LoginPage}
|
loginPage={LoginPage}
|
||||||
authProvider={authProvider}
|
authProvider={authProvider}
|
||||||
dataProvider={dataProvider}
|
dataProvider={dataProvider}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { createContext, useContext } from "react";
|
||||||
interface AppContextType {
|
interface AppContextType {
|
||||||
restrictBaseUrl: string | string[];
|
restrictBaseUrl: string | string[];
|
||||||
asManagedUsers: string[];
|
asManagedUsers: string[];
|
||||||
|
supportURL: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AppContext = createContext({});
|
export const AppContext = createContext({});
|
||||||
|
|
26
src/components/AdminLayout.tsx
Normal file
26
src/components/AdminLayout.tsx
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
import { Layout, Menu } from 'react-admin';
|
||||||
|
import LiveHelpIcon from '@mui/icons-material/LiveHelp';
|
||||||
|
|
||||||
|
const DEFAULT_SUPPORT_LINK = "https://github.com/etkecc/synapse-admin/issues";
|
||||||
|
const supportLink = (): string => {
|
||||||
|
try {
|
||||||
|
new URL(localStorage.getItem("support_url") || ''); // Check if the URL is valid
|
||||||
|
return localStorage.getItem("support_url") || DEFAULT_SUPPORT_LINK;
|
||||||
|
} catch (e) {
|
||||||
|
return DEFAULT_SUPPORT_LINK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const AdminMenu = () => (
|
||||||
|
<Menu>
|
||||||
|
<Menu.ResourceItems />
|
||||||
|
<Menu.Item to={supportLink()} target="_blank" primaryText="Contact support" leftIcon={<LiveHelpIcon />} />
|
||||||
|
</Menu>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const AdminLayout = ({ children }) => (
|
||||||
|
<Layout menu={AdminMenu}>
|
||||||
|
{children}
|
||||||
|
</Layout>
|
||||||
|
);
|
|
@ -4,8 +4,8 @@
|
||||||
* @param id The user ID to check
|
* @param id The user ID to check
|
||||||
* @returns Whether the user is managed by an application service
|
* @returns Whether the user is managed by an application service
|
||||||
*/
|
*/
|
||||||
export const isASManaged = (id: string) => {
|
export const isASManaged = (id: string): boolean => {
|
||||||
const managedUsersString = localStorage.getItem("as_managed_users");
|
const managedUsersString = localStorage.getItem("as_managed_users") || '';
|
||||||
try {
|
try {
|
||||||
const asManagedUsers = JSON.parse(managedUsersString).map(regex => new RegExp(regex));
|
const asManagedUsers = JSON.parse(managedUsersString).map(regex => new RegExp(regex));
|
||||||
return asManagedUsers.some(regex => regex.test(id));
|
return asManagedUsers.some(regex => regex.test(id));
|
||||||
|
|
1
src/i18n/index.d.ts
vendored
1
src/i18n/index.d.ts
vendored
|
@ -139,6 +139,7 @@ interface SynapseTranslationMessages extends TranslationMessages {
|
||||||
deactivate: string;
|
deactivate: string;
|
||||||
erase: string;
|
erase: string;
|
||||||
erase_admin_error: string;
|
erase_admin_error: string;
|
||||||
|
modify_managed_user_error: string;
|
||||||
};
|
};
|
||||||
action: {
|
action: {
|
||||||
erase: string;
|
erase: string;
|
||||||
|
|
|
@ -10,6 +10,7 @@ fetch("config.json")
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(props => {
|
.then(props => {
|
||||||
storage.setItem("as_managed_users", JSON.stringify(props.asManagedUsers));
|
storage.setItem("as_managed_users", JSON.stringify(props.asManagedUsers));
|
||||||
|
storage.setItem("support_url", props.supportURL);
|
||||||
return createRoot(document.getElementById("root")).render(
|
return createRoot(document.getElementById("root")).render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<AppContext.Provider value={props}>
|
<AppContext.Provider value={props}>
|
||||||
|
|
Loading…
Add table
Reference in a new issue