Skip to content

Commit

Permalink
Add total quota to quota meter
Browse files Browse the repository at this point in the history
  • Loading branch information
guerler committed Jun 1, 2024
1 parent 5cdd404 commit 4430b42
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion client/src/components/Masthead/QuotaMeter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ describe("QuotaMeter.vue", () => {
const user = {
total_disk_usage: 5120,
quota_percent: 50,
quota: "100 MB",
};
const config = { enable_quotas: true };
const wrapper = await createQuotaMeterWrapper(config, user);
expect(wrapper.find(".quota-progress > span").text()).toBe("Using 50%");
expect(wrapper.find(".quota-progress > span").text()).toBe("Using 50% of 100 MB");
});

it("changes appearance depending on usage", async () => {
Expand Down
16 changes: 11 additions & 5 deletions client/src/components/Masthead/QuotaMeter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const hasQuota = computed(() => {
return quotasEnabled && quotaLimited;
});
const quotaLimit = computed(() => currentUser.value?.quota ?? 0);
const totalUsageString = computed(() => {
const total = currentUser.value?.total_disk_usage ?? 0;
return bytesToString(total, true);
Expand Down Expand Up @@ -44,8 +46,14 @@ const variant = computed(() => {
<BProgress :max="100">
<BProgressBar aria-label="Quota usage" :value="usage" :variant="variant" />
</BProgress>
<span v-if="hasQuota">{{ "Using " + usage.toFixed(0) }}%</span>
<span v-else>{{ "Using " + totalUsageString }}</span>
<span>
<span v-localize>Using</span>
<span v-if="hasQuota">
<span>{{ usage.toFixed(0) }}%</span>
<span v-if="quotaLimit !== 0">of {{ quotaLimit }}</span>
</span>
<span v-else>{{ totalUsageString }}</span>
</span>
</BLink>
</div>
</template>
Expand All @@ -57,16 +65,14 @@ const variant = computed(() => {
margin-left: 0.5rem;
margin-right: 0.5rem;
.quota-progress {
width: 150px;
width: 12rem;
height: 1.4em;
position: relative;
& > * {
position: absolute;
width: 100%;
height: 100%;
text-align: center;
}
& > span {
line-height: 1.4em;
pointer-events: none;
}
Expand Down

0 comments on commit 4430b42

Please sign in to comment.