-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add description to topics table and details
- Loading branch information
1 parent
9b84ea5
commit 842da80
Showing
6 changed files
with
81 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
src/routes/console/project-[project]/messaging/topics/topic-[topic]/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
<script lang="ts"> | ||
import { Container } from '$lib/layout'; | ||
import DangerZone from './dangerZone.svelte'; | ||
import UpdateName from './updateName.svelte'; | ||
import Details from './details.svelte'; | ||
import UpdateDescription from './updateDescription.svelte'; | ||
import UpdateName from './updateName.svelte'; | ||
</script> | ||
|
||
<Container> | ||
<Details /> | ||
<UpdateName /> | ||
<UpdateDescription /> | ||
<DangerZone /> | ||
</Container> |
65 changes: 65 additions & 0 deletions
65
src/routes/console/project-[project]/messaging/topics/topic-[topic]/updateDescription.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<script lang="ts"> | ||
import { CardGrid, Heading } from '$lib/components'; | ||
import { Button, Form, InputText } from '$lib/elements/forms'; | ||
import { onMount } from 'svelte'; | ||
import { topic } from './store'; | ||
import { invalidate } from '$app/navigation'; | ||
import { trackEvent, Submit, trackError } from '$lib/actions/analytics'; | ||
import { Dependencies } from '$lib/constants'; | ||
import { addNotification } from '$lib/stores/notifications'; | ||
import { sdk } from '$lib/stores/sdk'; | ||
let description: string = null; | ||
onMount(async () => { | ||
description ??= $topic.description; | ||
}); | ||
async function updateDescription() { | ||
try { | ||
await sdk.forProject.client.call( | ||
'PATCH', | ||
new URL(`${sdk.forProject.client.config.endpoint}/messaging/topics/${$topic.$id}`), | ||
{ | ||
'X-Appwrite-Project': sdk.forProject.client.config.project, | ||
'content-type': 'application/json', | ||
'X-Appwrite-Mode': 'admin' | ||
}, | ||
{ | ||
description | ||
} | ||
); | ||
await invalidate(Dependencies.MESSAGING_TOPIC); | ||
addNotification({ | ||
message: 'Description has been updated', | ||
type: 'success' | ||
}); | ||
trackEvent(Submit.MessagingTopicUpdateDescription); | ||
} catch (error) { | ||
addNotification({ | ||
message: error.message, | ||
type: 'error' | ||
}); | ||
trackError(error, Submit.MessagingTopicUpdateDescription); | ||
} | ||
} | ||
</script> | ||
|
||
<Form onSubmit={updateDescription}> | ||
<CardGrid> | ||
<Heading tag="h6" size="7">Description</Heading> | ||
|
||
<svelte:fragment slot="aside"> | ||
<ul data-private> | ||
<InputText | ||
id="description" | ||
label="Description" | ||
placeholder="Enter description" | ||
autocomplete={false} | ||
bind:value={description} /> | ||
</ul> | ||
</svelte:fragment> | ||
|
||
<svelte:fragment slot="actions"> | ||
<Button disabled={description === $topic.description} submit>Update</Button> | ||
</svelte:fragment> | ||
</CardGrid> | ||
</Form> |