Skip to content

Commit

Permalink
Add edit release notes artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
yunusefendi52 committed Dec 17, 2024
1 parent 153b2fa commit 37d7b92
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 75 deletions.
5 changes: 0 additions & 5 deletions app.d.ts

This file was deleted.

Binary file modified bun.lockb
Binary file not shown.
63 changes: 63 additions & 0 deletions components/DialogEditArtifact.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<template>
<!-- TODO: Check responsiveness on mobile -->
<Drawer class="!w-[30rem]" position="right" header="Edit" v-model:visible="show">
<form id="editForm" @submit.prevent="onFormSubmit" class="flex flex-col gap-4 w-full">
<input name="orgName" hidden required :value="orgName" />
<input name="appName" hidden required :value="appName" />
<input name="releaseId" hidden required :value="releaseId" />
<div class="flex flex-col gap-1">
<Textarea rows="5" form="editForm" :pt="{
root: {
'name': 'releaseNotes',
},
}" id="releaseNotes" ref="refTextArea" placeholder="Release Notes" />
</div>
<Button type="submit" severity="secondary" label="Save" data-testid="save_edit_btn" :loading="isPending" />
</form>
</Drawer>
</template>

<script setup lang="ts">
const { params } = useRoute()
const appName = params.appId as string
const orgName = params.orgName as string
const releaseId = params.detailArtifact as string
const show = defineModel<boolean>()
const props = defineProps({
releaseNotes: {
type: String,
required: true,
},
})
const emit = defineEmits(['onEdited'])
const refTextArea = ref()
if (import.meta.client) {
watchEffect(() => {
const releaseNotes = props?.releaseNotes
if (refTextArea.value) {
// @ts-ignore
document.getElementById('releaseNotes').value = releaseNotes
}
})
}
const { mutate, isPending } = useMutation({
mutationFn: async (r: any) => {
await $fetch.raw('/api/artifacts/edit-artifact', {
method: 'post',
body: r,
})
show.value = false
emit('onEdited')
},
})
const onFormSubmit = (ev: Event) => {
const request = getObjectForm(ev)
mutate(request)
};
</script>
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"@hebilicious/vue-query-nuxt": "^0.3.0",
"@libsql/client": "^0.14.0",
"@plist/parse": "^1.1.0",
"@primevue/nuxt-module": "^4.0.2",
"@primevue/themes": "^4.0.2",
"@primevue/nuxt-module": "^4.2.5",
"@primevue/themes": "^4.2.5",
"@tanstack/vue-query": "^5.28.9",
"@vueuse/core": "^10.10.0",
"@vueuse/nuxt": "^10.10.0",
Expand All @@ -43,7 +43,7 @@
"moment": "^2.30.1",
"pg": "^8.11.3",
"primeicons": "^7.0.0",
"primevue": "^4.0.2",
"primevue": "^4.2.5",
"simple-xml-to-json": "^1.2.3",
"slugify": "^1.6.6",
"uuidv7": "^1.0.1",
Expand Down
38 changes: 27 additions & 11 deletions pages/orgs/[orgName]/apps/[appId]/releases/[detailArtifact].vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,19 @@
</div>
</div>
</div>
<div class="card flex flex-col gap-3 mx-4 mb-4">
<div class="card flex flex-col gap-3 mx-4 mb-4" style="white-space: break-spaces;">
<div class="flex flex-col md:flex-row items-stretch gap-2">
<div class="flex flex-col gap-1 flex-1">
<!-- <span class="text-sm">Release Id {{ detailArtifact?.releaseId }}</span> -->
<span class="font-semibold text-xl">Version {{ detailArtifact?.versionName2 }} ({{
detailArtifact?.versionCode2
}})</span>
}})</span>
<span class="text-lg">{{ formatDate(detailArtifact?.createdAt) }}</span>
</div>
</div>
<div class="flex flex-col gap-2">
<span class="font-semibold">Release Notes</span>
<label>{{ detailArtifact?.releaseNotes ?? '-' }}</label>
</div>
<div class="flex flex-col gap-2">
<span class="font-semibold">Downloads</span>
<label>{{ '-' }}</label>
<span>{{ '-' }}</span>
</div>
<div class="flex flex-col gap-2">
<span class="font-semibold">Groups</span>
Expand All @@ -56,12 +52,20 @@
<div class="flex flex-col gap-2">
<span class="font-semibold">File metadata</span>
<div class="flex flex-col">
<label>{{ `MD5: ${detailArtifact?.fileMetadata?.md5?.replaceAll('"', '')}` }}</label>
<label>{{ `File Extension: ${detailArtifact?.extension}`
}}</label>
<label>{{ `File Size: ${formatBytes(detailArtifact?.fileMetadata?.contentLength ?? 0)}` }}</label>
<span>{{ `MD5: ${detailArtifact?.fileMetadata?.md5?.replaceAll('"', '')}` }}</span>
<span>{{ `File Extension: ${detailArtifact?.extension}`
}}</span>
<span>{{ `File Size: ${formatBytes(detailArtifact?.fileMetadata?.contentLength || 0)}` }}</span>
</div>
</div>
<div class="flex flex-col gap-2">
<span class="font-semibold">Release Notes</span>
<span>{{ detailArtifact?.releaseNotes || '-' }}</span>
</div>
</div>
<div v-if="showEdit">
<DialogEditArtifact v-model="showEdit" :release-notes="detailArtifact?.releaseNotes ?? ''"
@on-edited="refreshData" />
</div>
</template>

Expand Down Expand Up @@ -174,6 +178,13 @@ const confirmDelete = (event: any) => {
const menu = ref()
const items = ref<MenuItem[]>([
{
label: 'Edit',
icon: 'pi pi-pencil',
command: () => {
showEdit.value = true
},
},
{
label: 'Delete',
icon: 'pi pi-trash',
Expand All @@ -187,4 +198,9 @@ const toggle = (event: Event) => {
menu.value.toggle(event)
}
const showEdit = ref(false)
const refreshData = () => {
refresh()
}
</script>
28 changes: 28 additions & 0 deletions server/api/artifacts/edit-artifact.post.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export default defineEventHandler(async (event) => {
const { orgName, appName, releaseId, releaseNotes } = await readValidatedBody(event, z.object({
orgName: z.string().min(1).max(128),
appName: z.string().min(1).max(128),
releaseId: z.string().min(1).transform(e => parseInt(e)),
releaseNotes: z.string().max(5000).nullish(),
}).parse)

if (await roleEditNotAllowed(event, orgName)) {
throw createError({
message: 'Request edit artifact not valid',
statusCode: 400,
})
}

const { userApp } = await getUserApp(event, orgName, appName)

const db = event.context.drizzle
await db.update(tables.artifacts)
.set({
releaseNotes: releaseNotes,
})
.where(and(
eq(tables.artifacts.organizationId, userApp.organizationsId!),
eq(tables.artifacts.appsId, userApp.id),
eq(tables.artifacts.releaseId, releaseId),
))
})
112 changes: 56 additions & 56 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
# bun ./bun.lockb --hash: 9C6BD510801E669E-b9e992dc8afcebe9-C3460F3346A56EF7-17f2b2a0b5817ed9
# bun ./bun.lockb --hash: 471406DA03FCAB71-dbd7609dacd0b1f0-78C7D76ACD43F5ED-e317421320cbae69


"@aashutoshrathi/word-wrap@^1.2.3":
Expand Down Expand Up @@ -1849,7 +1849,7 @@
untyped "^1.4.2"
"@nuxt/schema" "3.11.1"

"@nuxt/kit@^3.11.2", "@nuxt/kit@^3.2.0", "@nuxt/kit@^3.7.3", "@nuxt/kit@^3.8.2":
"@nuxt/kit@^3.11.2", "@nuxt/kit@^3.2.0", "@nuxt/kit@^3.8.2":
version "3.11.2"
resolved "https://registry.npmjs.org/@nuxt/kit/-/kit-3.11.2.tgz"
integrity sha512-yiYKP0ZWMW7T3TCmsv4H8+jEsB/nFriRAR8bKoSqSV9bkVYWPE36sf7JDux30dQ91jSlQG6LQkB3vCHYTS2cIg==
Expand Down Expand Up @@ -1899,7 +1899,7 @@
untyped "^1.4.2"
"@nuxt/schema" "3.12.4"

"@nuxt/kit@^3.13.2", "@nuxt/kit@^3.8.2":
"@nuxt/kit@^3.13.2", "@nuxt/kit@^3.7.3", "@nuxt/kit@^3.8.2":
version "3.13.2"
resolved "https://registry.npmjs.org/@nuxt/kit/-/kit-3.13.2.tgz"
integrity sha512-KvRw21zU//wdz25IeE1E5m/aFSzhJloBRAQtv+evcFeZvuroIxpIQuUqhbzuwznaUwpiWbmwlcsp5uOWmi4vwA==
Expand Down Expand Up @@ -2283,66 +2283,66 @@
resolved "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.25.tgz"
integrity sha512-j7P6Rgr3mmtdkeDGTe0E/aYyWEWVtc5yFXtHCRHs28/jptDEWfaVOc5T7cblqy1XKPPfCxJc/8DwQ5YgLOZOVQ==

"@primeuix/styled@^0.0.5":
version "0.0.5"
resolved "https://registry.npmjs.org/@primeuix/styled/-/styled-0.0.5.tgz"
integrity sha512-pVoGn/uPkVm/DyF3TR3EmH/pL/dP4nR42FcYbVduFq9VfO3KVeOEqvcCULHXos66RZO9MCbCFUoLy6ctf9GUGQ==
"@primeuix/styled@^0.3.2":
version "0.3.2"
resolved "https://registry.npmjs.org/@primeuix/styled/-/styled-0.3.2.tgz"
integrity sha512-ColZes0+/WKqH4ob2x8DyNYf1NENpe5ZguOvx5yCLxaP8EIMVhLjWLO/3umJiDnQU4XXMLkn2mMHHw+fhTX/mw==
dependencies:
"@primeuix/utils" "^0.0.5"
"@primeuix/utils" "^0.3.2"

"@primeuix/utils@^0.0.5":
version "0.0.5"
resolved "https://registry.npmjs.org/@primeuix/utils/-/utils-0.0.5.tgz"
integrity sha512-ntUiUgtRtkF8KuaxHffzhYxQxoXk6LAPHm7CVlFjdqS8Rx8xRkLkZVyo84E+pO2hcNFkOGVP/GxHhQ2s94O8zA==
"@primeuix/utils@^0.3.2":
version "0.3.2"
resolved "https://registry.npmjs.org/@primeuix/utils/-/utils-0.3.2.tgz"
integrity sha512-B+nphqTQeq+i6JuICLdVWnDMjONome2sNz0xI65qIOyeB4EF12CoKRiCsxuZ5uKAkHi/0d1LqlQ9mIWRSdkavw==

"@primevue/auto-import-resolver@4.0.2":
version "4.0.2"
resolved "https://registry.npmjs.org/@primevue/auto-import-resolver/-/auto-import-resolver-4.0.2.tgz"
integrity sha512-RVCwZVK4Yzx8K3fFvF3O7CX+EirkmxAx3+ZWbatSMT+zRUhsdNFKh5jcPYJk/yGs/hI4lh8lTOqhFf2uXCflQg==
"@primevue/auto-import-resolver@4.2.5":
version "4.2.5"
resolved "https://registry.npmjs.org/@primevue/auto-import-resolver/-/auto-import-resolver-4.2.5.tgz"
integrity sha512-+jeH7QhzyKYYo1yWvJ/HDeHWTddvIbtI6/Gr4pY0hW94RHvRXlnWS20lrXGQ60P/3pkl6p423wysY1hhvsMUjQ==
dependencies:
"@primevue/metadata" "4.0.2"
"@primevue/metadata" "4.2.5"

"@primevue/core@4.0.2":
version "4.0.2"
resolved "https://registry.npmjs.org/@primevue/core/-/core-4.0.2.tgz"
integrity sha512-SpCIQ1LG6B66cecmZt1UdFeY7tbdJrgnhncADolfE9fcCyTSBtbaVLLhCV2E4Q9myMwCFE5KQxqazA4rdLWk4w==
"@primevue/core@4.2.5":
version "4.2.5"
resolved "https://registry.npmjs.org/@primevue/core/-/core-4.2.5.tgz"
integrity sha512-+oWBIQs5dLd2Ini4KEVOlvPILk989EHAskiFS3R/dz3jeOllJDMZFcSp8V9ddV0R3yDaPdLVkfHm2Q5t42kU2Q==
dependencies:
"@primeuix/styled" "^0.0.5"
"@primeuix/utils" "^0.0.5"
"@primeuix/styled" "^0.3.2"
"@primeuix/utils" "^0.3.2"

"@primevue/icons@4.0.2":
version "4.0.2"
resolved "https://registry.npmjs.org/@primevue/icons/-/icons-4.0.2.tgz"
integrity sha512-S1VEpMsx4uUAsTjZtII03LQqgocYwSKbXMF0YDFWybY8r5LaHaveVZxS/i+KbsCLaL18BXJw0L/7L1eQdJHzaA==
"@primevue/icons@4.2.5":
version "4.2.5"
resolved "https://registry.npmjs.org/@primevue/icons/-/icons-4.2.5.tgz"
integrity sha512-WFbUMZhQkXf/KmwcytkjGVeJ9aGEDXjP3uweOjQZMmRdEIxFnqYYpd90wE90JE1teZn3+TVnT4ZT7ejGyEXnFQ==
dependencies:
"@primeuix/utils" "^0.0.5"
"@primevue/core" "4.0.2"
"@primeuix/utils" "^0.3.2"
"@primevue/core" "4.2.5"

"@primevue/metadata@4.0.2":
version "4.0.2"
resolved "https://registry.npmjs.org/@primevue/metadata/-/metadata-4.0.2.tgz"
integrity sha512-zJ5fZNKDuuOf86qNm4NbVzoW/d3n9p8lnt1qsqIMEXWrlGjhRbGg+vbjUKhiUpgKNvwy+HsnAnRFnPCyxuByfQ==
"@primevue/metadata@4.2.5":
version "4.2.5"
resolved "https://registry.npmjs.org/@primevue/metadata/-/metadata-4.2.5.tgz"
integrity sha512-dABQ8BecGg6NRnrLx11MvmCQCFn2inUEmao8t17/Tc2wxwoXY315TaakDa5ebOdYnTG91lh+NX7SBpTH+MYIyQ==

"@primevue/nuxt-module@^4.0.2":
version "4.0.2"
resolved "https://registry.npmjs.org/@primevue/nuxt-module/-/nuxt-module-4.0.2.tgz"
integrity sha512-vK5CFypYvdJO8EtVEpiQlvyrYjKF97V3dzRST+QeVvRd7gy49tgFTwU2jp7fZsnSnyAq74ZhJWeOid0gUmbJdg==
"@primevue/nuxt-module@^4.2.5":
version "4.2.5"
resolved "https://registry.npmjs.org/@primevue/nuxt-module/-/nuxt-module-4.2.5.tgz"
integrity sha512-/zs9pYCu81Le56l7HCz1AUv6g3eW17XLx3BNCeE3BcYxQAcwTP9rd9uUxvrRvigQABGoc21Ye+Wb02uv1/uRtg==
dependencies:
"@nuxt/kit" "^3.7.3"
"@primeuix/styled" "^0.0.5"
"@primeuix/utils" "^0.0.5"
"@primeuix/styled" "^0.3.2"
"@primeuix/utils" "^0.3.2"
unplugin-vue-components "0.27.0"
pathe "^1.1.2"
"@primevue/auto-import-resolver" "4.0.2"
"@primevue/metadata" "4.0.2"
primevue "4.0.2"
primevue "4.2.5"
"@primevue/auto-import-resolver" "4.2.5"
"@primevue/metadata" "4.2.5"

"@primevue/themes@^4.0.2":
version "4.0.2"
resolved "https://registry.npmjs.org/@primevue/themes/-/themes-4.0.2.tgz"
integrity sha512-DGrdFOWRUb8/qDX+Hjkg0SkU2hvo6EmEE5/fA/+NSlLAemj5fcR8r3wo9jhFMIU0QVNl17jZycuL5taU0H72BA==
"@primevue/themes@^4.2.5":
version "4.2.5"
resolved "https://registry.npmjs.org/@primevue/themes/-/themes-4.2.5.tgz"
integrity sha512-8F7yA36xYIKtNuAuyBdZZEks/bKDwlhH5WjpqGGB0FdwfAEoBYsynQ5sdqcT2Lb/NsajHmS5lc++Ttlvr1g1Lw==
dependencies:
"@primeuix/styled" "^0.0.5"
"@primeuix/styled" "^0.3.2"

"@rollup/plugin-alias@^5.1.0":
version "5.1.0"
Expand Down Expand Up @@ -8694,15 +8694,15 @@ primeicons@^7.0.0:
resolved "https://registry.npmjs.org/primeicons/-/primeicons-7.0.0.tgz"
integrity sha512-jK3Et9UzwzTsd6tzl2RmwrVY/b8raJ3QZLzoDACj+oTJ0oX7L9Hy+XnVwgo4QVKlKpnP/Ur13SXV/pVh4LzaDw==

primevue@4.0.2, primevue@^4.0.2:
version "4.0.2"
resolved "https://registry.npmjs.org/primevue/-/primevue-4.0.2.tgz"
integrity sha512-bf5In//ixosZDOcfJ0iaBXhtQSpNC/CuAOE2KHd/SgUKZdij3VRljQ+I9+Be/TTxfikIeKH7eZ4gzDbWiIZurw==
primevue@4.2.5, primevue@^4.2.5:
version "4.2.5"
resolved "https://registry.npmjs.org/primevue/-/primevue-4.2.5.tgz"
integrity sha512-7UMOIJvdFz4jQyhC76yhNdSlHtXvVpmE2JSo2ndUTBWjWJOkYyT562rQ4ayO+bMdJLtzBGqgY64I9ZfEvNd7vQ==
dependencies:
"@primeuix/styled" "^0.0.5"
"@primeuix/utils" "^0.0.5"
"@primevue/icons" "4.0.2"
"@primevue/core" "4.0.2"
"@primeuix/styled" "^0.3.2"
"@primeuix/utils" "^0.3.2"
"@primevue/core" "4.2.5"
"@primevue/icons" "4.2.5"

proc-log@^3.0.0:
version "3.0.0"
Expand Down Expand Up @@ -10489,7 +10489,7 @@ vscode-uri@^3.0.2:
"@vue/server-renderer" "3.4.23"
"@vue/compiler-sfc" "3.4.23"

[email protected], "vue@>=2.7 || >=3", vue@>=3.2.13, vue@^3, vue@^3.2.0, vue@^3.2.25, vue@^3.3.4, vue@^3.4.32:
[email protected], "vue@>=2.7 || >=3", vue@>=3.2.13, vue@^3, vue@^3.2.0, vue@^3.2.25, vue@^3.3.0, vue@^3.3.4, vue@^3.4.32:
version "3.4.38"
resolved "https://registry.npmjs.org/vue/-/vue-3.4.38.tgz"
integrity sha512-f0ZgN+mZ5KFgVv9wz0f4OgVKukoXtS3nwET4c2vLBGQR50aI8G0cqbFtLlX9Yiyg3LFGBitruPHt2PxwTduJEw==
Expand Down

0 comments on commit 37d7b92

Please sign in to comment.