diff options
| author | Md Saban <45597394+mdsaban@users.noreply.github.com> | 2024-06-30 03:44:44 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-29 23:14:44 +0100 |
| commit | e107f8b6c250759ab0f884b2fdd0283fae15cfe5 (patch) | |
| tree | d1b9123c4bd4ec6cd8df5f18b026250ffdfdf608 /apps/web/components/dashboard/admin/AdminActions.tsx | |
| parent | a63713032ff6b15b80348f724246e7abea40c8a4 (diff) | |
| download | karakeep-e107f8b6c250759ab0f884b2fdd0283fae15cfe5.tar.zst | |
ui: refactor admin settings page (#249)
* ui: refactor admin ui
* fix: pr comments
* chore: lint fix
* chore: refactor
* minor tweaks
---------
Co-authored-by: MohamedBassem <me@mbassem.com>
Diffstat (limited to 'apps/web/components/dashboard/admin/AdminActions.tsx')
| -rw-r--r-- | apps/web/components/dashboard/admin/AdminActions.tsx | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/apps/web/components/dashboard/admin/AdminActions.tsx b/apps/web/components/dashboard/admin/AdminActions.tsx new file mode 100644 index 00000000..783f7e76 --- /dev/null +++ b/apps/web/components/dashboard/admin/AdminActions.tsx @@ -0,0 +1,79 @@ +"use client"; + +import { ActionButton } from "@/components/ui/action-button"; +import { toast } from "@/components/ui/use-toast"; +import { api } from "@/lib/trpc"; + +export default function AdminActions() { + const { mutate: recrawlLinks, isPending: isRecrawlPending } = + api.admin.recrawlLinks.useMutation({ + onSuccess: () => { + toast({ + description: "Recrawl enqueued", + }); + }, + onError: (e) => { + toast({ + variant: "destructive", + description: e.message, + }); + }, + }); + + const { mutate: reindexBookmarks, isPending: isReindexPending } = + api.admin.reindexAllBookmarks.useMutation({ + onSuccess: () => { + toast({ + description: "Reindex enqueued", + }); + }, + onError: (e) => { + toast({ + variant: "destructive", + description: e.message, + }); + }, + }); + + return ( + <div> + <div className="mb-2 mt-8 text-xl font-medium">Actions</div> + <div className="flex flex-col gap-2 sm:w-1/2"> + <ActionButton + variant="destructive" + loading={isRecrawlPending} + onClick={() => + recrawlLinks({ crawlStatus: "failure", runInference: true }) + } + > + Recrawl Failed Links Only + </ActionButton> + <ActionButton + variant="destructive" + loading={isRecrawlPending} + onClick={() => + recrawlLinks({ crawlStatus: "all", runInference: true }) + } + > + Recrawl All Links + </ActionButton> + <ActionButton + variant="destructive" + loading={isRecrawlPending} + onClick={() => + recrawlLinks({ crawlStatus: "all", runInference: false }) + } + > + Recrawl All Links (Without Inference) + </ActionButton> + <ActionButton + variant="destructive" + loading={isReindexPending} + onClick={() => reindexBookmarks()} + > + Reindex All Bookmarks + </ActionButton> + </div> + </div> + ); +} |
