From 237a0024dfcbc09537a3c0f59ca74d1aef20e21b Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 12 Aug 2021 15:29:19 +0100 Subject: [PATCH] Temporary bot menu. --- external/lang | 2 +- package.json | 4 +- .../popovers/ServerIdentityModal.tsx | 4 + src/pages/settings/Settings.tsx | 13 +- src/pages/settings/panes/MyBots.tsx | 150 ++++++++++++++++++ yarn.lock | 16 +- 6 files changed, 177 insertions(+), 12 deletions(-) create mode 100644 src/pages/settings/panes/MyBots.tsx diff --git a/external/lang b/external/lang index 7be90cf4..cec5d62b 160000 --- a/external/lang +++ b/external/lang @@ -1 +1 @@ -Subproject commit 7be90cf44ba08d235ae52d7dc6073d8f9347232b +Subproject commit cec5d62b11fa52bafea39ee905a8354fb840a078 diff --git a/package.json b/package.json index 630bea65..e01c977d 100644 --- a/package.json +++ b/package.json @@ -115,8 +115,8 @@ "react-virtualized-auto-sizer": "^1.0.5", "react-virtuoso": "^1.10.4", "redux": "^4.1.0", - "revolt-api": "^0.5.2-alpha.0", - "revolt.js": "5.0.1-alpha.1", + "revolt-api": "0.5.2-alpha.1", + "revolt.js": "5.0.1-alpha.2", "rimraf": "^3.0.2", "sass": "^1.35.1", "shade-blend-color": "^1.0.0", diff --git a/src/context/intermediate/popovers/ServerIdentityModal.tsx b/src/context/intermediate/popovers/ServerIdentityModal.tsx index eb6e449e..3ef55266 100644 --- a/src/context/intermediate/popovers/ServerIdentityModal.tsx +++ b/src/context/intermediate/popovers/ServerIdentityModal.tsx @@ -7,6 +7,7 @@ import Button from "../../../components/ui/Button"; import InputBox from "../../../components/ui/InputBox"; import Modal from "../../../components/ui/Modal"; import Overline from "../../../components/ui/Overline"; +import Tip from "../../../components/ui/Tip"; import { FileUploader } from "../../revoltjs/FileUploads"; import { useClient } from "../../revoltjs/RevoltClient"; @@ -30,6 +31,9 @@ export const ServerIdentityModal = observer(({ server, onClose }: Props) => { return ( + + This section is under construction. + Nickname

, }, { - divider: true, id: "experiments", icon: , title: , }, + { + divider: true, + category: "revolt", + id: "bots", + icon: , + title: , + }, { id: "feedback", icon: , @@ -148,6 +156,9 @@ export default function Settings() { + + + diff --git a/src/pages/settings/panes/MyBots.tsx b/src/pages/settings/panes/MyBots.tsx new file mode 100644 index 00000000..14b8df9c --- /dev/null +++ b/src/pages/settings/panes/MyBots.tsx @@ -0,0 +1,150 @@ +import { observer } from "mobx-react-lite"; +import { Bot } from "revolt-api/types/Bots"; + +import { useEffect, useState } from "preact/hooks"; + +import { useClient } from "../../../context/revoltjs/RevoltClient"; + +import UserShort from "../../../components/common/user/UserShort"; +import Button from "../../../components/ui/Button"; +import Checkbox from "../../../components/ui/Checkbox"; +import InputBox from "../../../components/ui/InputBox"; +import Overline from "../../../components/ui/Overline"; +import Tip from "../../../components/ui/Tip"; + +interface Data { + _id: string; + username: string; + public: boolean; + interactions_url?: string; +} + +function BotEditor({ bot }: { bot: Data }) { + const client = useClient(); + const [data, setData] = useState(bot); + + function save() { + const changes: Record = {}; + if (data.username !== bot.username) changes.name = data.username; + if (data.public !== bot.public) changes.public = data.public; + if (data.interactions_url !== bot.interactions_url) + changes.interactions_url = data.interactions_url; + + client.bots.edit(bot._id, changes); + } + + return ( +

+

+ + setData({ ...data, username: e.currentTarget.value }) + } + /> +

+

+ setData({ ...data, public: v })}> + is public + +

+

interactions url: (reserved for the future)

+

+ + setData({ + ...data, + interactions_url: e.currentTarget.value, + }) + } + /> +

+ +
+ ); +} + +export const MyBots = observer(() => { + const client = useClient(); + const [bots, setBots] = useState(undefined); + + useEffect(() => { + client.bots.fetchOwned().then(({ bots }) => setBots(bots)); + // eslint-disable-next-line + }, []); + + const [name, setName] = useState(""); + + return ( +
+ + This section is under construction. + + create a new bot +

+ setName(e.currentTarget.value)} + /> +

+

+ +

+ my bots + {bots?.map((bot) => { + const user = client.users.get(bot._id); + return ( +
+ +

+ token:{" "} + + {bot.token} + +

+ + +
+ ); + })} +
+ ); +}); diff --git a/yarn.lock b/yarn.lock index a1dc21b4..b3c04822 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3600,15 +3600,15 @@ reusify@^1.0.4: resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== -revolt-api@^0.5.2-alpha.0: - version "0.5.2-alpha.0" - resolved "https://registry.yarnpkg.com/revolt-api/-/revolt-api-0.5.2-alpha.0.tgz#a41f44ee38622636c9b5b5843f9e2798a79f00d3" - integrity sha512-VI/o4nQTPXrDCVdFpZFfZfj7Q4nunj62gftdmYJtuSmXx+6eN2Nve7QQZjNt6UIH6Dc/IDgiFDcBdafBF9YXug== +revolt-api@0.5.2-alpha.1: + version "0.5.2-alpha.1" + resolved "https://registry.yarnpkg.com/revolt-api/-/revolt-api-0.5.2-alpha.1.tgz#2164d04cd5581267ce59142557666bd386bc85c4" + integrity sha512-3OrjYCDNPkJ+yO9d87NJvuUDAbungEbUfrfHlvFwV8hJze/RMkuYUTFWe1HyBMwBC7F/yWQK+2V7IoifC5STmw== -revolt.js@5.0.1-alpha.1: - version "5.0.1-alpha.1" - resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.0.1-alpha.1.tgz#9af021d05d3cd098d0383c64e1fe10c70f2fb07a" - integrity sha512-QIbnR25ICey8iopMzu0FBueo7gd0ddZQVoyyC++jg4Rvt0zlcAHJfx/YTapZxzTFo0/u/YEgD68GuTh8ybmFdg== +revolt.js@5.0.1-alpha.2: + version "5.0.1-alpha.2" + resolved "https://registry.yarnpkg.com/revolt.js/-/revolt.js-5.0.1-alpha.2.tgz#ec4876da57367453ef38d6c9bf84828c5f068b74" + integrity sha512-QBulAUAqBGCY62jJjpKa/+y4QBjTEzPfHl/R9NY6wJ/nCfYX7/leOFWb1PWJ09KerPfbYEiQvQYk8YYFF9HptQ== dependencies: axios "^0.19.2" eventemitter3 "^4.0.7"