put plugin details in a modal

This commit is contained in:
Peter Clement 2022-09-05 09:35:24 +01:00
parent 1c67772973
commit 5941ebc615
2 changed files with 81 additions and 37 deletions

View File

@ -14,13 +14,11 @@
NPM: ["URL"], NPM: ["URL"],
Github: ["Github Token", "URL"], Github: ["Github Token", "URL"],
URL: ["Headers", "URL"], URL: ["Headers", "URL"],
File: ["Path", "Headers"], "File Upload": ["File Upload"],
Upload: ["Upload"],
} }
let file let file
let sourceValue = "NPM" let sourceValue = "NPM"
let typeValue = "Datasource" let typeValue = "Datasource"
let nameValue
let dynamicValues = {} let dynamicValues = {}
let verificationSuccessful = false let verificationSuccessful = false
@ -30,7 +28,7 @@
const url = dynamicValues["URL"] const url = dynamicValues["URL"]
switch (source) { switch (source) {
case "upload": case "file upload":
if (file) { if (file) {
await plugins.uploadPlugin(file, sourceValue) await plugins.uploadPlugin(file, sourceValue)
} }
@ -39,7 +37,6 @@
await plugins.createPlugin( await plugins.createPlugin(
typeValue, typeValue,
source, source,
nameValue,
url, url,
dynamicValues["Github Token"] dynamicValues["Github Token"]
) )
@ -48,13 +45,12 @@
await plugins.createPlugin( await plugins.createPlugin(
typeValue, typeValue,
source, source,
nameValue,
url, url,
dynamicValues["Headers"] dynamicValues["Headers"]
) )
break break
case "npm": case "npm":
await plugins.createPlugin(typeValue, source, nameValue, url) await plugins.createPlugin(typeValue, source, url)
break break
} }
} }
@ -86,16 +82,12 @@
<Select <Select
placeholder={null} placeholder={null}
bind:value={sourceValue} bind:value={sourceValue}
options={["NPM", "Github", "URL", "File", "Upload"]} options={["NPM", "Github", "URL", "File Upload"]}
/> />
</div> </div>
<div class="form-row">
<Label size="M">Name</Label>
<Input bind:value={nameValue} />
</div>
{#each authOptions[sourceValue] as option} {#each authOptions[sourceValue] as option}
{#if option === "Upload"} {#if option === "File Upload"}
<div class="form-row"> <div class="form-row">
<Label size="M">{option}</Label> <Label size="M">{option}</Label>

View File

@ -1,14 +1,18 @@
<script> <script>
import { Icon, Body, ActionMenu, MenuItem, Detail } from "@budibase/bbui" import {
Icon,
Body,
Modal,
ModalContent,
Button,
Label,
Input,
} from "@budibase/bbui"
import { plugins } from "stores/portal" import { plugins } from "stores/portal"
export let plugin export let plugin
$: console.log(plugin)
let modal
function editGroup() { let detailsModal
modal.show()
}
</script> </script>
<div class="row"> <div class="row">
@ -25,36 +29,72 @@
> >
{plugin.name} {plugin.name}
</Body> </Body>
<Detail size="S">
<div class="opacity">{plugin.schema.type}</div>
</Detail>
</div> </div>
</div> </div>
</div> </div>
<div class="desktop">{plugin.source || "-"}</div>
<div class="desktop">{plugin.author || "-"}</div>
<div class="desktop">{plugin.version}</div> <div class="desktop">{plugin.version}</div>
<div class="desktop">
{plugin.schema.type.charAt(0).toUpperCase() + plugin.schema.type.slice(1)}
</div>
<div> <div>
<div> <Icon on:click={detailsModal.show()} hoverable name="ChevronRight" />
<ActionMenu align="right">
<span slot="control">
<Icon hoverable name="More" />
</span>
<MenuItem
on:click={() => plugins.deletePlugin(plugin._id, plugin._rev)}
icon="Delete">Delete</MenuItem
>
<MenuItem on:click={() => editGroup(plugin)} icon="Edit">Edit</MenuItem>
</ActionMenu>
</div>
</div> </div>
</div> </div>
<Modal bind:this={detailsModal}>
<ModalContent
title="Plugin details"
showConfirmButton={false}
showCancelButton={false}
>
<div class="form-row">
<Label size="M">Type</Label>
<Input
disabled
value={plugin.schema.type.charAt(0).toUpperCase() +
plugin.schema.type.slice(1)}
/>
</div>
<div class="form-row">
<Label size="M">Source</Label>
<Input disabled value={plugin.source} />
</div>
<div class="form-row">
<Label size="M">Version</Label>
<Input disabled value={plugin.version} />
</div>
<div class="form-row">
<Label size="M">License</Label>
<Input disabled value={plugin.package.license} />
</div>
<div class="form-row">
<Label size="M">Author</Label>
<Input disabled value={plugin.package.author || "N/A"} />
</div>
<div class="footer" slot="footer">
<Button
newStyles
on:click={() => plugins.deletePlugin(plugin._id, plugin._rev)}
warning>Delete</Button
>
<Button
newStyles
on:click={() => plugins.deletePlugin(plugin._id, plugin._rev)}
>Update</Button
>
<Button cta newStyles on:click={detailsModal.hide()}>Done</Button>
</div>
</ModalContent>
</Modal>
<style> <style>
.row { .row {
display: grid; display: grid;
grid-template-columns: 0.3fr auto auto auto auto; grid-template-columns: 0.3fr auto auto auto;
align-items: center; align-items: center;
background: var(--background); background: var(--background);
height: 50px; height: 50px;
@ -70,6 +110,13 @@
display: flex; display: flex;
} }
.form-row {
display: grid;
grid-template-columns: 60px 1fr;
grid-gap: var(--spacing-l) var(--spacing-l);
align-items: center;
}
.opacity { .opacity {
opacity: 50%; opacity: 50%;
} }
@ -78,4 +125,9 @@
display: none !important; display: none !important;
} }
} }
.footer {
display: flex;
gap: var(--spacing-l);
}
</style> </style>