Unverified Commit 1b5ba604 authored by Marius van den Beek's avatar Marius van den Beek Committed by GitHub
Browse files

Merge pull request #14325 from davelopez/22.05_allow_dataset_actions_in_new_tab

[22.05] Add HREF links to some history item actions
parents 53744eb2 95c2efb8
Loading
Loading
Loading
Loading
+24 −7
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@
                    :is-history-item="isHistoryItem"
                    :is-visible="item.visible"
                    :state="state"
                    :item-urls="itemUrls"
                    @delete="$emit('delete')"
                    @display="onDisplay"
                    @edit="onEdit"
@@ -81,6 +82,7 @@
                v-if="expandDataset"
                :dataset="item"
                :show-highlight="isHistoryItem"
                :item-urls="itemUrls"
                @edit="onEdit"
                @toggleHighlights="toggleHighlights" />
        </b-collapse>
@@ -165,6 +167,26 @@ export default {
        tagsDisabled() {
            return !this.expandDataset || !this.isHistoryItem;
        },
        isCollection() {
            return "collection_type" in this.item;
        },
        /** Relative URLs for history item actions */
        itemUrls() {
            const id = this.item.id;
            if (this.isCollection) {
                return {
                    edit: `collection/edit/${id}`,
                };
            }
            return {
                display: `datasets/${id}/display/?preview=True`,
                edit: `datasets/edit?dataset_id=${id}`,
                showDetails: `datasets/${id}/details`,
                reportError: `datasets/error?dataset_id=${id}`,
                rerun: `tool_runner/rerun?id=${id}`,
                visualize: `visualizations?dataset_id=${id}`,
            };
        },
    },
    methods: {
        onClick() {
@@ -175,8 +197,7 @@ export default {
            }
        },
        onDisplay() {
            const url = `datasets/${this.item.id}/display/?preview=True`;
            iframeAdd({ path: url, title: this.name });
            iframeAdd({ path: this.itemUrls.display, title: this.name });
        },
        onDragStart(evt) {
            evt.dataTransfer.dropEffect = "move";
@@ -184,11 +205,7 @@ export default {
            evt.dataTransfer.setData("text", JSON.stringify([this.item]));
        },
        onEdit() {
            if (this.item.collection_type) {
                backboneRoute(`collection/edit/${this.item.id}`);
            } else {
                backboneRoute("datasets/edit", { dataset_id: this.item.id });
            }
            backboneRoute(this.itemUrls.edit);
        },
        onTags(newTags) {
            this.$emit("tag-change", this.item, newTags);
+17 −7
Original line number Diff line number Diff line
@@ -4,25 +4,27 @@
            v-if="isDataset"
            :disabled="displayDisabled"
            :title="displayButtonTitle"
            class="px-1"
            class="display-btn px-1"
            size="sm"
            variant="link"
            @click.stop="$emit('display')">
            :href="displayUrl"
            @click.prevent.stop="$emit('display')">
            <icon icon="eye" />
        </b-button>
        <b-button
            v-if="isHistoryItem"
            :disabled="editDisabled"
            :title="editButtonTitle"
            class="px-1"
            class="edit-btn px-1"
            size="sm"
            variant="link"
            @click.stop="$emit('edit')">
            :href="editUrl"
            @click.prevent.stop="$emit('edit')">
            <icon icon="pen" />
        </b-button>
        <b-button
            v-if="isHistoryItem && !isDeleted"
            class="px-1"
            class="delete-btn px-1"
            title="Delete"
            size="sm"
            variant="link"
@@ -31,7 +33,7 @@
        </b-button>
        <b-button
            v-if="isHistoryItem && isDeleted"
            class="px-1"
            class="undelete-btn px-1"
            title="Undelete"
            size="sm"
            variant="link"
@@ -40,7 +42,7 @@
        </b-button>
        <b-button
            v-if="isHistoryItem && !isVisible"
            class="px-1"
            class="unhide-btn px-1"
            title="Unhide"
            size="sm"
            variant="link"
@@ -51,6 +53,7 @@
</template>

<script>
import { prependPath } from "utils/redirect.js";
export default {
    props: {
        isDataset: { type: Boolean, required: true },
@@ -58,6 +61,7 @@ export default {
        isHistoryItem: { type: Boolean, required: true },
        isVisible: { type: Boolean, default: true },
        state: { type: String, default: "" },
        itemUrls: { type: Object, required: true },
    },
    computed: {
        displayButtonTitle() {
@@ -78,6 +82,12 @@ export default {
        editDisabled() {
            return ["discarded", "new", "upload", "queued", "running", "waiting"].includes(this.state);
        },
        displayUrl() {
            return prependPath(this.itemUrls.display);
        },
        editUrl() {
            return prependPath(this.itemUrls.edit);
        },
    },
};
</script>
+31 −8
Original line number Diff line number Diff line
@@ -2,7 +2,14 @@
    <div class="dataset-actions mb-1">
        <div class="clearfix">
            <div class="btn-group float-left">
                <b-button v-if="showError" class="px-1" title="Error" size="sm" variant="link" @click.stop="onError">
                <b-button
                    v-if="showError"
                    class="px-1"
                    title="Error"
                    size="sm"
                    variant="link"
                    :href="reportErrorUrl"
                    @click.prevent.stop="onError">
                    <span class="fa fa-bug" />
                </b-button>
                <dataset-download v-if="showDownloads" :item="item" @on-download="onDownload" />
@@ -21,7 +28,8 @@
                    title="Dataset Details"
                    size="sm"
                    variant="link"
                    @click.stop="onInfo">
                    :href="showDetailsUrl"
                    @click.prevent.stop="onInfo">
                    <span class="fa fa-info-circle" />
                </b-button>
                <b-button
@@ -30,7 +38,8 @@
                    title="Run Job Again"
                    size="sm"
                    variant="link"
                    @click.stop="onRerun">
                    :href="rerunUrl"
                    @click.prevent.stop="onRerun">
                    <span class="fa fa-redo" />
                </b-button>
                <b-button
@@ -39,7 +48,8 @@
                    title="Visualize"
                    size="sm"
                    variant="link"
                    @click.stop="onVisualize">
                    :href="visualizeUrl"
                    @click.prevent.stop="onVisualize">
                    <span class="fa fa-bar-chart-o" />
                </b-button>
                <b-button
@@ -62,7 +72,7 @@
<script>
import { legacyNavigationMixin } from "components/plugins/legacyNavigation";
import { copy as sendToClipboard } from "utils/clipboard";
import { absPath } from "utils/redirect";
import { absPath, prependPath } from "utils/redirect.js";
import { downloadUrlMixin } from "./mixins.js";
import DatasetDownload from "./DatasetDownload";

@@ -74,6 +84,7 @@ export default {
    props: {
        item: { type: Object, required: true },
        showHighlight: { type: Boolean, default: false },
        itemUrls: { type: Object, required: true },
    },
    computed: {
        showDownloads() {
@@ -97,6 +108,18 @@ export default {
            // TODO: Check hasViz, if visualizations are activated in the config
            return !this.item.purged && ["ok", "failed_metadata", "error"].includes(this.item.state);
        },
        reportErrorUrl() {
            return prependPath(this.itemUrls.reportError);
        },
        showDetailsUrl() {
            return prependPath(this.itemUrls.showDetails);
        },
        rerunUrl() {
            return prependPath(this.itemUrls.rerun);
        },
        visualizeUrl() {
            return prependPath(this.itemUrls.visualize);
        },
    },
    methods: {
        onCopyLink() {
@@ -107,10 +130,10 @@ export default {
            window.location.href = resource;
        },
        onError() {
            this.backboneRoute("datasets/error", { dataset_id: this.item.id });
            this.backboneRoute(this.itemUrls.reportError);
        },
        onInfo() {
            this.backboneRoute(`datasets/${this.item.id}/details`);
            this.backboneRoute(this.itemUrls.showDetails);
        },
        onRerun() {
            this.backboneRoute(`root?job_id=${this.item.creating_job}`);
@@ -118,7 +141,7 @@ export default {
        onVisualize() {
            const name = this.item.name || "";
            const title = `Visualization of ${name}`;
            const path = `visualizations?dataset_id=${this.item.id}`;
            const path = this.itemUrls.visualize;
            const redirectParams = {
                path: path,
                title: title,
+6 −1
Original line number Diff line number Diff line
@@ -21,7 +21,11 @@
                        <span class="value">{{ result.misc_info }}</span>
                    </div>
                </div>
                <DatasetActions :item="result" :show-highlight="showHighlight" @toggleHighlights="toggleHighlights" />
                <DatasetActions
                    :item="result"
                    :show-highlight="showHighlight"
                    :item-urls="itemUrls"
                    @toggleHighlights="toggleHighlights" />
                <pre v-if="result.peek" class="dataset-peek p-1" v-html="result.peek" />
            </div>
        </div>
@@ -94,6 +98,7 @@ export default {
    props: {
        dataset: { type: Object, required: true },
        showHighlight: { type: Boolean, default: false },
        itemUrls: { type: Object, required: true },
    },
    computed: {
        stateText() {
+7 −3
Original line number Diff line number Diff line
@@ -14,12 +14,15 @@
        <template v-slot:button-content>
            <span class="fa fa-save" />
        </template>
        <b-dropdown-item v-localize @click.stop="onDownload(downloadUrl)"> Download Dataset </b-dropdown-item>
        <b-dropdown-item v-localize :href="downloadUrl" @click.prevent.stop="onDownload(downloadUrl)">
            Download Dataset
        </b-dropdown-item>
        <b-dropdown-item
            v-for="(metaFile, index) of metaFiles"
            :key="index"
            :data-description="`download ${metaFile.file_type}`"
            @click.stop="onDownload(metaDownloadUrl, metaFile.file_type)">
            :href="metaDownloadUrl + metaFile.file_type"
            @click.prevent.stop="onDownload(metaDownloadUrl, metaFile.file_type)">
            Download {{ metaFile.file_type }}
        </b-dropdown-item>
    </b-dropdown>
@@ -29,7 +32,8 @@
        title="Download"
        size="sm"
        variant="link"
        @click.stop="onDownload(downloadUrl)">
        :href="downloadUrl"
        @click.prevent.stop="onDownload(downloadUrl)">
        <span class="fa fa-save" />
    </b-button>
</template>
Loading