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

Conversation

guerler
Copy link
Contributor

@guerler guerler commented Feb 27, 2025

This PR modularizes Markdown components in preparation for supporting additional element types. Currently, we support only default/markdown and galaxy.

Additionally, this PR enhances Galaxy components by introducing reactivity, a necessary step for the upcoming component preview.

The PR also refactors components to render elements without requiring requests to the Pages API for dataset IDs. Instead, components now interact solely with their respective resource endpoints. To prevent redundant requests, a simple caching mechanism has been implemented.

These structural changes are essential for the upcoming markdown handling and editing features from #19226.

How to test the changes?

(Select all options that apply)

  • I've included appropriate automated tests.
  • This is a refactoring of components with existing test coverage.
  • Instructions for manual testing are as follows:
    1. [add testing steps and prerequisites here if you didn't write automated tests covering all your changes]

License

  • I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.

@guerler guerler added kind/enhancement area/UI-UX kind/refactoring cleanup or refactoring of existing code, no functional changes labels Feb 27, 2025
@guerler guerler added this to the 25.0 milestone Feb 27, 2025
Copy link
Contributor

@davelopez davelopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pretty good progress, but I feel, on some points, it is just a half-step in the right direction.
Instead of adding another isolated cache that doesn't respect types, we could leverage the existing Pinia stores more or improve them if needed.
Also, we should avoid using axios as much as we can while we have properly typed FastAPI routes that can be accessed using the GalaxyApi client.

Below are just some recommendations. I know using proper or stricter types is hard, but we are benefiting from it by avoiding a significant number of bugs in the future by investing in them now.

Comment on lines 68 to 74
const itemContent = ref<any>(null);
const loading = ref(true);
const messageText = ref<string | null>(null);
const messageVariant = ref<string | null>(null);

const itemName = computed(() => itemContent.value?.name || "");
const itemUrl = computed(() => `${getAppRoot()}api/dataset_collections/${props.collectionId}`);
const downloadUrl = computed(() => `${getAppRoot()}api/dataset_collections/${props.collectionId}/download`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have FastAPI endpoints with typed responses for those requests. Please use them as much as you can instead of axios. Then itemContent will have the correct type instead of any.

Also, another recommendation: I know this was just converting the old code, but unless you really need to handle null cases in a meaningful way, I think it is better to write:
ref<string>(); instead of ref<string | null>(null); then you are only dealing with the defined/undefined case in your conditions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for all your comments—I completely agree. We should exclusively use stores and eliminate legacy Axios calls. However, I didn’t address this in this refactoring since my primary focus was restructuring the directories in this PR.

That said, another issue we might want to tackle is establishing a more consistent store interface. While we have many well-implemented stores, their interfaces are not entirely uniform.

That being said, I did replace the Axios call in this component with a schema-conformant call using Galaxy API. Additionally, I updated the ref to prevent null values.

try {
const attributeName = ATTRIBUTES[props.name] || "";
if (attributeName) {
const data = await fromCache(`datasets/${datasetId}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what benefit brings another generic cache when we have already a store for datasets and other entities, but I do see some drawbacks, like duplicated requests, duplicated memory and no type inference.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a new text content store for datasets and removed the generic cache.

…s component instead of generic cache wrapper
@guerler guerler force-pushed the revise_markdown_wrapper branch from 1a0ce71 to 3aed7b6 Compare March 1, 2025 01:07
…isplay component (file_ext seems to be missing in pdfs?)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/UI-UX kind/enhancement kind/refactoring cleanup or refactoring of existing code, no functional changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants