-
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,430 additions
and
286 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
83 changes: 83 additions & 0 deletions
83
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,83 @@ | ||
import { shallowMount } from "@vue/test-utils"; | ||
import DescribeObjectStore from "./DescribeObjectStore"; | ||
import { getLocalVue } from "jest/helpers"; | ||
// import flushPromises from "flush-promises"; | ||
// import MockAdapter from "axios-mock-adapter"; | ||
// import axios from "axios"; | ||
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 class="display-os-by-name" v-if="storageInfo.name"> | ||
a Galaxy <object-store-restriction-span :is-private="isPrivate" /> object store named | ||
<b>{{ storageInfo.name }}</b> | ||
</span> | ||
<span class="display-os-by-id" v-else-if="storageInfo.object_store_id"> | ||
a Galaxy <object-store-restriction-span :is-private="isPrivate" /> object store with id | ||
<b>{{ storageInfo.object_store_id }}</b> | ||
</span> | ||
<span class="display-os-default" v-else> | ||
the default configured Galaxy <object-store-restriction-span :is-private="isPrivate" /> object store </span | ||
>. | ||
</div> | ||
<QuotaSourceUsageProvider | ||
:quotaSourceLabel="quotaSourceLabel" | ||
v-if="storageInfo.quota && storageInfo.quota.enabled" | ||
v-slot="{ result: quotaUsage, loading: isLoadingUsage }"> | ||
<b-spinner v-if="isLoadingUsage" /> | ||
<QuotaUsageBar v-else-if="quotaUsage" :quota-usage="quotaUsage" :embedded="true" /> | ||
</QuotaSourceUsageProvider> | ||
<div v-else>Galaxy has no quota configured fo 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.
File renamed without changes.
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.