budibase/packages/builder/src/components/settings/UpdateAPIKeyModal.svelte

38 lines
1015 B
Svelte
Raw Normal View History

2022-02-09 21:30:52 +01:00
<script>
import { ModalContent, Body, notifications } from "@budibase/bbui"
2022-02-09 21:30:52 +01:00
import { auth } from "stores/portal"
import { onMount } from "svelte"
import CopyInput from "components/common/inputs/CopyInput.svelte"
2022-02-09 21:30:52 +01:00
let apiKey = null
async function generateAPIKey() {
try {
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")
}
// 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>
<CopyInput bind:value={apiKey} label="API key" />
2022-02-10 00:16:24 +01:00
</ModalContent>