Skip to content

Commit

Permalink
creating new branch based off dev for help mode
Browse files Browse the repository at this point in the history
  • Loading branch information
assuntad23 authored and ahmedhamidawan committed Mar 25, 2024
1 parent 53e0ac5 commit 262f165
Show file tree
Hide file tree
Showing 10 changed files with 205 additions and 1 deletion.
8 changes: 8 additions & 0 deletions client/src/components/Form/FormDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
</template>

<script>
import { mapStores } from "pinia";
import Vue from "vue";
import { useHelpModeTextStore } from "@/stores/helpmode/helpModeTextStore";
import FormInputs from "./FormInputs";
import { matchInputs, validateInputs, visitInputs } from "./utilities";
Expand Down Expand Up @@ -99,6 +102,7 @@ export default {
};
},
computed: {
...mapStores(useHelpModeTextStore),
validation() {
return validateInputs(this.formIndex, this.formData, this.allowEmptyValueOnRequiredInput);
},
Expand Down Expand Up @@ -138,6 +142,7 @@ export default {
},
},
created() {
this.callHelpMode();
this.onCloneInputs();
// build flat formData that is ready to be submitted
this.formData = this.buildFormData();
Expand All @@ -149,6 +154,9 @@ export default {
this.onErrors();
},
methods: {
callHelpMode() {
this.helpModeTextStore.addHelpModeText("tool_form_base");
},
buildFormData() {
const params = {};
Object.entries(this.formIndex).forEach(([key, input]) => {
Expand Down
49 changes: 49 additions & 0 deletions client/src/components/Masthead/HelpModeSwitch.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<script setup lang="ts">
import { computed } from "vue";
import { useHelpModeStatusStore } from "@/stores/helpmode/helpModeStatusStore";
const tooltip = "Enable/Disable Help Mode";
const statusStore = useHelpModeStatusStore();
const enabledStatus = computed({
get() {
return statusStore.helpmodestatus;
},
set(value: boolean) {
statusStore.setHelpModeStatus(value);
},
});
function toggleEnabledStatus() {
enabledStatus.value = !enabledStatus.value;
}
</script>

<template>
<div>
<button
class="help-mode-button"
:class="{ highlight: enabledStatus }"
:title="tooltip"
:aria-label="tooltip"
@click="toggleEnabledStatus"
@keydown.enter="toggleEnabledStatus">
<i class="fas fa-question-circle fa-lg" :class="{ highlight: enabledStatus }"> </i> Help Me
</button>
</div>
</template>

<style scoped>
.highlight {
color: yellow;
}
.help-mode-button {
background-color: inherit;
border: 0px transparent;
cursor: pointer;
color: inherit;
outline: none;
}
.help-mode-button.highlight {
color: yellow;
}
</style>
4 changes: 4 additions & 0 deletions client/src/components/Masthead/Masthead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useConfig } from "@/composables/config";
import { useUserStore } from "@/stores/userStore";
import { loadWebhookMenuItems } from "./_webhooks";
import HelpModeSwitch from "./HelpModeSwitch";
import MastheadItem from "./MastheadItem";
import QuotaMeter from "./QuotaMeter";
import { getActiveTab } from "./utilities";
Expand Down Expand Up @@ -138,6 +139,9 @@ onMounted(() => {
:active-tab="activeTab"
@open-url="emit('open-url', $event)" />
<MastheadItem v-if="windowTab" :tab="windowTab" :toggle="windowToggle" @click="onWindowToggle" />
<BNavItem>
<HelpModeSwitch />
</BNavItem>
<BNavItem
v-if="!isAnonymous && isConfigLoaded && config.enable_notification_system"
id="notifications-bell">
Expand Down
87 changes: 87 additions & 0 deletions client/src/components/Panels/HelpModeText.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<script setup lang="ts">
import { useDraggable } from "@vueuse/core";
import MarkdownIt from "markdown-it";
import { computed, onMounted, ref } from "vue";
import { useHelpModeStatusStore } from "@/stores/helpmode/helpModeStatusStore";
import { useHelpModeTextStore } from "@/stores/helpmode/helpModeTextStore";
const md = MarkdownIt();
const helpInfo = useHelpModeTextStore();
const status = useHelpModeStatusStore();
const helpText = computed({
get() {
return md.render(helpInfo.helpmodetext);
},
set() {
//do nothing, this is set in components that add helptext
},
});
const helpStatus = computed({
get() {
return status.helpmodestatus;
},
set(value: boolean) {
status.setHelpModeStatus(value);
},
});
function closeHelpMode() {
helpStatus.value = !helpStatus.value;
}
const el = ref<HTMLElement | null>(null);
const { x, y, style } = useDraggable(el, {
initialValue: { x: 0, y: 0 },
});
const helpTextRef = ref(null);
onMounted(() => {
const links = (helpTextRef.value as unknown as HTMLElement).querySelectorAll("a");
links.forEach((link: HTMLAnchorElement) => {
link.setAttribute("target", "_blank");
});
});
</script>
<template>
<div
ref="el"
:style="style"
style="position: fixed"
class="helptext unified-panel-body d-flex justify-content-between">
<div class="header">
<h1>Galaxy Help Mode</h1>
<button class="close-button" @click="closeHelpMode">
<i class="fas fa-times"></i>
</button>
</div>
<div ref="helpTextRef" class="help-mode-container" v-html="helpText"></div>
</div>
</template>
<style>
.helptext {
display: flex;
flex-direction: column;
width: 25% !important;
height: 30% !important;
z-index: 9999;
background-color: aliceblue;
border-color: black;
border-radius: 5px;
border-width: 2px;
border: solid;
opacity: 90%;
}
.header {
display: flex;
color: white;
background-color: #454d6b;
justify-content: space-between;
align-items: center;
border-bottom: 2px solid #868686;
/* padding-bottom: 10px; */
}
.help-mode-container {
margin-top: 0;
padding: 10px;
overflow-y: auto;
height: 100%;
}
</style>
4 changes: 4 additions & 0 deletions client/src/entry/analysis/modules/Analysis.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ import { onMounted, onUnmounted, ref } from "vue";
import { useRouter } from "vue-router/composables";
import { usePanels } from "@/composables/usePanels";
import { useHelpModeStatusStore } from "@/stores/helpmode/helpModeStatusStore";
import CenterFrame from "./CenterFrame.vue";
import ActivityBar from "@/components/ActivityBar/ActivityBar.vue";
import HistoryIndex from "@/components/History/Index.vue";
import FlexPanel from "@/components/Panels/FlexPanel.vue";
import HelpModeText from "@/components/Panels/HelpModeText.vue";
import DragAndDropModal from "@/components/Upload/DragAndDropModal.vue";
const router = useRouter();
const showCenter = ref(false);
const { showPanels } = usePanels();
const status = useHelpModeStatusStore();
// methods
function hideCenter() {
Expand Down Expand Up @@ -46,5 +49,6 @@ onUnmounted(() => {
<HistoryIndex />
</FlexPanel>
<DragAndDropModal />
<HelpModeText v-if="status.helpmodestatus" />
</div>
</template>
20 changes: 20 additions & 0 deletions client/src/stores/helpmode/helpModeStatusStore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { defineStore } from "pinia";

import { useHelpModeTextStore } from "./helpModeTextStore";

export const useHelpModeStatusStore = defineStore("helpModeStatusStore", {
state: () => {
return {
helpmodestatus: false,
};
},

actions: {
setHelpModeStatus(status) {
this.helpmodestatus = status;
if (status == false) {
useHelpModeTextStore().clearHelpModeText();
}
},
},
});
25 changes: 25 additions & 0 deletions client/src/stores/helpmode/helpModeTextStore.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { defineStore } from "pinia";

import config from "./helpTextConfig.yml";

export const useHelpModeTextStore = defineStore("helpModeText", {
state: () => {
return {
helpmodetext: "Welcome to Galaxy Help Mode!",
};
},

actions: {
addHelpModeText(text) {
const file_path = config[text];
fetch("https://raw.githubusercontent.com/assuntad23/galaxy-help-markdown/main/" + file_path)
.then((response) => response.text())
.then((text) => {
this.helpmodetext = text;
});
},
clearHelpModeText() {
this.helpmodetext = "Welcome to Galaxy Help Mode!";
},
},
});
2 changes: 2 additions & 0 deletions client/src/stores/helpmode/helpTextConfig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tool_form_base: tools/tool_form_base.md
collection_builder: collections/collection_builder.md
6 changes: 6 additions & 0 deletions client/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const scriptsBase = path.join(__dirname, "src");
const testsBase = path.join(__dirname, "tests");
const libsBase = path.join(scriptsBase, "libs");
const styleBase = path.join(scriptsBase, "style");
const helpTextConfigPath = path.join(scriptsBase, "stores", "helpMode");

const modulesExcludedFromLibs = [
"jspdf",
Expand Down Expand Up @@ -104,6 +105,11 @@ module.exports = (env = {}, argv = {}) => {
test: /\.vue$/,
loader: "vue-loader",
},
{
test: /\.ya?ml$/,
include: helpTextConfigPath,
loader: "yaml-loader",
},
{
test: /\.tsx?$/,
exclude: /node_modules/,
Expand Down
1 change: 0 additions & 1 deletion database/info.txt

This file was deleted.

0 comments on commit 262f165

Please sign in to comment.