Skip to content
Snippets Groups Projects
Verified Commit 8f88a25d authored by Daniel Göbel's avatar Daniel Göbel
Browse files

Show icon in update workflow modal

#45
parent 2ea98772
No related branches found
No related tags found
1 merge request!37Resolve "Update Workflow Modal"
This commit is part of merge request !37. Comments created here will be created in the context of that merge request.
...@@ -136,6 +136,9 @@ watch( ...@@ -136,6 +136,9 @@ watch(
>My Workflows</router-link >My Workflows</router-link
> >
</li> </li>
<li v-if="store.workflowReviewer || store.admin">
<a class="dropdown-item" href="#">Reviews</a>
</li>
</ul> </ul>
</li> </li>
</ul> </ul>
......
...@@ -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>
...@@ -21,7 +21,7 @@ const workflowsState = reactive<{ ...@@ -21,7 +21,7 @@ const workflowsState = reactive<{
name: "", name: "",
versions: [ versions: [
{ {
version: "", version: "1.0.0",
created_at: "01.01.2023", created_at: "01.01.2023",
git_commit_hash: "", git_commit_hash: "",
status: Status.CREATED, status: Status.CREATED,
...@@ -83,18 +83,26 @@ onMounted(() => { ...@@ -83,18 +83,26 @@ onMounted(() => {
Create Create
</button> </button>
</div> </div>
<card-transition-group <div v-if="!workflowsState.loading">
v-if="!workflowsState.loading" <card-transition-group
class="d-flex flex-wrap align-items-center justify-content-between mt-5" v-if="workflowsState.workflows.length > 0"
> class="d-flex flex-wrap align-items-center justify-content-between mt-5"
<workflow-with-versions-card >
v-for="workflow in workflowsState.workflows" <workflow-with-versions-card
:key="workflow.workflow_id" v-for="workflow in workflowsState.workflows"
:workflow="workflow" :key="workflow.workflow_id"
:loading="false" :workflow="workflow"
@workflow-update-click="workflowUpdateClick" :loading="false"
/> @workflow-update-click="workflowUpdateClick"
</card-transition-group> />
</card-transition-group>
<div v-else class="text-center mt-5 fs-2">
There are currently no workflows that you created.<br />
<a href="#" data-bs-toggle="modal" data-bs-target="#createWorkflowModal"
>Create a new one</a
>
</div>
</div>
<div <div
v-else v-else
class="d-flex flex-wrap align-items-center justify-content-between mt-5" class="d-flex flex-wrap align-items-center justify-content-between mt-5"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment