feat: add correct submit buttons to form modals

This commit is contained in:
Paul Makles 2022-07-06 12:49:24 +01:00
parent f9c6f5cd9d
commit 705dcd001b
16 changed files with 91 additions and 34 deletions

View file

@ -73,7 +73,7 @@
"@hcaptcha/react-hcaptcha": "^0.3.6", "@hcaptcha/react-hcaptcha": "^0.3.6",
"@insertish/vite-plugin-babel-macros": "^1.0.5", "@insertish/vite-plugin-babel-macros": "^1.0.5",
"@preact/preset-vite": "^2.0.0", "@preact/preset-vite": "^2.0.0",
"@revoltchat/ui": "1.0.65", "@revoltchat/ui": "1.0.69",
"@rollup/plugin-replace": "^2.4.2", "@rollup/plugin-replace": "^2.4.2",
"@styled-icons/boxicons-logos": "^10.38.0", "@styled-icons/boxicons-logos": "^10.38.0",
"@styled-icons/boxicons-regular": "^10.38.0", "@styled-icons/boxicons-regular": "^10.38.0",

View file

@ -1,3 +1,5 @@
import { Text } from "preact-i18n";
import { ModalForm } from "@revoltchat/ui"; import { ModalForm } from "@revoltchat/ui";
import { noop } from "../../../lib/js"; import { noop } from "../../../lib/js";
@ -26,6 +28,9 @@ export default function AddFriend({ ...props }: ModalProps<"add_friend">) {
callback={({ username }) => callback={({ username }) =>
client.api.post(`/users/friend`, { username }).then(noop) client.api.post(`/users/friend`, { username }).then(noop)
} }
submit={{
children: <Text id="app.special.modals.actions.ok" />,
}}
/> />
); );
} }

View file

@ -41,6 +41,10 @@ export default function BanMember({
callback={async ({ reason }) => callback={async ({ reason }) =>
void (await member.server!.banUser(member._id.user, { reason })) void (await member.server!.banUser(member._id.user, { reason }))
} }
submit={{
palette: "error",
children: <Text id="app.special.modals.actions.ban" />,
}}
/> />
); );
} }

View file

@ -96,6 +96,12 @@ export default function Confirmation(
break; break;
} }
}} }}
submit={{
palette: "error",
children: (
<Text id={`app.special.modals.actions.${event[1]}`} />
),
}}
/> />
); );
} }

View file

@ -39,6 +39,9 @@ export default function CreateCategory({
], ],
}); });
}} }}
submit={{
children: <Text id="app.special.modals.actions.create" />,
}}
/> />
); );
} }

View file

@ -67,6 +67,9 @@ export default function CreateChannel({
); );
} }
}} }}
submit={{
children: <Text id="app.special.modals.actions.create" />,
}}
/> />
); );
} }

View file

@ -40,6 +40,9 @@ export default function CreateGroup({ ...props }: ModalProps<"create_group">) {
history.push(`/channel/${group._id}`); history.push(`/channel/${group._id}`);
}} }}
submit={{
children: <Text id="app.special.modals.actions.create" />,
}}
/> />
); );
} }

View file

@ -71,6 +71,18 @@ export default function CreateInvite({
}, },
}} }}
callback={noopAsync} callback={noopAsync}
submit={{
children: <Text id="app.special.modals.actions.ok" />,
}}
actions={[
{
children: <Text id="app.context_menu.copy_link" />,
onClick: () =>
modalController.writeText(
`${window.location.protocol}//${window.location.host}/invite/${code}`,
),
},
]}
/> />
); );
} }

View file

@ -30,6 +30,9 @@ export default function CreateRole({
const role = await server.createRole(name); const role = await server.createRole(name);
callback(role.id); callback(role.id);
}} }}
submit={{
children: <Text id="app.special.modals.actions.create" />,
}}
/> />
); );
} }

View file

@ -52,6 +52,9 @@ export default function CreateServer({
history.push(`/server/${server._id}`); history.push(`/server/${server._id}`);
}} }}
submit={{
children: <Text id="app.special.modals.actions.create" />,
}}
/> />
); );
} }

View file

@ -38,6 +38,9 @@ export default function CustomStatus({
}, },
}) })
} }
submit={{
children: <Text id="app.special.modals.actions.save" />,
}}
/> />
); );
} }

View file

@ -30,6 +30,10 @@ export default function DeleteMessage({
}, },
}} }}
callback={() => target.delete()} callback={() => target.delete()}
submit={{
palette: "error",
children: <Text id="app.special.modals.actions.delete" />,
}}
/> />
); );
} }

View file

@ -27,6 +27,9 @@ export default function ImportTheme({ ...props }: ModalProps<"import_theme">) {
callback={async ({ data }) => callback={async ({ data }) =>
state.settings.theme.hydrate(JSON.parse(data)) state.settings.theme.hydrate(JSON.parse(data))
} }
submit={{
children: <Text id="app.special.modals.actions.ok" />,
}}
/> />
); );
} }

View file

@ -33,6 +33,10 @@ export default function KickMember({
}, },
}} }}
callback={() => member.kick()} callback={() => member.kick()}
submit={{
palette: "error",
children: <Text id="app.special.modals.actions.kick" />,
}}
/> />
); );
} }

View file

@ -669,14 +669,17 @@ export default function ContextMenus() {
userId !== uid && userId !== uid &&
uid !== server.owner uid !== server.owner
) { ) {
const member = client.members.getKey({
server: server._id,
user: user!._id,
})!;
if (member) {
if (serverPermissions & Permission.KickMembers) if (serverPermissions & Permission.KickMembers)
generateAction( generateAction(
{ {
action: "kick_member", action: "kick_member",
target: client.members.getKey({ target: member,
server: server._id,
user: user!._id,
})!,
}, },
undefined, // this is needed because generateAction uses positional, not named parameters undefined, // this is needed because generateAction uses positional, not named parameters
undefined, undefined,
@ -688,10 +691,7 @@ export default function ContextMenus() {
generateAction( generateAction(
{ {
action: "ban_member", action: "ban_member",
target: client.members.getKey({ target: member,
server: server._id,
user: user!._id,
})!,
}, },
undefined, undefined,
undefined, undefined,
@ -700,6 +700,7 @@ export default function ContextMenus() {
); );
} }
} }
}
if (queued) { if (queued) {
generateAction({ generateAction({

View file

@ -2231,9 +2231,9 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@revoltchat/ui@npm:1.0.65": "@revoltchat/ui@npm:1.0.69":
version: 1.0.65 version: 1.0.69
resolution: "@revoltchat/ui@npm:1.0.65" resolution: "@revoltchat/ui@npm:1.0.69"
dependencies: dependencies:
"@styled-icons/boxicons-logos": ^10.38.0 "@styled-icons/boxicons-logos": ^10.38.0
"@styled-icons/boxicons-regular": ^10.38.0 "@styled-icons/boxicons-regular": ^10.38.0
@ -2247,7 +2247,7 @@ __metadata:
react-virtuoso: ^2.12.0 react-virtuoso: ^2.12.0
peerDependencies: peerDependencies:
revolt.js: "*" revolt.js: "*"
checksum: 34a52672aa3aca1c62d884c62f2c85c0100b6adb21b7d01053e74e96cfa95cb76f125e1ca1f46afc586a8730b273746486525199f66969338e6c84ab1f21e7cd checksum: bb67870911689d7dccd82f96affdb0e3e89b2e688d4a7403ee9bbb6a0245dfc296f35636ababd5ed6b43a3ce26777cee03c453728088b4a29fed350dcc89ea37
languageName: node languageName: node
linkType: hard linkType: hard
@ -3554,7 +3554,7 @@ __metadata:
"@hcaptcha/react-hcaptcha": ^0.3.6 "@hcaptcha/react-hcaptcha": ^0.3.6
"@insertish/vite-plugin-babel-macros": ^1.0.5 "@insertish/vite-plugin-babel-macros": ^1.0.5
"@preact/preset-vite": ^2.0.0 "@preact/preset-vite": ^2.0.0
"@revoltchat/ui": 1.0.65 "@revoltchat/ui": 1.0.69
"@rollup/plugin-replace": ^2.4.2 "@rollup/plugin-replace": ^2.4.2
"@styled-icons/boxicons-logos": ^10.38.0 "@styled-icons/boxicons-logos": ^10.38.0
"@styled-icons/boxicons-regular": ^10.38.0 "@styled-icons/boxicons-regular": ^10.38.0