Skip to content

Commit

Permalink
Fix up loading failed error state in Dataset Attributes component
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed May 28, 2024
1 parent 093dcc8 commit 16cb727
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
14 changes: 4 additions & 10 deletions client/src/components/DatasetInformation/DatasetAttributes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,17 @@ async function mountDatasetAttributes(conversion_disable = false) {
return wrapper;
}

async function buildWrapperWithError(error) {
async function buildWrapperWithError(error: string) {
const axiosMock = new MockAdapter(axios);
axiosMock.onGet(`/dataset/get_edit?dataset_id=${DATASET_ID}`).reply(400);
const wrapper = mount(DatasetAttributes, {
propsData: {
datasetId: "dataset_id",
datasetId: DATASET_ID,
messageText: error,
messageVariant: "danger",
},
computed: {
hasError() {
return true;
},
},
localVue,
stubs: {
DatasetAttributesProvider: MockProvider({
result: null,
}),
FontAwesomeIcon: false,
FormElement: false,
},
Expand Down
10 changes: 5 additions & 5 deletions client/src/components/DatasetInformation/DatasetAttributes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { faBars, faCog, faDatabase, faExchangeAlt, faRedo, faSave, faUser } from
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { type AxiosError } from "axios";
import { BAlert, BButton, BTab, BTabs } from "bootstrap-vue";
import { computed, onMounted, ref } from "vue";
import { onMounted, ref } from "vue";
import { fetchDatasetAttributes } from "@/api/datasets";
import { setAttributes } from "@/components/DatasetInformation/services";
Expand All @@ -26,11 +26,11 @@ const props = defineProps<Props>();
const historyStore = useHistoryStore();
const loading = ref(false);
const messageText = ref("");
const loadingFailed = ref(false);
const messageText = ref<string>();
const messageVariant = ref("danger");
const formData = ref<Record<string, any>>({});
const datasetAttributes = ref<Record<string, any>>({});
const hasError = computed(() => messageVariant.value === "danger");
function onAttribute(data: object) {
formData.value["attribute"] = data;
Expand Down Expand Up @@ -77,7 +77,7 @@ async function loadDatasetAttributes() {
datasetAttributes.value = data;
} catch (e) {
const error = e as AxiosError<{ err_msg?: string }>;
loadingFailed.value = true;
onError(error.response?.data?.err_msg || "Unable to fetch available dataset attributes.");
} finally {
loading.value = false;
Expand All @@ -102,7 +102,7 @@ onMounted(async () => {
<BAlert v-if="loading" variant="info" show>
<LoadingSpan message="Loading dataset attributes..." />
</BAlert>
<div v-else-if="!hasError" class="mt-3">
<div v-else-if="!loadingFailed" class="mt-3">
<BTabs>
<BTab v-if="!datasetAttributes['attribute_disable']">
<template v-slot:title>
Expand Down

0 comments on commit 16cb727

Please sign in to comment.