2022-02-09 21:30:52 +01:00
|
|
|
<script>
|
2022-02-28 15:29:19 +01:00
|
|
|
import { ModalContent, Body, notifications } from "@budibase/bbui"
|
2022-02-09 21:30:52 +01:00
|
|
|
import { auth } from "stores/portal"
|
|
|
|
import { onMount } from "svelte"
|
2022-02-28 15:29:19 +01:00
|
|
|
import CopyInput from "components/common/inputs/CopyInput.svelte"
|
2022-02-09 21:30:52 +01:00
|
|
|
|
|
|
|
let apiKey = null
|
|
|
|
|
|
|
|
async function generateAPIKey() {
|
|
|
|
try {
|
2022-02-10 20:06:49 +01:00
|
|
|
apiKey = await auth.generateAPIKey()
|
2022-02-09 21:30:52 +01:00
|
|
|
notifications.success("New API key generated.")
|
|
|
|
} catch (err) {
|
|
|
|
notifications.error("Unable to generate new API key")
|
|
|
|
}
|
2022-02-10 20:06:49 +01:00
|
|
|
// need to return false to keep modal open
|
|
|
|
return false
|
2022-02-09 21:30:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
onMount(async () => {
|
2022-02-10 00:16:24 +01:00
|
|
|
apiKey = await auth.fetchAPIKey()
|
2022-02-09 21:30:52 +01:00
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
2022-02-10 00:16:24 +01:00
|
|
|
<ModalContent
|
|
|
|
title="Developer information"
|
|
|
|
showConfirmButton={false}
|
|
|
|
showSecondaryButton={true}
|
|
|
|
secondaryButtonText="Re-generate key"
|
|
|
|
secondaryAction={generateAPIKey}
|
|
|
|
>
|
|
|
|
<Body size="S">
|
|
|
|
You can find information about your developer account here, such as the API
|
|
|
|
key used to access the Budibase API.
|
|
|
|
</Body>
|
2022-02-28 15:29:19 +01:00
|
|
|
<CopyInput bind:value={apiKey} label="API key" />
|
2022-02-10 00:16:24 +01:00
|
|
|
</ModalContent>
|