Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 7 additions & 2 deletions client/src/components/Tool/ToolHelpForum.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import { computed, onMounted, ref } from "vue";
import { GalaxyApi } from "@/api";
import { galaxyLogo } from "@/components/icons/galaxyIcons";
import { useConfigStore } from "@/stores/configurationStore";
import { errorMessageAsString } from "@/utils/simple-error";
import { getShortToolId } from "@/utils/tool";

import { createTopicUrl, type HelpForumPost, type HelpForumTopic, useHelpURLs } from "./helpForumUrls";

import Alert from "@/components/Alert.vue";
import Heading from "@/components/Common/Heading.vue";
import ExternalLink from "@/components/ExternalLink.vue";

Expand All @@ -22,6 +24,7 @@ const toolHelpTag = "tool-help";

const topics = ref<HelpForumTopic[]>([]);
const posts = ref<HelpForumPost[]>([]);
const errorMessage = ref("");
const helpAvailable = computed(() => topics.value.length > 0);

const root = ref(null);
Expand All @@ -36,7 +39,7 @@ onMounted(async () => {
},
});
if (error) {
console.error("Error fetching help forum data", error);
errorMessage.value = errorMessageAsString(error, "Failed to search the Help Forum.");
}

topics.value = data?.topics ?? [];
Expand Down Expand Up @@ -66,12 +69,14 @@ const configStore = useConfigStore();
<div ref="root" class="tool-help-forum mt-2 mb-4">
<Heading h2 separator bold size="sm">Help Forum</Heading>

<Alert v-if="errorMessage" variant="warning" :message="errorMessage" />

<p v-if="helpAvailable">
Following questions on the
<ExternalLink :href="configStore.config.help_forum_api_url"> Help Forum </ExternalLink> may be related to
this tool:
</p>
<p v-else>
<p v-else-if="!errorMessage">
There are no questions on the
<ExternalLink :href="configStore.config.help_forum_api_url"> Help Forum </ExternalLink>
about this tool.
Expand Down
38 changes: 30 additions & 8 deletions lib/galaxy/webapps/galaxy/services/help.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import logging

from galaxy.config import GalaxyAppConfiguration
from galaxy.exceptions import ServerNotConfiguredForRequest
from galaxy.exceptions import (
InternalServerError,
MessageException,
ServerNotConfiguredForRequest,
)
from galaxy.schema.help import HelpForumSearchResponse
from galaxy.security.idencoding import IdEncodingHelper
from galaxy.util import requests
Expand Down Expand Up @@ -34,10 +38,28 @@ def search_forum(self, query: str) -> HelpForumSearchResponse:
if not self.config.help_forum_api_url:
raise ServerNotConfiguredForRequest("Help forum API URL is not configured.")
forum_search_url = f"{self.config.help_forum_api_url}/search.json"
response = requests.get(
url=forum_search_url,
params={
"q": query,
},
)
return HelpForumSearchResponse(**response.json())
try:
response = requests.get(
url=forum_search_url,
params={
"q": query,
},
)
except requests.exceptions.ConnectionError:
raise MessageException(
"Could not connect to the Galaxy Help Forum. The service may be temporarily unavailable."
)
except requests.exceptions.Timeout:
raise MessageException("The request to the Galaxy Help Forum timed out. Please try again later.")
except requests.exceptions.RequestException as e:
raise InternalServerError(f"An error occurred while requesting the Galaxy Help Forum: {e}")

if not response.ok:
raise MessageException(
f"The Galaxy Help Forum returned an error (HTTP {response.status_code}). Please try again later."
)

try:
return HelpForumSearchResponse(**response.json())
except ValueError as e:
raise InternalServerError(f"Received an unexpected response format from the Galaxy Help Forum: {e}")
Loading