|
7 | 7 | import OpenGraph from '$lib/components/OpenGraph.svelte'; |
8 | 8 | import { getInstallCommand, getRunCommand } from '$lib/installInstructions'; |
9 | 9 | import { faGithub } from '@fortawesome/free-brands-svg-icons'; |
10 | | - import { faChevronCircleRight, faStar, faSync } from '@fortawesome/free-solid-svg-icons'; |
| 10 | + import { faChevronCircleRight, faStar, faSync, faTrash } from '@fortawesome/free-solid-svg-icons'; |
11 | 11 | import Fa from 'svelte-fa'; |
12 | 12 | import { Highlight } from 'svelte-highlight'; |
13 | 13 | import { bash } from 'svelte-highlight/languages'; |
|
19 | 19 | import NeovimPluginMetaData from '$lib/components/NeovimPluginMetaData.svelte'; |
20 | 20 | import { humanizeRelative } from '$lib/utils'; |
21 | 21 | import { session } from '$lib/stores/session'; |
| 22 | + import { trpc } from '$lib/trpc/client'; |
| 23 | + import { page } from '$app/stores'; |
| 24 | + import { goto } from '$app/navigation'; |
22 | 25 |
|
23 | 26 | export let data: PageData; |
24 | 27 | $: ({ config, plugins, languageServers } = data); |
25 | | - $: pluginManager = plugins?.find(p => p.category === 'plugin-manager')?.name ?? "unknown" |
| 28 | + $: pluginManager = plugins?.find((p) => p.category === 'plugin-manager')?.name ?? 'unknown'; |
26 | 29 |
|
| 30 | + async function deleteConfig() { |
| 31 | + await trpc($page).deleteConfig.mutate({ id: config.id }); |
| 32 | + goto(`/${config.owner}`); |
| 33 | + } |
27 | 34 | </script> |
28 | 35 |
|
29 | 36 | <svelte:head> |
|
69 | 76 | {humanizeRelative(new Date().getTime() - new Date(config.lastSyncedAt).getTime())}</span |
70 | 77 | > |
71 | 78 | </div> |
72 | | - |
73 | | - <a href="https://github.com/{config.owner}/{config.repo}" target="_blank"> |
74 | | - <Button text="GitHub" icon={faGithub} /> |
75 | | - </a> |
| 79 | + <div class="flex gap-1 items-center justify-between font-semibold"> |
| 80 | + {#if $session.user?.id === config.userId} |
| 81 | + <Button text="Delete" icon={faTrash} on:click={deleteConfig} /> |
| 82 | + {/if} |
| 83 | + <a href="https://github.com/{config.owner}/{config.repo}" target="_blank"> |
| 84 | + <Button text="GitHub" icon={faGithub} /> |
| 85 | + </a> |
| 86 | + </div> |
76 | 87 | </div> |
77 | 88 | <NeovimConfigMetaData |
78 | 89 | syncing={false} |
79 | | - pluginManager={pluginManager} |
| 90 | + {pluginManager} |
80 | 91 | pluginCount={config.pluginCount?.toString()} |
81 | 92 | root={config.root} |
82 | 93 | initFile={config.initFile} |
|
0 commit comments