Skip to content

Commit

Permalink
feat(analyses): disable analysis control buttons if build status is n…
Browse files Browse the repository at this point in the history
…ot "finished" build_image
  • Loading branch information
brucetony committed Sep 6, 2024
1 parent 4ed0710 commit 8cab744
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 6 deletions.
53 changes: 51 additions & 2 deletions components/analysis/AnalysesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,22 @@ import { FilterMatchMode } from "primevue/api";
import SearchBar from "~/components/table/SearchBar.vue";
import {
getApprovalStatusSeverity,
getBuildStatusSeverity,
getRunStatusSeverity,
} from "~/utils/status-tag-severity";
import { AnalysisNodeRunStatus, ApprovalStatus } from "~/services/Api";
import {
AnalysisNodeRunStatus,
ApprovalStatus,
AnalysisBuildStatus,
} from "~/services/Api";
const expandedRows = ref();
const analyses = ref();
const expandRowEntries = [];
const runStatuses = Object.values(AnalysisNodeRunStatus);
const approvalStatuses = Object.values(ApprovalStatus);
const buildStatuses = Object.values(AnalysisBuildStatus);
const { data: response, status, error } = await getAnalysisNodes();
Expand All @@ -39,7 +45,7 @@ function onToggleRowExpansion(rowIds) {
const defaultFilters = {
global: { value: null, matchMode: FilterMatchMode.CONTAINS },
approval_status: { value: null, matchMode: FilterMatchMode.IN },
// "analysis.build_status": { value: null, matchMode: FilterMatchMode.IN },
"analysis.build_status": { value: null, matchMode: FilterMatchMode.IN },
run_status: { value: null, matchMode: FilterMatchMode.IN },
// Below are more examples
// "analysis.name": { value: null, matchMode: FilterMatchMode.CONTAINS },
Expand Down Expand Up @@ -80,6 +86,13 @@ function updateRunStatus(analysisNodeId: string, newStatus: string) {
<Card class="contentCard">
<template #title>Analyses</template>
<template #content>
<InlineMessage severity="warn">
Some controls may be disabled!
</InlineMessage>
<p>
If the image for the analysis is not yet <b>finished</b> (see Build
Status), a container for the analysis cannot be started.
</p>
<DataTable
:value="analyses"
v-model:expandedRows="expandedRows"
Expand Down Expand Up @@ -137,6 +150,7 @@ function updateRunStatus(analysisNodeId: string, newStatus: string) {
:options="approvalStatuses"
optionLabel=""
placeholder="Any"
display="chip"
class="p-column-filter"
>
<template #option="slotProps">
Expand All @@ -151,6 +165,40 @@ function updateRunStatus(analysisNodeId: string, newStatus: string) {
</MultiSelect>
</template>
</Column>
<Column
field="analysis.build_status"
header="Build Status"
filterField="analysis.build_status"
:showFilterMatchModes="false"
>
<template #body="{ data }">
<Tag
v-if="data.analysis.build_status"
:value="data.analysis.build_status"
:severity="getBuildStatusSeverity(data.analysis.build_status)"
/>
</template>
<template #filter="{ filterModel }">
<MultiSelect
v-model="filterModel.value"
:options="buildStatuses"
optionLabel=""
placeholder="Any"
display="chip"
class="p-column-filter"
>
<template #option="slotProps">
<div class="flex align-items-center gap-2">
<Tag
v-if="slotProps.option"
:value="slotProps.option"
:severity="getBuildStatusSeverity(slotProps.option)"
/>
</div>
</template>
</MultiSelect>
</template>
</Column>
<Column
field="run_status"
header="Run Status"
Expand Down Expand Up @@ -228,6 +276,7 @@ function updateRunStatus(analysisNodeId: string, newStatus: string) {
v-if="slotProps.data.approval_status === 'approved'"
>
<AnalysisControlButtons
:analysisBuildStatus="slotProps.data.analysis.build_status"
:analysisRunStatus="slotProps.data.run_status"
:analysisNodeId="slotProps.data.id"
:analysisId="slotProps.data.analysis_id"
Expand Down
22 changes: 18 additions & 4 deletions components/analysis/AnalysisControlButtons.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<script setup lang="ts">
import {
AnalysisBuildStatus,
AnalysisNodeRunStatus,
type BodyCreateAnalysisPoPost,
} from "~/services/Api";
const props = defineProps({
analysisBuildStatus: String,
analysisRunStatus: String,
analysisNodeId: String,
analysisId: String,
Expand Down Expand Up @@ -145,7 +147,10 @@ async function onDeleteAnalysis() {
v-tooltip.top="'Start the analysis'"
severity="success"
style="margin-right: 10px"
:disabled="!buttonStatuses.playActive"
:disabled="
!buttonStatuses.playActive ||
!(props.analysisBuildStatus === AnalysisBuildStatus.Finished)
"
:loading="loading"
@click="onStartAnalysis()"
/>
Expand All @@ -156,7 +161,10 @@ async function onDeleteAnalysis() {
v-tooltip.top="'Rerun the analysis'"
severity="success"
style="margin-right: 10px"
:disabled="!buttonStatuses.rerunActive"
:disabled="
!buttonStatuses.rerunActive ||
!(props.analysisBuildStatus === AnalysisBuildStatus.Finished)
"
:loading="loading"
@click="onStartAnalysis()"
/>
Expand All @@ -166,7 +174,10 @@ async function onDeleteAnalysis() {
v-tooltip.top="'Stop the analysis'"
severity="warn"
style="margin-right: 10px"
:disabled="!buttonStatuses.stopActive"
:disabled="
!buttonStatuses.stopActive ||
!(props.analysisBuildStatus === AnalysisBuildStatus.Finished)
"
:loading="loading"
@click="onStopAnalysis()"
/>
Expand All @@ -175,7 +186,10 @@ async function onDeleteAnalysis() {
aria-label="Delete"
v-tooltip.top="'Delete the analysis container'"
severity="danger"
:disabled="!buttonStatuses.deleteActive"
:disabled="
!buttonStatuses.deleteActive ||
!(props.analysisBuildStatus === AnalysisBuildStatus.Finished)
"
:loading="loading"
@click="onDeleteAnalysis()"
/>
Expand Down
1 change: 1 addition & 0 deletions components/projects/ProposalTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const updateFilters = (filterText: string) => {
:options="approvalStatuses"
optionLabel=""
placeholder="Any"
display="chip"
class="p-column-filter"
>
<template #option="slotProps">
Expand Down

0 comments on commit 8cab744

Please sign in to comment.