-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16051 from jmchilton/refactor_object_store_compon…
…ents Refactor a few client object store components
- Loading branch information
Showing
14 changed files
with
162 additions
and
115 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
client/src/components/ObjectStore/ConfigurationMarkdown.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { shallowMount } from "@vue/test-utils"; | ||
import { getLocalVue } from "tests/jest/helpers"; | ||
import ConfigurationMarkdown from "./ConfigurationMarkdown.vue"; | ||
|
||
const localVue = getLocalVue(); | ||
|
||
describe("ConfigurationMarkdown.vue", () => { | ||
let wrapper; | ||
|
||
it("should convert supplied configuration markup to markdown and display", () => { | ||
wrapper = shallowMount(ConfigurationMarkdown, { | ||
propsData: { markdown: "the *content*", admin: true }, | ||
localVue, | ||
}); | ||
expect(wrapper.html()).toContain("<em>content</em>"); | ||
}); | ||
|
||
it("should allow HTML in configuration markdup explicitly set by the admin", () => { | ||
wrapper = shallowMount(ConfigurationMarkdown, { | ||
propsData: { markdown: "the <b>content</b>", admin: true }, | ||
localVue, | ||
}); | ||
expect(wrapper.html()).toContain("<b>content</b>"); | ||
}); | ||
|
||
it("should escape supplied HTML for non-admin sourced content", () => { | ||
wrapper = shallowMount(ConfigurationMarkdown, { | ||
propsData: { markdown: "the <b>content</b>", admin: false }, | ||
localVue, | ||
}); | ||
expect(wrapper.html()).not.toContain("<b>content</b>"); | ||
}); | ||
}); |
18 changes: 18 additions & 0 deletions
18
client/src/components/ObjectStore/ConfigurationMarkdown.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<script setup lang="ts"> | ||
import { computed } from "vue"; | ||
import { markup } from "./configurationMarkdown"; | ||
interface Props { | ||
markdown: string; | ||
admin: boolean; // was the configuration specified by an admin | ||
} | ||
const props = defineProps<Props>(); | ||
const markdownHtml = computed(() => markup(props.markdown ?? "", props.admin)); | ||
</script> | ||
<template> | ||
<!-- Disable v-html warning because we allow markdown generated HTML | ||
in various places in the Galaxy interface. Raw HTML will be | ||
excluded from markdown for all user generated content. | ||
--> | ||
<!-- eslint-disable-next-line vue/no-v-html --> | ||
<div v-html="markdownHtml" /> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 35 additions & 12 deletions
47
client/src/components/ObjectStore/ShowSelectedObjectStore.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,48 @@ | ||
<script setup lang="ts"> | ||
import LoadingSpan from "@/components/LoadingSpan.vue"; | ||
import { ObjectStoreDetailsProvider } from "@/components/providers/ObjectStoreProvider"; | ||
import DescribeObjectStore from "@/components/ObjectStore/DescribeObjectStore.vue"; | ||
import { getObjectStoreDetails } from "./services"; | ||
import { watch, ref } from "vue"; | ||
import type { ConcreteObjectStoreModel } from "./types"; | ||
import { errorMessageAsString } from "@/utils/simple-error"; | ||
interface ShowSelectObjectStoreProps { | ||
forWhat: String; | ||
preferredObjectStoreId?: String | null; | ||
forWhat: string; | ||
preferredObjectStoreId: string; | ||
} | ||
withDefaults(defineProps<ShowSelectObjectStoreProps>(), { | ||
preferredObjectStoreId: null, | ||
}); | ||
const props = defineProps<ShowSelectObjectStoreProps>(); | ||
const objectStore = ref<ConcreteObjectStoreModel | null>(null); | ||
const loading = ref(true); | ||
const error = ref<string | null>(null); | ||
async function fetch() { | ||
loading.value = true; | ||
try { | ||
objectStore.value = await getObjectStoreDetails(props.preferredObjectStoreId); | ||
} catch (e) { | ||
error.value = errorMessageAsString(e); | ||
} finally { | ||
loading.value = false; | ||
} | ||
} | ||
watch( | ||
() => props.preferredObjectStoreId, | ||
async () => { | ||
fetch(); | ||
} | ||
); | ||
fetch(); | ||
const loadingMessage = "Loading object store details"; | ||
</script> | ||
|
||
<template> | ||
<ObjectStoreDetailsProvider | ||
:id="preferredObjectStoreId" | ||
v-slot="{ result: storageInfo, loading: isLoadingStorageInfo }"> | ||
<LoadingSpan v-if="isLoadingStorageInfo" :message="loadingMessage | localize" /> | ||
<DescribeObjectStore v-else :what="forWhat" :storage-info="storageInfo"> </DescribeObjectStore> | ||
</ObjectStoreDetailsProvider> | ||
<div> | ||
<LoadingSpan v-if="loading" :message="loadingMessage | localize" /> | ||
<DescribeObjectStore v-else-if="objectStore != null" :what="forWhat" :storage-info="objectStore"> | ||
</DescribeObjectStore> | ||
<b-alert v-else-if="error" show variant="danger">{{ error }}</b-alert> | ||
</div> | ||
</template> |
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
client/src/components/ObjectStore/configurationMarkdown.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import MarkdownIt from "markdown-it"; | ||
|
||
export function markup(markup: string, adminConfigured: boolean): string | null { | ||
let markupHtml; | ||
const allowHtml = adminConfigured ? true : false; | ||
if (markup) { | ||
markupHtml = MarkdownIt({ html: allowHtml }).render(markup); | ||
} else { | ||
markupHtml = null; | ||
} | ||
return markupHtml; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import type { components } from "@/schema"; | ||
|
||
export type ConcreteObjectStoreModel = components["schemas"]["ConcreteObjectStoreModel"]; |
Oops, something went wrong.