Fix deletion

This commit is contained in:
Adria Navarro 2025-03-20 17:52:00 +01:00
parent a40c51eede
commit 04ad69a269
4 changed files with 9 additions and 8 deletions

View File

@ -7,7 +7,7 @@
Modal,
notifications,
} from "@budibase/bbui"
import type { OAuth2Config } from "@budibase/types"
import type { OAuth2Config } from "@/types"
import OAuth2ConfigModalContent from "./OAuth2ConfigModalContent.svelte"
import { confirm } from "@/helpers"
@ -26,7 +26,7 @@
warning: true,
onConfirm: async () => {
try {
await oauth2.delete(row.id)
await oauth2.delete(row._id, row._rev)
notifications.success(`Config '${row.name}' deleted successfully`)
} catch (e: any) {
let message = "Error deleting config"

View File

@ -60,8 +60,8 @@ export class OAuth2Store extends BudiStore<OAuth2StoreState> {
await this.fetch()
}
async delete(id: string) {
await API.oauth2.delete(id)
async delete(id: string, rev: string) {
await API.oauth2.delete(id, rev)
await this.fetch()
}

View File

@ -18,7 +18,7 @@ export interface OAuth2Endpoints {
update: (
config: UpdateOAuth2ConfigRequest
) => Promise<UpdateOAuth2ConfigResponse>
delete: (id: string) => Promise<void>
delete: (id: string, rev: string) => Promise<void>
validate: (config: ValidateConfigRequest) => Promise<ValidateConfigResponse>
}
@ -66,10 +66,11 @@ export const buildOAuth2Endpoints = (API: BaseAPIClient): OAuth2Endpoints => ({
/**
* Deletes an OAuth2 configuration by its id.
* @param id the ID of the OAuth2 config
* @param rev the rev of the OAuth2 config
*/
delete: async id => {
delete: async (id, rev) => {
return await API.delete<void, void>({
url: `/api/oauth2/${id}`,
url: `/api/oauth2/${id}/${rev}`,
})
},
validate: async function (

View File

@ -28,7 +28,7 @@ const updateSchema = Joi.object({
})
const validationSchema = Joi.object({
_id: Joi.string().required(),
_id: Joi.string(),
...baseSchema,
})