Implement delete
This commit is contained in:
parent
cbe9fba5a5
commit
6db7ea4458
|
@ -1,11 +1,20 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ActionMenu, Icon, MenuItem } from "@budibase/bbui"
|
import { oauth2 } from "@/stores/builder"
|
||||||
|
import { ActionMenu, Icon, MenuItem, notifications } from "@budibase/bbui"
|
||||||
|
import type { OAuth2Config } from "@budibase/types"
|
||||||
|
|
||||||
|
export let row: OAuth2Config
|
||||||
|
|
||||||
function onEdit() {
|
function onEdit() {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
function onDelete() {
|
async function onDelete() {
|
||||||
// TODO
|
try {
|
||||||
|
await oauth2.delete(row.id)
|
||||||
|
notifications.success(`Config '${row.name}' deleted successfully`)
|
||||||
|
} catch (e: any) {
|
||||||
|
notifications.error("Error deleting config")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,11 @@ export class OAuth2Store extends BudiStore<OAuth2StoreState> {
|
||||||
await API.oauth2.create(config)
|
await API.oauth2.create(config)
|
||||||
await this.fetch()
|
await this.fetch()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async delete(id: string) {
|
||||||
|
await API.oauth2.delete(id)
|
||||||
|
await this.fetch()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const oauth2 = new OAuth2Store()
|
export const oauth2 = new OAuth2Store()
|
||||||
|
|
|
@ -11,12 +11,12 @@ export interface OAuth2Endpoints {
|
||||||
create: (
|
create: (
|
||||||
config: UpsertOAuth2ConfigRequest
|
config: UpsertOAuth2ConfigRequest
|
||||||
) => Promise<UpsertOAuth2ConfigResponse>
|
) => Promise<UpsertOAuth2ConfigResponse>
|
||||||
|
delete: (id: string) => Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
export const buildOAuth2Endpoints = (API: BaseAPIClient): OAuth2Endpoints => ({
|
export const buildOAuth2Endpoints = (API: BaseAPIClient): OAuth2Endpoints => ({
|
||||||
/**
|
/**
|
||||||
* Gets all OAuth2 configurations for the app.
|
* Gets all OAuth2 configurations for the app.
|
||||||
* @param tableId the ID of the table
|
|
||||||
*/
|
*/
|
||||||
fetch: async () => {
|
fetch: async () => {
|
||||||
return (
|
return (
|
||||||
|
@ -42,4 +42,14 @@ export const buildOAuth2Endpoints = (API: BaseAPIClient): OAuth2Endpoints => ({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes an OAuth2 configuration by its id.
|
||||||
|
* @param id the ID of the OAuth2 config
|
||||||
|
*/
|
||||||
|
delete: async id => {
|
||||||
|
return await API.delete<void, void>({
|
||||||
|
url: `/api/oauth2/${id}`,
|
||||||
|
})
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue