Update frontend dependencies

This commit is contained in:
Tulir Asokan 2021-06-11 11:57:40 +03:00
parent b2018d9ae9
commit a685448887
13 changed files with 4631 additions and 4498 deletions

View File

@ -13,15 +13,15 @@
}, },
"homepage": ".", "homepage": ".",
"dependencies": { "dependencies": {
"node-sass": "^4.12.0", "sass": "^1.34.1",
"react": "^16.8.6", "react": "^17.0.2",
"react-ace": "^9.0.0", "react-ace": "^9.4.1",
"react-contextmenu": "^2.11.0", "react-contextmenu": "^2.14.0",
"react-dom": "^16.8.6", "react-dom": "^17.0.2",
"react-json-tree": "^0.11.2", "react-json-tree": "^0.15.0",
"react-router-dom": "^5.0.1", "react-router-dom": "^5.2.0",
"react-scripts": "3.4.1", "react-scripts": "4.0.3",
"react-select": "^3.0.4" "react-select": "^4.3.1"
}, },
"scripts": { "scripts": {
"start": "react-scripts start", "start": "react-scripts start",
@ -30,16 +30,11 @@
"eject": "react-scripts eject" "eject": "react-scripts eject"
}, },
"browserslist": [ "browserslist": [
"last 5 firefox versions", "last 2 firefox versions",
"last 3 and_ff versions", "last 2 and_ff versions",
"last 5 chrome versions", "last 2 chrome versions",
"last 3 and_chr versions", "last 2 and_chr versions",
"last 2 safari versions", "last 1 safari versions",
"last 2 ios_saf versions" "last 1 ios_saf versions"
], ]
"devDependencies": {
"sass-lint": "^1.13.1",
"sass-lint-auto-fix": "^0.21.0",
"@babel/helper-call-delegate": "^7.10.4"
}
} }

View File

@ -244,6 +244,7 @@ export async function doClientAuth(server, type, username, password) {
return await resp.json() return await resp.json()
} }
// eslint-disable-next-line import/no-anonymous-default-export
export default { export default {
login, ping, setBasePath, getFeatures, remoteGetFeatures, login, ping, setBasePath, getFeatures, remoteGetFeatures,
openLogSocket, openLogSocket,

View File

@ -1,5 +1,5 @@
// maubot - A plugin-based Matrix bot system. // maubot - A plugin-based Matrix bot system.
// Copyright (C) 2019 Tulir Asokan // Copyright (C) 2021 Tulir Asokan
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by
@ -57,7 +57,9 @@ export const PrefSwitch = ({ rowName, active, origActive, fullWidth = false, ...
</PrefRow> </PrefRow>
) )
export const PrefSelect = ({ rowName, value, origValue, fullWidth = false, creatable = false, ...args }) => ( export const PrefSelect = ({
rowName, value, origValue, fullWidth = false, creatable = false, ...args
}) => (
<PrefRow name={rowName} fullWidth={fullWidth} labelFor={rowName} <PrefRow name={rowName} fullWidth={fullWidth} labelFor={rowName}
changed={origValue !== undefined && value.id !== origValue}> changed={origValue !== undefined && value.id !== origValue}>
{creatable {creatable

View File

@ -1,5 +1,5 @@
// maubot - A plugin-based Matrix bot system. // maubot - A plugin-based Matrix bot system.
// Copyright (C) 2019 Tulir Asokan // Copyright (C) 2021 Tulir Asokan
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by
@ -23,10 +23,12 @@ class Switch extends Component {
} }
} }
componentWillReceiveProps(nextProps) { componentDidUpdate(prevProps) {
this.setState({ if (prevProps.active !== this.props.active) {
active: nextProps.active, this.setState({
}) active: this.props.active,
})
}
} }
toggle = () => { toggle = () => {

View File

@ -1,5 +1,5 @@
// maubot - A plugin-based Matrix bot system. // maubot - A plugin-based Matrix bot system.
// Copyright (C) 2019 Tulir Asokan // Copyright (C) 2021 Tulir Asokan
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by
@ -30,7 +30,7 @@ class Main extends Component {
} }
} }
async componentWillMount() { async componentDidMount() {
await this.getBasePath() await this.getBasePath()
if (localStorage.accessToken) { if (localStorage.accessToken) {
await this.ping() await this.ping()
@ -43,7 +43,7 @@ class Main extends Component {
async getBasePath() { async getBasePath() {
try { try {
const resp = await fetch(process.env.PUBLIC_URL + "/paths.json", { const resp = await fetch(process.env.PUBLIC_URL + "/paths.json", {
headers: { "Content-Type": "application/json" } headers: { "Content-Type": "application/json" },
}) })
const apiPathJson = await resp.json() const apiPathJson = await resp.json()
const apiPath = apiPathJson.api_path const apiPath = apiPathJson.api_path

View File

@ -1,3 +1,18 @@
// maubot - A plugin-based Matrix bot system.
// Copyright (C) 2021 Tulir Asokan
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program 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 Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import React, { Component } from "react" import React, { Component } from "react"
import { Link } from "react-router-dom" import { Link } from "react-router-dom"
import api from "../../api" import api from "../../api"
@ -8,7 +23,7 @@ class BaseMainView extends Component {
this.state = Object.assign(this.initialState, props.entry) this.state = Object.assign(this.initialState, props.entry)
} }
componentWillReceiveProps(nextProps) { UNSAFE_componentWillReceiveProps(nextProps) {
const newState = Object.assign(this.initialState, nextProps.entry) const newState = Object.assign(this.initialState, nextProps.entry)
for (const key of this.entryKeys) { for (const key of this.entryKeys) {
if (this.props.entry[key] === nextProps.entry[key]) { if (this.props.entry[key] === nextProps.entry[key]) {

View File

@ -1,5 +1,5 @@
// maubot - A plugin-based Matrix bot system. // maubot - A plugin-based Matrix bot system.
// Copyright (C) 2019 Tulir Asokan // Copyright (C) 2021 Tulir Asokan
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by
@ -64,7 +64,7 @@ class Client extends BaseMainView {
get entryKeys() { get entryKeys() {
return ["id", "displayname", "homeserver", "avatar_url", "access_token", "sync", return ["id", "displayname", "homeserver", "avatar_url", "access_token", "sync",
"autojoin", "online", "enabled", "started"] "autojoin", "online", "enabled", "started"]
} }
get initialState() { get initialState() {
@ -106,7 +106,7 @@ class Client extends BaseMainView {
get selectedHomeserver() { get selectedHomeserver() {
return this.state.homeserver return this.state.homeserver
? this.homeserverEntry([this.props.ctx.homeserversByURL[this.state.homeserver], ? this.homeserverEntry([this.props.ctx.homeserversByURL[this.state.homeserver],
this.state.homeserver]) this.state.homeserver])
: {} : {}
} }
@ -116,13 +116,14 @@ class Client extends BaseMainView {
label: serverName || serverURL, label: serverName || serverURL,
} }
componentWillReceiveProps(nextProps) { componentDidUpdate(prevProps) {
super.componentWillReceiveProps(nextProps)
this.updateHomeserverOptions() this.updateHomeserverOptions()
} }
updateHomeserverOptions() { updateHomeserverOptions() {
this.homeserverOptions = Object.entries(this.props.ctx.homeserversByName).map(this.homeserverEntry) this.homeserverOptions = Object
.entries(this.props.ctx.homeserversByName)
.map(this.homeserverEntry)
} }
isValidHomeserver(value) { isValidHomeserver(value) {
@ -186,7 +187,8 @@ class Client extends BaseMainView {
} }
get loading() { get loading() {
return this.state.saving || this.state.startingOrStopping || this.clearingCache || this.state.deleting return this.state.saving || this.state.startingOrStopping
|| this.clearingCache || this.state.deleting
} }
renderStartedContainer = () => { renderStartedContainer = () => {
@ -211,7 +213,8 @@ class Client extends BaseMainView {
} }
get avatarMXC() { get avatarMXC() {
return this.state.avatar_url === "disable" ? this.props.entry.remote_avatar_url : this.state.avatar_url return this.state.avatar_url === "disable"
? this.props.entry.remote_avatar_url : this.state.avatar_url
} }
get avatarURL() { get avatarURL() {

View File

@ -1,5 +1,5 @@
// maubot - A plugin-based Matrix bot system. // maubot - A plugin-based Matrix bot system.
// Copyright (C) 2019 Tulir Asokan // Copyright (C) 2021 Tulir Asokan
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by
@ -69,8 +69,7 @@ class Instance extends BaseMainView {
return instance return instance
} }
componentWillReceiveProps(nextProps) { componentDidUpdate(prevProps) {
super.componentWillReceiveProps(nextProps)
this.updateClientOptions() this.updateClientOptions()
} }
@ -95,8 +94,8 @@ class Instance extends BaseMainView {
: <NoAvatarIcon className='avatar'/>} : <NoAvatarIcon className='avatar'/>}
<span className="displayname">{ <span className="displayname">{
(client.displayname === "disable" (client.displayname === "disable"
? client.remote_displayname ? client.remote_displayname
: client.displayname : client.displayname
) || client.id ) || client.id
}</span> }</span>
</div> </div>

View File

@ -1,5 +1,5 @@
// maubot - A plugin-based Matrix bot system. // maubot - A plugin-based Matrix bot system.
// Copyright (C) 2019 Tulir Asokan // Copyright (C) 2021 Tulir Asokan
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by
@ -50,7 +50,7 @@ class InstanceDatabase extends Component {
this.order = new Map() this.order = new Map()
} }
async componentWillMount() { async componentDidMount() {
const tables = new Map(Object.entries(await api.getInstanceDatabase(this.props.instanceID))) const tables = new Map(Object.entries(await api.getInstanceDatabase(this.props.instanceID)))
for (const [name, table] of tables) { for (const [name, table] of tables) {
table.name = name table.name = name

View File

@ -1,5 +1,5 @@
// maubot - A plugin-based Matrix bot system. // maubot - A plugin-based Matrix bot system.
// Copyright (C) 2019 Tulir Asokan // Copyright (C) 2021 Tulir Asokan
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by
@ -42,7 +42,7 @@ class LogEntry extends PureComponent {
return <> return <>
{req.method} {req.path} {req.method} {req.path}
<div className="content"> <div className="content">
{Object.entries(req.content).length > 0 {Object.entries(req.content || {}).length > 0
&& <JSONTree data={{ content: req.content }} hideRoot={true}/>} && <JSONTree data={{ content: req.content }} hideRoot={true}/>}
</div> </div>
</> </>

View File

@ -1,5 +1,5 @@
// maubot - A plugin-based Matrix bot system. // maubot - A plugin-based Matrix bot system.
// Copyright (C) 2019 Tulir Asokan // Copyright (C) 2021 Tulir Asokan
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by
@ -51,7 +51,7 @@ class Dashboard extends Component {
} }
} }
async componentWillMount() { async componentDidMount() {
const [instanceList, clientList, pluginList, homeservers] = await Promise.all([ const [instanceList, clientList, pluginList, homeservers] = await Promise.all([
api.getInstances(), api.getClients(), api.getPlugins(), api.getClientAuthServers(), api.getInstances(), api.getClients(), api.getPlugins(), api.getClientAuthServers(),
api.updateDebugOpenFileEnabled()]) api.updateDebugOpenFileEnabled()])

View File

@ -1,5 +1,5 @@
// maubot - A plugin-based Matrix bot system. // maubot - A plugin-based Matrix bot system.
// Copyright (C) 2019 Tulir Asokan // Copyright (C) 2021 Tulir Asokan
// //
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by // it under the terms of the GNU Affero General Public License as published by
@ -18,69 +18,72 @@ div.log
width: 100% width: 100%
overflow: auto overflow: auto
> div.lines div.log > div.lines
text-align: left text-align: left
font-size: 12px font-size: 12px
max-height: 100% max-height: 100%
min-width: 100% min-width: 100%
font-family: "Fira Code", monospace font-family: "Fira Code", monospace
display: table display: table
> div.row div.log > div.lines > div.row
display: table-row display: table-row
white-space: pre white-space: pre
&.debug &.trace
background-color: $background opacity: .75
&:nth-child(odd) &.debug, &.trace
background-color: $background-dark background-color: $background
&.info &:nth-child(odd)
background-color: #AAFAFA background-color: $background-dark
&:nth-child(odd) &.info
background-color: #66FAFA background-color: #AAFAFA
&.warning, &.warn &:nth-child(odd)
background-color: #FABB77 background-color: #66FAFA
&:nth-child(odd) &.warning, &.warn
background-color: #FAAA55 background-color: #FABB77
&.error &:nth-child(odd)
background-color: #FAAAAA background-color: #FAAA55
&:nth-child(odd) &.error
background-color: #FA9999 background-color: #FAAAAA
&.fatal &:nth-child(odd)
background-color: #CC44CC background-color: #FA9999
&:nth-child(odd) &.fatal
background-color: #AA44AA background-color: #CC44CC
&.unfocused &:nth-child(odd)
opacity: .25 background-color: #AA44AA
> span &.unfocused
padding: .125rem .25rem opacity: .25
display: table-cell
&:first-child > span
padding-left: 0 padding: .125rem .25rem
display: table-cell
&:last-child &:first-child
padding-right: 0 padding-left: 0
a &:last-child
color: inherit padding-right: 0
text-decoration: none
&:hover a
text-decoration: underline color: inherit
text-decoration: none
> span.text &:hover
> div.content > * text-decoration: underline
background-color: inherit !important
margin: 0 !important > span.text
> div.content > *
background-color: inherit !important
margin: 0 !important

File diff suppressed because it is too large Load Diff