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

Move Markdown components to subdirectory for modularity #19719

Open
wants to merge 24 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b99e5d2
Move Markdown components to subdirectory for modularity
guerler Feb 27, 2025
ca5c995
Run prettier, use inline markdown dialog instead of separate component
guerler Feb 27, 2025
4908f9d
Remove unused details from Markdown Galaxy component props, remove ve…
guerler Feb 27, 2025
396e2fd
Remove invocation handler for now, will be added in separate PR
guerler Feb 27, 2025
bec4597
Remove unused cache handler
guerler Feb 27, 2025
04ac0e1
Remove legacy markdown container
guerler Feb 27, 2025
a95e161
Adjust history dataset display test
guerler Feb 27, 2025
435ef32
Remove unused markdown editor style
guerler Feb 28, 2025
ca311d8
Remove unnecessary legacy library add for icons
guerler Feb 28, 2025
22f3803
Avoid unnecessary null values for message strings
guerler Feb 28, 2025
f26eb3a
Replace legacy axios call in collection display with Galaxy api call
guerler Feb 28, 2025
5458489
Add error handler to datasets store and use in history dataset detail…
guerler Feb 28, 2025
2ac4359
Use history store to retrieve name, remove error handling
guerler Feb 28, 2025
08aef86
Use dataset store instead of cache handler
guerler Feb 28, 2025
6a5ad39
Replace attributeValue in HistoryDatasetDetails with computed value i…
guerler Feb 28, 2025
dd4fe2d
Add dataset text content store, remove generic cache
guerler Feb 28, 2025
2b5ca67
Remove cache reset call from markdown editor, prepare adjusted jest t…
guerler Feb 28, 2025
c711dc3
Add error handling to workflow license wrapper, use Galaxy API instea…
guerler Feb 28, 2025
3ba0c1c
Complete history dataset display test
guerler Feb 28, 2025
d2fbbb0
Fix dataset store condition to avoid repetitive redundant calls
guerler Feb 28, 2025
36f6532
The should fetch handler seems to be unnecessary since the dataset re…
guerler Feb 28, 2025
7022f13
Add basic workflow license rendering test
guerler Feb 28, 2025
3aed7b6
Update markdown galaxy test using history link component
guerler Mar 1, 2025
5b41428
Use extension instead of file_ext to match types in history dataset d…
guerler Mar 1, 2025
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
23 changes: 22 additions & 1 deletion client/src/api/datasets.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
import axios from "axios";

import { type components, GalaxyApi, type GalaxyApiPaths, type HDADetailed } from "@/api";
import {
type components,
type DatasetTextContentDetails,
GalaxyApi,
type GalaxyApiPaths,
type HDADetailed,
} from "@/api";
import { withPrefix } from "@/utils/redirect";
import { rethrowSimple } from "@/utils/simple-error";

export async function fetchDatasetTextContentDetails(params: { id: string }): Promise<DatasetTextContentDetails> {
const { data, error } = await GalaxyApi().GET("/api/datasets/{dataset_id}/get_content_as_text", {
params: {
path: {
dataset_id: params.id,
},
},
});

if (error) {
rethrowSimple(error);
}
return data;
}

export async function fetchDatasetDetails(params: { id: string }): Promise<HDADetailed> {
const { data, error } = await GalaxyApi().GET("/api/datasets/{dataset_id}", {
params: {
Expand Down
5 changes: 5 additions & 0 deletions client/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import { type components, type GalaxyApiPaths } from "@/api/schema";

export { type components, GalaxyApi, type GalaxyApiPaths };

/**
* Contains a dataset's text content and details
*/
export type DatasetTextContentDetails = components["schemas"]["DatasetTextContentDetails"];

/**
* Contains minimal information about a History.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ const isImage = computedAsync(async () => {
const res = await fetch(imageUrl.value);
const buff = await res.blob();
return buff.type.startsWith("image/");
}, null);
}, true);
</script>

<template>
<div>
<div v-if="imageUrl" class="w-100 p-2">
<b-card nobody body-class="p-1">
<b-img :src="imageUrl" fluid />
<span v-if="!isImage" class="text-danger">This dataset does not appear to be an image.</span>
<b-img v-else :src="imageUrl" fluid />
</b-card>
</div>
<div v-else>
Expand Down
15 changes: 10 additions & 5 deletions client/src/components/License/License.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
</template>

<script>
import axios from "axios";
import ExternalLink from "components/ExternalLink";
import LoadingSpan from "components/LoadingSpan";
import { getAppRoot } from "onload/loadConfig";

import { GalaxyApi } from "@/api";

export default {
components: {
Expand Down Expand Up @@ -62,9 +62,14 @@ export default {
methods: {
fetchLicense() {
this.license = null;
const url = `${getAppRoot()}api/licenses/${this.licenseId}`;
axios
.get(url)
GalaxyApi()
.GET("/api/licenses/{license_id}", {
params: {
path: {
license_id: this.licenseId,
},
},
})
.then((response) => response.data)
.then((data) => {
this.license = data;
Expand Down
79 changes: 79 additions & 0 deletions client/src/components/Markdown/Editor/TextEditor.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<template>
<div class="d-flex h-100 w-100">
<FlexPanel side="left">
<MarkdownToolBox :steps="steps" @insert="insertMarkdown" />
</FlexPanel>
<textarea
id="workflow-report-editor"
ref="textArea"
v-model="content"
class="markdown-textarea w-100 p-4"
@input="onUpdate" />
</div>
</template>

<script setup lang="ts">
import { debounce } from "lodash";
import { defineEmits, defineProps, nextTick, ref, watch } from "vue";

import MarkdownToolBox from "@/components/Markdown/MarkdownToolBox.vue";
import FlexPanel from "@/components/Panels/FlexPanel.vue";

const props = defineProps<{
markdownText: string;
mode: "report" | "page";
steps?: Record<string, any>;
title: string;
}>();

const emit = defineEmits<{
(e: "update", value: string): void;
}>();

const content = ref<string>(props.markdownText);
const textArea = ref<HTMLTextAreaElement | null>(null);

const FENCE = "```";

watch(
() => props.markdownText,
(newValue) => {
const textCursor = textArea.value?.selectionEnd || 0;
content.value = newValue;
nextTick(() => {
if (textArea.value) {
textArea.value.selectionEnd = textCursor;
textArea.value.focus();
}
});
}
);

function insertMarkdown(markdown: string) {
markdown = markdown.replace(")(", ", ");
markdown = `${FENCE}galaxy\n${markdown}\n${FENCE}\n`;
if (textArea.value) {
textArea.value.focus();
const cursorPosition = textArea.value.selectionStart;
const newContent =
content.value?.substr(0, cursorPosition) +
`\r\n${markdown.trim()}\r\n` +
content.value?.substr(cursorPosition);

emit("update", newContent || "");
}
}

const onUpdate = debounce((e: Event) => {
emit("update", content.value || "");
}, 300);
</script>

<style scoped>
.markdown-textarea {
border: none;
resize: none;
outline: none;
font: 14px/1.7 Menlo, Consolas, Monaco, "Andale Mono", monospace;
}
</style>
20 changes: 0 additions & 20 deletions client/src/components/Markdown/Elements/HistoryDatasetAsImage.vue

This file was deleted.

This file was deleted.

37 changes: 0 additions & 37 deletions client/src/components/Markdown/Elements/HistoryDatasetDetails.vue

This file was deleted.

Loading
Loading