Commit 2328939b authored by davelopez's avatar davelopez
Browse files

Display history name

This will retrieve the history from the server for now. I should be replaced by the corresponding pinia store in the next release.
parent e6757c2f
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -19,7 +19,13 @@ const mockGetExportRecords = getExportRecords as jest.MockedFunction<typeof getE
mockGetExportRecords.mockResolvedValue([]);

const FAKE_HISTORY_ID = "fake-history-id";
const FAKE_HISTORY = {
    id: FAKE_HISTORY_ID,
    name: "fake-history-name",
};

const REMOTE_FILES_API_ENDPOINT = new RegExp("/api/remote_files/plugins");
const GET_HISTORY_ENDPOINT = new RegExp(`/api/histories/${FAKE_HISTORY_ID}`);

type FilesSourcePluginList = components["schemas"]["FilesSourcePlugin"][];
const REMOTE_FILES_API_RESPONSE: FilesSourcePluginList = [
@@ -50,12 +56,19 @@ describe("HistoryExport.vue", () => {
    beforeEach(async () => {
        axiosMock = new MockAdapter(axios);
        axiosMock.onGet(REMOTE_FILES_API_ENDPOINT).reply(200, []);
        axiosMock.onGet(GET_HISTORY_ENDPOINT).reply(200, FAKE_HISTORY);
    });

    afterEach(() => {
        axiosMock.restore();
    });

    it("should render the history name", async () => {
        const wrapper = await mountHistoryExport();

        expect(wrapper.find("#history-name").text()).toBe(FAKE_HISTORY.name);
    });

    it("should render export options", async () => {
        const wrapper = await mountHistoryExport();

+21 −1
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ import ExportRecordDetails from "components/Common/ExportRecordDetails.vue";
import ExportRecordTable from "components/Common/ExportRecordTable.vue";
import ExportOptions from "./ExportOptions.vue";
import ExportToFileSourceForm from "components/Common/ExportForm.vue";
import { getHistoryById } from "@/store/historyStore/model/queries";
import { getExportRecords, exportToFileSource, reimportHistoryFromRecord } from "./services";
import { useTaskMonitor } from "composables/taskMonitor";
import { useFileSources } from "composables/fileSources";
@@ -13,6 +14,9 @@ import { useShortTermStorage, DEFAULT_EXPORT_PARAMS } from "composables/shortTer
import { useConfirmDialog } from "composables/confirmDialog";
import { copy as sendToClipboard } from "utils/clipboard";
import { absPath } from "@/utils/redirect";
import { faFileExport } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { library } from "@fortawesome/fontawesome-svg-core";

const {
    isRunning: isExportTaskRunning,
@@ -39,11 +43,18 @@ const props = defineProps({
    },
});

library.add(faFileExport);

const POLLING_DELAY = 3000;

const history = ref(null);
const isLoadingHistory = ref(true);

const exportParams = reactive(DEFAULT_EXPORT_PARAMS);
const isLoadingRecords = ref(true);
const exportRecords = ref(null);

const historyName = computed(() => history.value?.name ?? props.historyId);
const latestExportRecord = computed(() => (exportRecords.value?.length ? exportRecords.value.at(0) : null));
const previousExportRecords = computed(() => (exportRecords.value ? exportRecords.value.slice(1) : null));
const hasPreviousExports = computed(() => previousExportRecords.value?.length > 0);
@@ -58,6 +69,10 @@ const actionMessageVariant = ref(null);

onMounted(async () => {
    updateExports();
    //TODO: replace direct query with useHistoriesStore in 23.1
    isLoadingHistory.value = true;
    history.value = await getHistoryById(props.historyId);
    isLoadingHistory.value = false;
});

watch(isExportTaskRunning, (newValue, oldValue) => {
@@ -161,7 +176,12 @@ function updateExportParams(newParams) {
</script>
<template>
    <span class="history-export-component">
        <h1 class="h-lg">Export history {{ props.historyId }}</h1>
        <font-awesome-icon icon="file-export" size="2x" class="text-primary float-left mr-2" />
        <h1 class="h-lg">
            Export
            <loading-span v-if="isLoadingHistory" spinner-only />
            <b v-else id="history-name">{{ historyName }}</b>
        </h1>

        <export-options
            id="history-export-options"