Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interactive Client tools implemented client-side. Refactoring of ToolForm into several components #16935

Draft
wants to merge 16 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions client/src/components/Common/ButtonSpinner.vue
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
<template>
<b-button
v-if="wait"
v-b-tooltip.hover.bottom
disabled
variant="info"
title="Please Wait..."
class="d-flex flex-nowrap align-items-center text-nowrap">
<b-button v-if="wait" disabled variant="info" class="d-flex flex-nowrap align-items-center text-nowrap">
<FontAwesomeIcon icon="spinner" class="mr-2" spin />{{ title }}
</b-button>
<b-button
v-else
v-b-tooltip.hover.bottom
v-b-tooltip.hover.bottom="wait ? '' : tooltip"
:disabled="disabled"
variant="primary"
class="d-flex flex-nowrap align-items-center text-nowrap"
:title="tooltip"
@click="$emit('onClick')">
<FontAwesomeIcon icon="play" class="mr-2" />{{ title }}
<FontAwesomeIcon :icon="icon" class="mr-2" />{{ title }}
</b-button>
</template>
<script>
import { library } from "@fortawesome/fontawesome-svg-core";
import { faPlay, faSpinner } from "@fortawesome/free-solid-svg-icons";
import { faPlay, faSpinner, faStop } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";

library.add(faSpinner);
library.add(faPlay);
library.add(faStop);

export default {
components: {
Expand All @@ -39,6 +34,14 @@ export default {
type: Boolean,
default: false,
},
icon: {
type: String,
default: "play",
},
disabled: {
type: Boolean,
default: false,
},
tooltip: {
type: String,
default: null,
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/Panels/FlexPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ watch(position, () => {
right: 0;
}
.interaction-area {
margin: -1.5rem;
padding: 1.5rem;
margin: -1.5rem -1.5rem 0;
padding: 1.5rem 1.5rem 0;
position: absolute;
z-index: 2;
}
Expand Down
8 changes: 1 addition & 7 deletions client/src/components/Panels/ToolBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function onToolClick(tool: Tool, evt: Event) {
if (tool.id === "upload1") {
evt.preventDefault();
openGlobalUploadModal();
} else if (tool.form_style === "regular") {
} else if (tool.form_style === "regular" || tool.model_class === "InteractiveClientTool") {
evt.preventDefault();
// encode spaces in tool.id
const toolId = tool.id;
Expand Down Expand Up @@ -333,9 +333,3 @@ function setButtonText() {
</div>
</div>
</template>

<style scoped>
.toolTitle {
overflow-wrap: anywhere;
}
</style>
8 changes: 6 additions & 2 deletions client/src/components/Tool/Buttons/ToolFavoriteButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ async function onAddFavorite() {
emit("onSetError", null);
ariaAlert("added to favorites");
} catch {
emit("onSetError", `Failed to add '${props.id}' to favorites.`);
emit("onSetError", {
message: `Failed to add '${props.id}' to favorites.`,
});
ariaAlert("failed to add to favorites");
}
}
Expand All @@ -61,7 +63,9 @@ async function onRemoveFavorite() {
emit("onSetError", null);
ariaAlert("removed from favorites");
} catch {
emit("onSetError", `Failed to remove '${props.id}' from favorites.`);
emit("onSetError", {
message: `Failed to remove '${props.id}' from favorites.`,
});
ariaAlert("failed to remove from favorites");
}
}
Expand Down
2 changes: 2 additions & 0 deletions client/src/components/Tool/Buttons/ToolOptionsButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ function onLink() {
<FontAwesomeIcon icon="fa-external-link-alt" /><span v-localize>See in Tool Shed</span>
</b-dropdown-item>

<slot name="extra-tool-options-items" />

<b-dropdown-item v-for="w of webhookDetails" :key="w.title" @click="w.onclick">
<span :class="w.icon" />{{ l(w.title) }}
</b-dropdown-item>
Expand Down
40 changes: 12 additions & 28 deletions client/src/components/Tool/ToolCard.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<script setup>
import Heading from "components/Common/Heading";
import FormMessage from "components/Form/FormMessage";
import ToolFooter from "components/Tool/ToolFooter";
import ToolHelp from "components/Tool/ToolHelp";
import { getAppRoot } from "onload/loadConfig";
import { storeToRefs } from "pinia";
import { computed, ref, watch } from "vue";
import { computed, ref } from "vue";

import { useUserStore } from "@/stores/userStore";

Expand Down Expand Up @@ -40,14 +39,6 @@ const props = defineProps({
type: Object,
required: true,
},
messageText: {
type: String,
required: true,
},
messageVariant: {
type: String,
default: "info",
},
disabled: {
type: Boolean,
default: false,
Expand All @@ -62,23 +53,14 @@ const props = defineProps({
},
});

const emit = defineEmits(["onChangeVersion", "updatePreferredObjectStoreId"]);
const emit = defineEmits(["onChangeVersion", "onSetError", "updatePreferredObjectStoreId"]);

function onChangeVersion(v) {
emit("onChangeVersion", v);
function onChangeVersion(newVersion) {
emit("onChangeVersion", newVersion);
}

const errorText = ref(null);

watch(
() => props.id,
() => {
errorText.value = null;
}
);

function onSetError(e) {
errorText.value = e;
function onSetError(errorObj) {
emit("onSetError", errorObj);
}

const { currentUser, isAnonymous } = storeToRefs(useUserStore());
Expand All @@ -102,7 +84,7 @@ function onUpdatePreferredObjectStoreId(selectedToolPreferredObjectStoreId) {
</script>

<template>
<div class="position-relative">
<div class="position-relative" itemscope="itemscope" itemtype="https://schema.org/CreativeWork">
<div class="underlay sticky-top" />
<div class="tool-header sticky-top bg-secondary px-2 py-1 rounded">
<div class="d-flex justify-content-between">
Expand All @@ -125,7 +107,11 @@ function onUpdatePreferredObjectStoreId(selectedToolPreferredObjectStoreId) {
<ToolOptionsButton
:id="props.id"
:sharable-url="props.options.sharable_url"
:options="props.options" />
:options="props.options">
<template v-slot:extra-tool-options-items>
<slot name="extra-tool-options-items" />
</template>
</ToolOptionsButton>
<b-button
v-if="allowObjectStoreSelection"
id="tool-storage"
Expand Down Expand Up @@ -160,8 +146,6 @@ function onUpdatePreferredObjectStoreId(selectedToolPreferredObjectStoreId) {
</div>

<div id="tool-card-body">
<FormMessage variant="danger" :message="errorText" :persistent="true" />
<FormMessage :variant="props.messageVariant" :message="props.messageText" />
<slot name="body" />
<div v-if="props.disabled" class="portlet-backdrop" />
</div>
Expand Down
Loading
Loading