-
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.
Implement quota tracking options per ObjectStore.
- Loading branch information
Showing
36 changed files
with
1,434 additions
and
289 deletions.
There are no files selected for viewing
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
80 changes: 80 additions & 0 deletions
80
client/src/components/ObjectStore/DescribeObjectStore.test.js
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,80 @@ | ||
import { shallowMount } from "@vue/test-utils"; | ||
import DescribeObjectStore from "./DescribeObjectStore"; | ||
import { getLocalVue } from "tests/jest/helpers"; | ||
import MarkdownIt from "markdown-it"; | ||
|
||
const localVue = getLocalVue(); | ||
|
||
const TEST_STORAGE_API_RESPONSE_WITHOUT_ID = { | ||
object_store_id: null, | ||
private: false, | ||
}; | ||
const TEST_RENDERED_MARKDOWN_AS_HTML = "<p>My cool <strong>markdown</strong>\n"; | ||
|
||
const TEST_STORAGE_API_RESPONSE_WITH_ID = { | ||
object_store_id: "foobar", | ||
private: false, | ||
}; | ||
const TEST_STORAGE_API_RESPONSE_WITH_NAME = { | ||
object_store_id: "foobar", | ||
name: "my cool storage", | ||
description: "My cool **markdown**", | ||
private: true, | ||
}; | ||
|
||
// works fine without mocking but I guess it is more JS unit-y with the mock? | ||
jest.mock("markdown-it"); | ||
MarkdownIt.mockImplementation(() => { | ||
return { | ||
render(markdown) { | ||
return TEST_RENDERED_MARKDOWN_AS_HTML; | ||
}, | ||
}; | ||
}); | ||
|
||
describe("DescribeObjectStore.vue", () => { | ||
let wrapper; | ||
|
||
async function mountWithResponse(response) { | ||
wrapper = shallowMount(DescribeObjectStore, { | ||
propsData: { storageInfo: response, what: "where i am throwing my test dataset" }, | ||
localVue, | ||
}); | ||
} | ||
|
||
it("test dataset storage with object store without id", async () => { | ||
await mountWithResponse(TEST_STORAGE_API_RESPONSE_WITHOUT_ID); | ||
expect(wrapper.findAll("loading-span-stub").length).toBe(0); | ||
expect(wrapper.vm.descriptionRendered).toBeNull(); | ||
const byIdSpan = wrapper.findAll(".display-os-by-id"); | ||
expect(byIdSpan.length).toBe(0); | ||
const byNameSpan = wrapper.findAll(".display-os-by-name"); | ||
expect(byNameSpan.length).toBe(0); | ||
const byDefaultSpan = wrapper.findAll(".display-os-default"); | ||
expect(byDefaultSpan.length).toBe(1); | ||
}); | ||
|
||
it("test dataset storage with object store id", async () => { | ||
await mountWithResponse(TEST_STORAGE_API_RESPONSE_WITH_ID); | ||
expect(wrapper.findAll("loading-span-stub").length).toBe(0); | ||
expect(wrapper.vm.storageInfo.object_store_id).toBe("foobar"); | ||
expect(wrapper.vm.descriptionRendered).toBeNull(); | ||
const byIdSpan = wrapper.findAll(".display-os-by-id"); | ||
expect(byIdSpan.length).toBe(1); | ||
const byNameSpan = wrapper.findAll(".display-os-by-name"); | ||
expect(byNameSpan.length).toBe(0); | ||
expect(wrapper.find("object-store-restriction-span-stub").props("isPrivate")).toBeFalsy(); | ||
}); | ||
|
||
it("test dataset storage with object store name", async () => { | ||
await mountWithResponse(TEST_STORAGE_API_RESPONSE_WITH_NAME); | ||
expect(wrapper.findAll("loading-span-stub").length).toBe(0); | ||
expect(wrapper.vm.storageInfo.object_store_id).toBe("foobar"); | ||
expect(wrapper.vm.descriptionRendered).toBe(TEST_RENDERED_MARKDOWN_AS_HTML); | ||
const byIdSpan = wrapper.findAll(".display-os-by-id"); | ||
expect(byIdSpan.length).toBe(0); | ||
const byNameSpan = wrapper.findAll(".display-os-by-name"); | ||
expect(byNameSpan.length).toBe(1); | ||
expect(wrapper.find("object-store-restriction-span-stub").props("isPrivate")).toBeTruthy(); | ||
}); | ||
}); |
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,70 @@ | ||
<template> | ||
<div> | ||
<div> | ||
<span v-localize>{{ what }}</span> | ||
<span v-if="storageInfo.name" class="display-os-by-name"> | ||
a Galaxy <object-store-restriction-span :is-private="isPrivate" /> object store named | ||
<b>{{ storageInfo.name }}</b> | ||
</span> | ||
<span v-else-if="storageInfo.object_store_id" class="display-os-by-id"> | ||
a Galaxy <object-store-restriction-span :is-private="isPrivate" /> object store with id | ||
<b>{{ storageInfo.object_store_id }}</b> | ||
</span> | ||
<span v-else class="display-os-default"> | ||
the default configured Galaxy <object-store-restriction-span :is-private="isPrivate" /> object store </span | ||
>. | ||
</div> | ||
<QuotaSourceUsageProvider | ||
v-if="storageInfo.quota && storageInfo.quota.enabled" | ||
v-slot="{ result: quotaUsage, loading: isLoadingUsage }" | ||
:quota-source-label="quotaSourceLabel"> | ||
<b-spinner v-if="isLoadingUsage" /> | ||
<QuotaUsageBar v-else-if="quotaUsage" :quota-usage="quotaUsage" :embedded="true" /> | ||
</QuotaSourceUsageProvider> | ||
<div v-else>Galaxy has no quota configured for this object store.</div> | ||
<div v-html="descriptionRendered"></div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import MarkdownIt from "markdown-it"; | ||
import ObjectStoreRestrictionSpan from "./ObjectStoreRestrictionSpan"; | ||
import QuotaUsageBar from "components/User/DiskUsage/Quota/QuotaUsageBar"; | ||
import { QuotaSourceUsageProvider } from "components/User/DiskUsage/Quota/QuotaUsageProvider"; | ||
export default { | ||
components: { | ||
ObjectStoreRestrictionSpan, | ||
QuotaSourceUsageProvider, | ||
QuotaUsageBar, | ||
}, | ||
props: { | ||
storageInfo: { | ||
type: Object, | ||
required: true, | ||
}, | ||
what: { | ||
type: String, | ||
required: true, | ||
}, | ||
}, | ||
computed: { | ||
quotaSourceLabel() { | ||
return this.storageInfo.quota?.source; | ||
}, | ||
descriptionRendered() { | ||
const description = this.storageInfo.description; | ||
let descriptionRendered; | ||
if (description) { | ||
descriptionRendered = MarkdownIt({ html: true }).render(description); | ||
} else { | ||
descriptionRendered = null; | ||
} | ||
return descriptionRendered; | ||
}, | ||
isPrivate() { | ||
return this.storageInfo.private; | ||
}, | ||
}, | ||
}; | ||
</script> |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...setStorage/ObjectStoreRestrictionSpan.vue → ...bjectStore/ObjectStoreRestrictionSpan.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
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
Oops, something went wrong.