mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-08 10:18:07 -06:00
start implementing editing of existing domain permissions
This commit is contained in:
parent
6473886c8e
commit
7d253550b3
21 changed files with 617 additions and 116 deletions
|
|
@ -22,6 +22,7 @@ import { gtsApi } from "../../gts-api";
|
|||
import {
|
||||
replaceCacheOnMutation,
|
||||
removeFromCacheOnMutation,
|
||||
updateCacheOnMutation,
|
||||
} from "../../query-modifiers";
|
||||
import { listToKeyedObject } from "../../transforms";
|
||||
import type {
|
||||
|
|
@ -55,6 +56,36 @@ const extended = gtsApi.injectEndpoints({
|
|||
...replaceCacheOnMutation("domainAllows")
|
||||
}),
|
||||
|
||||
updateDomainBlock: build.mutation<DomainPerm, any>({
|
||||
query: (formData) => ({
|
||||
method: "PUT",
|
||||
url: `/api/v1/admin/domain_blocks/${formData.id}`,
|
||||
asForm: true,
|
||||
body: formData,
|
||||
discardEmpty: false
|
||||
}),
|
||||
...updateCacheOnMutation("domainBlocks", {
|
||||
key: (_draft, newData) => {
|
||||
return newData.domain;
|
||||
}
|
||||
})
|
||||
}),
|
||||
|
||||
updateDomainAllow: build.mutation<DomainPerm, any>({
|
||||
query: (formData) => ({
|
||||
method: "PUT",
|
||||
url: `/api/v1/admin/domain_allows/${formData.id}`,
|
||||
asForm: true,
|
||||
body: formData,
|
||||
discardEmpty: false
|
||||
}),
|
||||
...updateCacheOnMutation("domainAllows", {
|
||||
key: (_draft, newData) => {
|
||||
return newData.domain;
|
||||
}
|
||||
})
|
||||
}),
|
||||
|
||||
removeDomainBlock: build.mutation<DomainPerm, string>({
|
||||
query: (id) => ({
|
||||
method: "DELETE",
|
||||
|
|
@ -91,6 +122,16 @@ const useAddDomainBlockMutation = extended.useAddDomainBlockMutation;
|
|||
*/
|
||||
const useAddDomainAllowMutation = extended.useAddDomainAllowMutation;
|
||||
|
||||
/**
|
||||
* Update a single domain permission (block) by PUTing to `/api/v1/admin/domain_blocks/{id}`.
|
||||
*/
|
||||
const useUpdateDomainBlockMutation = extended.useUpdateDomainBlockMutation;
|
||||
|
||||
/**
|
||||
* Update a single domain permission (allow) by PUTing to `/api/v1/admin/domain_allows/{id}`.
|
||||
*/
|
||||
const useUpdateDomainAllowMutation = extended.useUpdateDomainAllowMutation;
|
||||
|
||||
/**
|
||||
* Remove a single domain permission (block) by DELETEing to `/api/v1/admin/domain_blocks/{id}`.
|
||||
*/
|
||||
|
|
@ -104,6 +145,8 @@ const useRemoveDomainAllowMutation = extended.useRemoveDomainAllowMutation;
|
|||
export {
|
||||
useAddDomainBlockMutation,
|
||||
useAddDomainAllowMutation,
|
||||
useUpdateDomainBlockMutation,
|
||||
useUpdateDomainAllowMutation,
|
||||
useRemoveDomainBlockMutation,
|
||||
useRemoveDomainAllowMutation
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue