Skip to content

Commit

Permalink
add enable_help_mode config option
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedhamidawan committed Mar 27, 2024
1 parent 01b38cd commit 047ce4a
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 9 deletions.
16 changes: 9 additions & 7 deletions client/src/components/Masthead/HelpModeSwitch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { library } from "@fortawesome/fontawesome-svg-core";
import { faQuestionCircle } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { BButton } from "bootstrap-vue";
import { storeToRefs } from "pinia";
import { useHelpModeStore } from "@/stores/helpmode/helpModeStore";
Expand All @@ -18,17 +19,18 @@ function toggleEnabledStatus() {

<template>
<div>
<button
<BButton
v-b-tooltip.hover.bottom
class="help-mode-button"
class="help-mode-button nav-link"
:class="{ highlight: status }"
:title="tooltip"
:aria-label="tooltip"
variant="link"
@click="toggleEnabledStatus"
@keydown.enter="toggleEnabledStatus">
<!-- <i class="fas fa-question-circle fa-lg" :class="{ highlight: status }"> </i> Help Me -->
<FontAwesomeIcon :icon="faQuestionCircle" :class="{ highlight: status }" size="lg" /> Help Me
</button>
<FontAwesomeIcon :icon="faQuestionCircle" :class="{ highlight: status }" size="lg" />
</BButton>
</div>
</template>

Expand All @@ -44,8 +46,8 @@ function toggleEnabledStatus() {
cursor: pointer;
color: inherit;
outline: none;
}
.help-mode-button.highlight {
color: var(--masthead-text-hover);
&.highlight {
color: var(--masthead-text-hover);
}
}
</style>
30 changes: 28 additions & 2 deletions client/src/stores/helpmode/helpModeStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import type { IconDefinition } from "@fortawesome/fontawesome-svg-core";
import { defineStore } from "pinia";
import { ref } from "vue";
import { ref, watch } from "vue";

import { rethrowSimple } from "@/utils/simple-error";

Expand Down Expand Up @@ -40,8 +40,26 @@ export const useHelpModeStore = defineStore("helpModeStore", () => {
const currentTabs = ref<string[]>([]);
/** Component ids for which fetching the help text was unsuccessful */
const invalidIds = ref<string[]>([]);
/** The ids of the components for which help text was requested while help mode was disabled */
const idsToStore = ref<string[]>([]);

// when help mode is enabled, store help for the ids requested while help mode was disabled
watch(status, async (newStatus) => {
if (newStatus) {
for (const id of idsToStore.value) {
await storeHelpModeText(id);
}
idsToStore.value = [];
}
});

async function storeHelpModeText(id: string, icon?: IconDefinition) {
// if help mode is disabled, store the id in the temp array and return
if (!status.value) {
idsToStore.value.push(id);
return;
}

loading.value = true;
try {
// Error handling
Expand Down Expand Up @@ -78,6 +96,14 @@ export const useHelpModeStore = defineStore("helpModeStore", () => {
}

function clearHelpModeText(id: string) {
// if help mode is disabled, remove the id from the temp array
if (!status.value) {
const idx = idsToStore.value.indexOf(id);
if (idx !== -1) {
idsToStore.value.splice(idx, 1);
}
}

// remove id from currentTabs
const idx = currentTabs.value.indexOf(id);
if (idx !== -1) {
Expand Down Expand Up @@ -105,7 +131,7 @@ export const useHelpModeStore = defineStore("helpModeStore", () => {
status,
/** Removes the tab from the stack for the given component `id` */
clearHelpModeText,
/** Adds help mode text for the given Galaxy component `id` */
/** Adds help mode text for the given Galaxy component `id` if help mode is enabled */
storeHelpModeText,
};
});
10 changes: 10 additions & 0 deletions doc/source/admin/galaxy_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2346,6 +2346,16 @@
:Type: str


~~~~~~~~~~~~~
``enable_help_mode``
~~~~~~~~~~~~~

:Description:
Enables the Galaxy Help Mode for this Galaxy Instance.
:Default: ``false``
:Type: bool


~~~~~~~~~~~~~~~~~~
``static_enabled``
~~~~~~~~~~~~~~~~~~
Expand Down
3 changes: 3 additions & 0 deletions lib/galaxy/config/sample/galaxy.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,9 @@ galaxy:
# activation emails.
#terms_url: null

# Enables the Galaxy Help Mode for this Galaxy Instance.
#enable_help_mode: false

# Serve static content, which must be enabled if you're not serving it
# via a proxy server. These options should be self explanatory and so
# are not documented individually. You can use these paths (or ones
Expand Down
7 changes: 7 additions & 0 deletions lib/galaxy/config/schemas/config_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1698,6 +1698,13 @@ mapping:
The URL linked by the "Terms and Conditions" link in the "Help" menu, as well
as on the user registration and login forms and in the activation emails.
enable_help_mode:
type: bool
default: false
required: false
desc: |
Enables the Galaxy Help Mode for this Galaxy Instance.
static_enabled:
type: bool
default: true
Expand Down
1 change: 1 addition & 0 deletions lib/galaxy/managers/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def _config_is_truthy(item, key, **context):
"upload_from_form_button": _use_config,
"release_doc_base_url": _use_config,
"expose_user_email": _use_config,
"enable_help_mode": _use_config,
"enable_tool_source_display": _use_config,
"enable_celery_tasks": _use_config,
"quota_source_labels": lambda item, key, **context: list(
Expand Down

0 comments on commit 047ce4a

Please sign in to comment.