Skip to content
Snippets Groups Projects

Resolve "Update Workflow Modal"

Merged Daniel Göbel requested to merge feature/45-update-workflow-modal into development
3 files
+ 63
23
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -15,7 +15,7 @@ import {
@@ -15,7 +15,7 @@ import {
requiredRepositoryFiles,
requiredRepositoryFiles,
determineGitIcon,
determineGitIcon,
} from "@/utils/GitRepository";
} from "@/utils/GitRepository";
import { valid, lte } from "semver";
import { valid, lte, inc } from "semver";
import { latestVersion as calculateLatestVersion } from "@/utils/Workflow";
import { latestVersion as calculateLatestVersion } from "@/utils/Workflow";
// Bootstrap Elements
// Bootstrap Elements
@@ -26,11 +26,12 @@ let successToast: Toast | null = null;
@@ -26,11 +26,12 @@ let successToast: Toast | null = null;
// Form Elements
// Form Elements
// =============================================================================
// =============================================================================
const workflowUpdateForm = ref<HTMLFormElement | undefined>(undefined);
const workflowUpdateForm = ref<HTMLFormElement | undefined>(undefined);
const workflowIconInput = ref<HTMLInputElement | undefined>(undefined);
const workflowIconInputElement = ref<HTMLInputElement | undefined>(undefined);
const workflowVersionElement = ref<HTMLInputElement | undefined>(undefined);
const workflowVersionElement = ref<HTMLInputElement | undefined>(undefined);
const workflowGitCommitHashElement = ref<HTMLInputElement | undefined>(
const workflowGitCommitHashElement = ref<HTMLInputElement | undefined>(
undefined
undefined
);
);
 
const workflowIconElement = ref<HTMLImageElement | undefined>(undefined);
// Constants
// Constants
// =============================================================================
// =============================================================================
@@ -82,6 +83,12 @@ const gitIcon = computed<string>(() =>
@@ -82,6 +83,12 @@ const gitIcon = computed<string>(() =>
determineGitIcon(props.workflow.repository_url)
determineGitIcon(props.workflow.repository_url)
);
);
 
const showIcon = computed<boolean>(
 
() =>
 
latestVersion.value.icon_url != undefined ||
 
workflowUpdate.icon != undefined
 
);
 
// Emitted Events
// Emitted Events
// =============================================================================
// =============================================================================
const emit = defineEmits<{
const emit = defineEmits<{
@@ -91,7 +98,16 @@ const emit = defineEmits<{
@@ -91,7 +98,16 @@ const emit = defineEmits<{
// Functions
// Functions
// =============================================================================
// =============================================================================
function iconChanged() {
function iconChanged() {
workflowUpdate.icon = workflowIconInput.value?.files?.[0].slice();
workflowUpdate.icon = workflowIconInputElement.value?.files?.[0].slice();
 
if (workflowUpdate.icon != undefined) {
 
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
 
workflowIconElement.value!.src = URL.createObjectURL(
 
workflowUpdate.icon.slice()
 
);
 
} else {
 
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
 
workflowIconElement.value!.src = latestVersion.value.icon_url ?? "";
 
}
}
}
function modalClosed() {
function modalClosed() {
@@ -140,11 +156,13 @@ function checkRepository() {
@@ -140,11 +156,13 @@ function checkRepository() {
function resetForm() {
function resetForm() {
modalClosed();
modalClosed();
 
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
 
workflowIconElement.value!.src = latestVersion.value.icon_url ?? "";
workflowUpdate.version = "";
workflowUpdate.version = "";
workflowUpdate.icon = undefined;
workflowUpdate.icon = undefined;
workflowUpdate.git_commit_hash = "";
workflowUpdate.git_commit_hash = "";
if (workflowIconInput.value != undefined) {
if (workflowIconInputElement.value != undefined) {
workflowIconInput.value.value = "";
workflowIconInputElement.value.value = "";
}
}
}
}
@@ -215,8 +233,8 @@ onMounted(() => {
@@ -215,8 +233,8 @@ onMounted(() => {
>
>
<template v-slot:header>
<template v-slot:header>
Update Workflow
Update Workflow
<span class="fw-bold">{{ props.workflow.name }}</span></template
<span class="fw-bold">{{ props.workflow.name }}</span>
>
</template>
<template v-slot:body>
<template v-slot:body>
<form
<form
id="workflowUpdateForm"
id="workflowUpdateForm"
@@ -232,6 +250,12 @@ onMounted(() => {
@@ -232,6 +250,12 @@ onMounted(() => {
target="_blank"
target="_blank"
>{{ props.workflow.repository_url }}</a
>{{ props.workflow.repository_url }}</a
>
>
 
<img
 
:src="latestVersion.icon_url"
 
ref="workflowIconElement"
 
class="float-end"
 
:hidden="!showIcon"
 
/>
</div>
</div>
<div class="mb-3">
<div class="mb-3">
<label for="workflowGitCommitInput" class="form-label"
<label for="workflowGitCommitInput" class="form-label"
@@ -274,7 +298,7 @@ onMounted(() => {
@@ -274,7 +298,7 @@ onMounted(() => {
type="text"
type="text"
class="form-control"
class="form-control"
id="workflowRepositoryInput"
id="workflowRepositoryInput"
placeholder="v1.0.0"
:placeholder="inc(latestVersion.version, 'patch') ?? undefined"
maxlength="10"
maxlength="10"
required
required
ref="workflowVersionElement"
ref="workflowVersionElement"
@@ -293,7 +317,7 @@ onMounted(() => {
@@ -293,7 +317,7 @@ onMounted(() => {
>
>
<input
<input
type="file"
type="file"
ref="workflowIconInput"
ref="workflowIconInputElement"
accept="image/*"
accept="image/*"
class="form-control"
class="form-control"
id="workflowIconInput"
id="workflowIconInput"
@@ -344,4 +368,9 @@ onMounted(() => {
@@ -344,4 +368,9 @@ onMounted(() => {
</bootstrap-modal>
</bootstrap-modal>
</template>
</template>
<style scoped></style>
<style scoped>
 
img {
 
max-height: 32px;
 
max-width: 32px;
 
}
 
</style>
Loading