From 30691986540228424d76db4ab6c8e3f9e721fb1c Mon Sep 17 00:00:00 2001 From: Sebastian Martinez Date: Mon, 12 Feb 2024 16:24:23 -0300 Subject: [PATCH] Use existing components for new issue view --- src/views/projects/Issue.svelte | 4 +- src/views/projects/Issue/IssueTeaser.svelte | 6 +- src/views/projects/Issue/New.svelte | 160 ++++---------------- 3 files changed, 37 insertions(+), 133 deletions(-) diff --git a/src/views/projects/Issue.svelte b/src/views/projects/Issue.svelte index 0edd9e6bf..ea31fbebd 100644 --- a/src/views/projects/Issue.svelte +++ b/src/views/projects/Issue.svelte @@ -560,10 +560,12 @@ } } }} /> - {:else} + {:else if issue.discussion[0].body} + {:else} + No description {/if}
{#if session} diff --git a/src/views/projects/Issue/IssueTeaser.svelte b/src/views/projects/Issue/IssueTeaser.svelte index a3be6779e..30c723a23 100644 --- a/src/views/projects/Issue/IssueTeaser.svelte +++ b/src/views/projects/Issue/IssueTeaser.svelte @@ -110,7 +110,11 @@ issue: issue.id, }}> - + {#if !issue.title} + No title + {:else} + + {/if} diff --git a/src/views/projects/Issue/New.svelte b/src/views/projects/Issue/New.svelte index 0c58b595c..d698f4a29 100644 --- a/src/views/projects/Issue/New.svelte +++ b/src/views/projects/Issue/New.svelte @@ -5,70 +5,37 @@ import * as router from "@app/lib/router"; import * as utils from "@app/lib/utils"; import { HttpdClient } from "@httpd-client"; - import { embed } from "@app/lib/file"; import { httpdStore } from "@app/lib/httpd"; import AssigneeInput from "@app/views/projects/Cob/AssigneeInput.svelte"; import AuthenticationErrorModal from "@app/modals/AuthenticationErrorModal.svelte"; - import Badge from "@app/components/Badge.svelte"; - import Button from "@app/components/Button.svelte"; import CobHeader from "@app/views/projects/Cob/CobHeader.svelte"; import ErrorMessage from "@app/components/ErrorMessage.svelte"; - import InlineMarkdown from "@app/components/InlineMarkdown.svelte"; + import ExtendedTextarea from "@app/components/ExtendedTextarea.svelte"; import LabelInput from "@app/views/projects/Cob/LabelInput.svelte"; import Layout from "@app/views/projects/Layout.svelte"; - import Markdown from "@app/components/Markdown.svelte"; - import NodeId from "@app/components/NodeId.svelte"; import TextInput from "@app/components/TextInput.svelte"; - import Textarea from "@app/components/Textarea.svelte"; export let baseUrl: BaseUrl; export let project: Project; export let rawPath: (commit?: string) => string; - let preview: boolean = false; - let selectionStart = 0; - let selectionEnd = 0; - let issueTitle = ""; - let issueText = ""; let assignees: string[] = []; let labels: string[] = []; - let creatingIssue: boolean = false; - const api = new HttpdClient(baseUrl); - const newEmbeds = new Map(); - function handleFileDrop(event: { detail: DragEvent }) { - event.detail.preventDefault(); - if (event.detail.dataTransfer) { - const embeds = Array.from(event.detail.dataTransfer.files).map(embed); - void Promise.all(embeds).then(embeds => - embeds.forEach(({ oid, name, content }) => { - newEmbeds.set(oid, { name, content }); - const embedText = `![${name}](${oid})\n`; - issueText = issueText - .slice(0, selectionStart) - .concat(embedText, issueText.slice(selectionEnd)); - selectionStart += embedText.length; - selectionEnd = selectionStart; - }), - ); - } - } - - async function createIssue(sessionId: string) { + async function createIssue( + sessionId: string, + title: string, + description: string, + embeds: Map, + ) { try { const result = await api.project.createIssue( project.id, - { - title: issueTitle, - description: issueText, - assignees: assignees, - embeds: [...newEmbeds.values()], - labels: labels, - }, + { title, description, assignees, embeds: [...embeds.values()], labels }, sessionId, ); @@ -91,7 +58,6 @@ } } - $: valid = issueTitle && issueText; $: session = $httpdStore.state === "authenticated" && utils.isLocal(baseUrl.hostname) ? $httpdStore.session @@ -103,13 +69,6 @@ display: flex; min-height: 100%; } - .actions { - display: flex; - justify-content: flex-end; - flex-direction: row; - gap: 1rem; - margin-top: 1rem; - } .metadata { display: flex; flex-direction: column; @@ -122,100 +81,39 @@ .editor { flex: 2; } - .author { - display: flex; - align-items: center; - gap: 0.5rem; - } {#if session} + {@const session_ = session}
- {#if !preview} - - {:else if issueTitle} - - {:else} - No title - {/if} - - - {#if preview} - open - {/if} + - {#if !preview} -