Skip to content

Commit

Permalink
Merge branch 'release_23.2' into release_24.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed Mar 11, 2024
2 parents 4e18d82 + b73d9e2 commit 3dbc2c6
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 73 deletions.
114 changes: 59 additions & 55 deletions client/src/components/Panels/Buttons/FavoritesButton.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,61 @@
<script setup lang="ts">
import { library } from "@fortawesome/fontawesome-svg-core";
import { faStar } from "@fortawesome/free-regular-svg-icons";
import { faStar as faRegStar } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { BButton } from "bootstrap-vue";
import { storeToRefs } from "pinia";
import { computed, ref, watch } from "vue";
import { useUserStore } from "@/stores/userStore";
library.add(faStar, faRegStar);
interface Props {
query: string;
}
const props = defineProps<Props>();
const emit = defineEmits<{
(e: "onFavorites", filter: string): void;
}>();
const { isAnonymous } = storeToRefs(useUserStore());
const FAVORITES = ["#favorites", "#favs", "#favourites"];
const toggle = ref(false);
const tooltipText = computed(() => {
if (isAnonymous.value) {
return "Log in to Favorite Tools";
} else {
if (toggle.value) {
return "Clear";
} else {
return "Show favorites";
}
}
});
watch(
() => props.query,
() => {
toggle.value = FAVORITES.includes(props.query);
}
);
function onFavorites() {
toggle.value = !toggle.value;
if (toggle.value) {
emit("onFavorites", "#favorites");
} else {
emit("onFavorites", "");
}
}
</script>

<template>
<b-button
<BButton
v-b-tooltip.hover.top.noninteractive
class="panel-header-button-toolbox"
size="sm"
Expand All @@ -8,58 +64,6 @@
:disabled="isAnonymous"
:title="tooltipText"
@click="onFavorites">
<icon v-if="toggle" :icon="['fas', 'star']" />
<icon v-else :icon="['far', 'star']" />
</b-button>
<FontAwesomeIcon :icon="toggle ? faRegStar : faStar" />
</BButton>
</template>

<script>
import { mapState } from "pinia";
import { useUserStore } from "@/stores/userStore";
export default {
name: "FavoritesButton",
props: {
query: {
type: String,
required: true,
},
},
data() {
return {
searchKey: "#favorites",
toggle: false,
};
},
computed: {
...mapState(useUserStore, ["isAnonymous"]),
tooltipText() {
if (this.isAnonymous) {
return this.l("Log in to Favorite Tools");
} else {
if (this.toggle) {
return this.l("Clear");
} else {
return this.l("Show favorites");
}
}
},
},
watch: {
query() {
this.toggle = this.query == this.searchKey;
},
},
methods: {
onFavorites() {
this.toggle = !this.toggle;
if (this.toggle) {
this.$emit("onFavorites", this.searchKey);
} else {
this.$emit("onFavorites", "");
}
},
},
};
</script>
19 changes: 14 additions & 5 deletions client/src/components/Panels/Common/ToolSearch.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<script setup lang="ts">
import { computed, type ComputedRef, onMounted, onUnmounted, type PropType, type Ref, ref } from "vue";
import { storeToRefs } from "pinia";
import { computed, type ComputedRef, onMounted, onUnmounted, type PropType, type Ref, ref, watch } from "vue";
import { useRouter } from "vue-router/composables";
import { getGalaxyInstance } from "@/app";
import { type Tool, type ToolSection, useToolStore } from "@/stores/toolStore";
import { useUserStore } from "@/stores/userStore";
import Filtering, { contains, type ValidFilter } from "@/utils/filtering";
import _l from "@/utils/localization";
Expand Down Expand Up @@ -109,6 +110,7 @@ const validFilters: ComputedRef<Record<string, ValidFilter<string>>> = computed(
});
const ToolFilters: ComputedRef<Filtering<string>> = computed(() => new Filtering(validFilters.value));
const { currentFavorites } = storeToRefs(useUserStore());
const toolStore = useToolStore();
const sectionNames = toolStore.sectionDatalist("default").map((option: { value: string; text: string }) => option.text);
Expand All @@ -118,8 +120,6 @@ const ontologyList = toolStore
onMounted(() => {
searchWorker.value = new Worker(new URL("../toolSearch.worker.js", import.meta.url));
const Galaxy = getGalaxyInstance();
const favoritesResults = Galaxy?.user.getFavorites().tools;
searchWorker.value.onmessage = ({ data }) => {
const { type, payload, sectioned, query, closestTerm } = data;
Expand All @@ -128,7 +128,7 @@ onMounted(() => {
} else if (type === "clearFilterResult") {
emit("onResults", null, null, null);
} else if (type === "favoriteToolsResult") {
emit("onResults", favoritesResults, null, null);
emit("onResults", currentFavorites.value.tools, null, null);
}
};
});
Expand All @@ -137,6 +137,15 @@ onUnmounted(() => {
searchWorker.value?.terminate();
});
watch(
() => currentFavorites.value.tools,
() => {
if (FAVORITES.includes(props.query)) {
post({ type: "favoriteTools" });
}
}
);
function checkQuery(q: string) {
emit("onQuery", q);
if (q && q.length >= MIN_QUERY_LENGTH) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Panels/ToolBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ function setButtonText() {
@onQuery="(q) => (query = q)"
@onResults="onResults" />
<section v-if="!propShowAdvanced">
<UploadButton />
<UploadButton v-if="!props.workflow" />
<div v-if="hasResults && resultPanel" class="pb-2">
<b-button size="sm" class="w-100" @click="onToggle">
<FontAwesomeIcon :icon="buttonIcon" />
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/Panels/ToolPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const emit = defineEmits<{
const arePanelsFetched = ref(false);
const toolStore = useToolStore();
const { currentPanelView, defaultPanelView, isPanelPopulated, loading, panelViews } = storeToRefs(toolStore);
const { currentPanelView, defaultPanelView, isPanelPopulated, loading, panel, panelViews } = storeToRefs(toolStore);
const loadingView = ref<string | undefined>(undefined);
const query = ref("");
Expand Down Expand Up @@ -62,7 +62,7 @@ watch(
watch(
() => currentPanelView.value,
async (newVal) => {
if (!newVal && arePanelsFetched.value) {
if ((!newVal || !panel.value[newVal]) && arePanelsFetched.value) {
await initializeTools();
}
}
Expand Down
5 changes: 2 additions & 3 deletions client/src/components/ToolsList/ToolsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,14 @@ const filterSettings = computed(() => {
return newFilterSettings;
});
const itemsLoaded: Ref<Tool[]> = ref([]);
onMounted(async () => {
await toolStore.fetchTools(filterSettings.value);
itemsLoaded.value = Object.values(toolStore.getToolsById(filterSettings.value));
});
const filterCount = computed(() => Object.keys(filterSettings.value).length);
const itemsLoaded = computed<Tool[]>(() => Object.values(toolStore.getToolsById(filterSettings.value)));
function scrollToTop() {
scrollContainer.value?.scrollTo({ top: 0, behavior: "smooth" });
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/ToolsList/ToolsListTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default {
}
},
async fetchHelp(tool) {
await fetchData(`api/tools/${tool.id}/build`).then((response) => {
await fetchData(`api/tools/${encodeURIComponent(tool.id)}/build`).then((response) => {
const help = response.help;
Vue.set(tool, "_showDetails", false); // maybe not needed
if (help && help != "\n") {
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/tool_util/parser/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
class AssertionDict(TypedDict):
tag: str
attributes: Dict[str, Any]
children: Optional[List[Dict[str, Any]]]
children: "AssertionList"


AssertionList = Optional[List[AssertionDict]]
Expand Down
9 changes: 5 additions & 4 deletions lib/galaxy/tool_util/parser/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,11 @@ def expand_dict_form(item):
new_assertion["that"] = assertion_key
new_assertion.update(assertion_value)
assertion = new_assertion
children = []
if "children" in assertion:
children = assertion["children"]
del assertion["children"]
children = assertion.pop("asserts", assertion.pop("children", []))
# if there are no nested assertions then children should be []
# but to_test_assert_list would return None
if children:
children = to_test_assert_list(children)
assert_dict: AssertionDict = dict(
tag=assertion["that"],
attributes=assertion,
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/webapps/galaxy/api/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def set_beacon(
return payload

@router.delete(
"/api/users/{user_id}/favorites/{object_type}/{object_id}",
"/api/users/{user_id}/favorites/{object_type}/{object_id:path}",
name="remove_favorite",
summary="Remove the object from user's favorites",
)
Expand Down
23 changes: 23 additions & 0 deletions test/unit/tool_util/test_test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,26 @@ def test_simple_assert_to_test_assert_list():

def test_assert_legacy_same_as_new_list_style():
assert to_test_assert_list(ASSERT_THAT_LIST) == to_test_assert_list(ASSERT_THAT_LIST)


NESTED_ASSERT_LIST = yaml.safe_load(
"""
- has_archive_member:
path: ".*"
asserts:
- has_text:
text: "a text"
- has_text:
text: "another text"
"""
)


def test_nested_asserts():
asserts = to_test_assert_list(NESTED_ASSERT_LIST)
assert asserts and len(asserts) == 1
assert asserts and asserts[0]["children"] and len(asserts[0]["children"]) == 2
assert asserts and asserts[0]["children"] and asserts[0]["children"][0]["tag"] == "has_text"
assert asserts and asserts[0]["children"] and asserts[0]["children"][0]["attributes"]["text"] == "a text"
assert asserts and asserts[0]["children"] and asserts[0]["children"][1]["tag"] == "has_text"
assert asserts and asserts[0]["children"] and asserts[0]["children"][1]["attributes"]["text"] == "another text"

0 comments on commit 3dbc2c6

Please sign in to comment.