({ script, guildId, plugin }: {
script: Script,
plugin?: Plugin,
guildId: string,
})
| 821 | } |
| 822 | |
| 823 | function ScriptDetails({ script, guildId, plugin }: { |
| 824 | script: Script, |
| 825 | plugin?: Plugin, |
| 826 | guildId: string, |
| 827 | }) { |
| 828 | const session = useSession(); |
| 829 | const notifications = UseNotifications(); |
| 830 | const { reload, delScript } = useCurrentGuildScripts(); |
| 831 | |
| 832 | async function deleteConfirm() { |
| 833 | if (window.confirm("are you sure you want to delete this script?")) { |
| 834 | await delScript(script.id); |
| 835 | } |
| 836 | } |
| 837 | |
| 838 | async function updatePluginVersion() { |
| 839 | const resp = await session.apiClient.updateScriptPlugin(guildId, script.id); |
| 840 | if (isErrorResponse(resp)) { |
| 841 | notifications.push({ class: "error", message: "failed updating plugin: " + resp.response?.description }); |
| 842 | } else { |
| 843 | reload(); |
| 844 | notifications.push({ class: "success", message: "updated plugin" }); |
| 845 | } |
| 846 | } |
| 847 | |
| 848 | return <Box sx={{ |
| 849 | display: "flex", |
| 850 | alignItems: "start", |
| 851 | flexDirection: "column", |
| 852 | }}> |
| 853 | <Stack direction={"row"} alignItems="center"> |
| 854 | {plugin ? ( |
| 855 | <> |
| 856 | <Typography variant="body1">{plugin.current_version === script.plugin_version_number ? |
| 857 | "Using the latest version" |
| 858 | : script.plugin_version_number === null |
| 859 | ? "Using a modified version" |
| 860 | : "New version available"}</Typography> |
| 861 | <AsyncOpButton disabled={plugin.current_version === script.plugin_version_number} onClick={updatePluginVersion} label="Update version"></AsyncOpButton> |
| 862 | <BlLink disabled={plugin.current_version === script.plugin_version_number} |
| 863 | to={`/servers/${guildId}/scripts/${script.id}/edit?diffMode=pluginPublished`}>View changes</BlLink> |
| 864 | </> |
| 865 | ) : null} |
| 866 | <BlLink to={`/servers/${guildId}/scripts/${script.id}/edit`}> |
| 867 | Edit |
| 868 | </BlLink> |
| 869 | <AsyncOpButton label="delete" onClick={() => deleteConfirm()}></AsyncOpButton> |
| 870 | </Stack> |
| 871 | {!script.enabled && <Alert severity='warning'> |
| 872 | This script is not enabled |
| 873 | </Alert>} |
| 874 | </Box> |
| 875 | } |
nothing calls this directly
no test coverage detected