Make file source form alerts template configurable

This commit is contained in:
mvdbeek
2026-07-13 12:44:15 +02:00
parent 4939956675
commit 7cc9dcd9f3
7 changed files with 87 additions and 14 deletions
@@ -13138,10 +13138,25 @@ export interface components {
};
/** FileSourceTemplateSummaries */
FileSourceTemplateSummaries: components["schemas"]["FileSourceTemplateSummary"][];
/** FileSourceTemplateAlert */
FileSourceTemplateAlert: {
/** Condition */
condition?: string | null;
/** Content */
content: string;
/**
* Variant
* @default info
* @enum {string}
*/
variant?: "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "light" | "dark";
};
/** FileSourceTemplateSummary */
FileSourceTemplateSummary: {
/** Description */
description: string | null;
/** Form Alerts */
form_alerts?: components["schemas"]["FileSourceTemplateAlert"][] | null;
/**
* Hidden
* @default false
@@ -7,6 +7,8 @@ import { useConfigurationTemplateCreation } from "@/components/ConfigTemplates/u
import { useGithubRepositoryOptions } from "./useGithubRepositoryOptions";
import ConfigurationMarkdown from "@/components/ObjectStore/ConfigurationMarkdown.vue";
const createUrl = "/api/file_source_instances";
const createTestUrl = "/api/file_source_instances/test";
@@ -27,12 +29,19 @@ function onFormChange(incoming: Record<string, unknown>) {
formData.value = incoming;
}
const { dynamicOptions, isRepositoryPicker, noRepositoriesFound } = useGithubRepositoryOptions(
const { alertConditions, dynamicOptions } = useGithubRepositoryOptions(
toRef(props, "template"),
toRef(props, "uuid"),
formData,
);
const formAlerts = computed(() => {
const activeConditions = new Set(alertConditions.value);
return (props.template.form_alerts ?? []).filter(
(alert) => !alert.condition || activeConditions.has(alert.condition),
);
});
const { ActionSummary, error, inputs, InstanceForm, onSubmit, submitTitle, loadingMessage, testRunning, testResults } =
useConfigurationTemplateCreation(
"file source",
@@ -47,18 +56,8 @@ const { ActionSummary, error, inputs, InstanceForm, onSubmit, submitTitle, loadi
<template>
<div id="create-file-source-landing">
<ActionSummary error-data-description="file-source-creation-error" :test-results="testResults" :error="error" />
<BAlert v-if="noRepositoriesFound" show variant="warning" data-description="github-no-repositories">
The GitHub App isn't installed on any repository you can access, so there are no owners or
repositories to choose. Install it on at least one repository from your
<a href="https://github.com/settings/installations" target="_blank" rel="noopener noreferrer">
installed GitHub Apps </a
>, then reload this page.
</BAlert>
<BAlert v-else-if="isRepositoryPicker" show variant="info" data-description="github-manage-repositories">
Need access to another repository? Update the GitHub App's repository access in a new tab from your
<a href="https://github.com/settings/installations" target="_blank" rel="noopener noreferrer">
installed GitHub Apps</a
>, then reload this page.
<BAlert v-for="alert in formAlerts" :key="alert.content" show :variant="alert.variant">
<ConfigurationMarkdown :markdown="alert.content" :admin="true" />
</BAlert>
<InstanceForm
:inputs="inputs"
@@ -82,6 +82,18 @@ export function useGithubRepositoryOptions(
repositories.value.length === 0,
);
// These semantic conditions deliberately describe picker state rather than GitHub-specific
// wording. Template-defined alerts decide what, if anything, to show for each state.
const alertConditions = computed(() => {
if (noRepositoriesFound.value) {
return ["repository_picker_empty"];
}
if (isRepositoryPicker.value) {
return ["repository_picker_available"];
}
return [];
});
async function fetchRepositories() {
if (!isRepositoryPicker.value || !uuid.value) {
return;
@@ -116,7 +128,7 @@ export function useGithubRepositoryOptions(
watch([uuid, isRepositoryPicker], () => void fetchRepositories(), { immediate: true });
return { dynamicOptions, loading, error, isRepositoryPicker, noRepositoriesFound };
return { dynamicOptions, loading, error, isRepositoryPicker, noRepositoriesFound, alertConditions };
}
function findVariableByMarker(template: FileSourceTemplateSummary, marker: string): string | undefined {
+6
View File
@@ -281,6 +281,12 @@ pointed to by the configuration option `file_source_templates_config_file` in `g
Alternatively, the configuration can be placed directly into `galaxy.yml` using the
`file_source_templates` configuration option.
A template can define `form_alerts` to show administrator-authored Markdown alerts while a
user creates an instance. Each alert has a Bootstrap `variant` and optional `condition`; alerts
without a condition are always shown. Template capabilities can expose condition names for
source-specific states, allowing the template to control the message without hard-coding it in
the form component.
### File Source Types
#### `posix`
@@ -9,6 +9,20 @@
You authorize Galaxy to access GitHub on your behalf through GitHub's OAuth flow - no
personal access token is required. Each repository is a separate file source: create one
instance of this template per repository you want to access.
form_alerts:
- condition: repository_picker_empty
variant: warning
content: |
The GitHub App isn't installed on any repository you can access, so there are no owners or
repositories to choose. Install it on at least one repository from your
<a href="https://github.com/settings/installations" target="_blank" rel="noopener noreferrer">installed GitHub Apps</a>,
then reload this page.
- condition: repository_picker_available
variant: info
content: |
Need access to another repository? Update the GitHub App's repository access from your
<a href="https://github.com/settings/installations" target="_blank" rel="noopener noreferrer">installed GitHub Apps</a>
in a new tab, then reload this page.
variables:
org:
label: Repository Owner
+22
View File
@@ -56,6 +56,27 @@ FileSourceTemplateType = Literal[
"ssh",
]
FileSourceTemplateAlertVariant = Literal[
"primary",
"secondary",
"success",
"danger",
"warning",
"info",
"light",
"dark",
]
class FileSourceTemplateAlert(StrictModel):
"""An administrator-authored alert shown while creating a file source."""
content: MarkdownContent
variant: FileSourceTemplateAlertVariant = "info"
# A condition is supplied by a client-side template capability. Omit it for an alert that
# should always be visible.
condition: str | None = None
class PosixFileSourceTemplateConfiguration(StrictModel):
type: Literal["posix"]
@@ -588,6 +609,7 @@ class FileSourceTemplateBase(StrictModel):
# template by hiding but keep it in the catalog for backward
# compatibility for users with existing stores of that template.
hidden: bool = False
form_alerts: list[FileSourceTemplateAlert] | None = None
variables: list[TemplateVariable] | None = None
secrets: list[TemplateSecret] | None = None
+5
View File
@@ -296,6 +296,11 @@ def test_production_aws_public_bucket():
def test_production_github_oauth():
github_template = _get_example_template("production_github.yml")
assert github_template.form_alerts is not None
assert [alert.condition for alert in github_template.form_alerts] == [
"repository_picker_empty",
"repository_picker_available",
]
configuration_obj = template_to_configuration(
github_template,
{"org": "galaxyproject", "repo": "galaxy"},