Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add admin activity to activity bar #17877

Merged
merged 16 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions client/src/components/ActivityBar/ActivityBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import InteractiveItem from "./Items/InteractiveItem.vue";
import NotificationItem from "./Items/NotificationItem.vue";
import UploadItem from "./Items/UploadItem.vue";
import AdminPanel from "@/components/admin/AdminPanel.vue";
import FlexPanel from "@/components/Panels/FlexPanel.vue";
import MultiviewPanel from "@/components/Panels/MultiviewPanel.vue";
import NotificationsPanel from "@/components/Panels/NotificationsPanel.vue";
Expand All @@ -31,7 +32,7 @@

const eventStore = useEventStore();
const activityStore = useActivityStore();
const { isAnonymous } = storeToRefs(userStore);
const { isAdmin, isAnonymous } = storeToRefs(userStore);

const emit = defineEmits(["dragstart"]);

Expand Down Expand Up @@ -137,7 +138,7 @@

<template>
<div class="d-flex">
<div

Check warning on line 141 in client/src/components/ActivityBar/ActivityBar.vue

View workflow job for this annotation

GitHub Actions / client-unit-test (18)

Visible, non-interactive elements should not have an interactive handler
class="activity-bar d-flex flex-column no-highlight"
data-description="activity bar"
@dragover.prevent="onDragOver"
Expand Down Expand Up @@ -173,7 +174,7 @@
:to="activity.to"
@click="onToggleSidebar()" />
<ActivityItem
v-else-if="['tools', 'visualizations', 'multiview'].includes(activity.id)"
v-else-if="['admin', 'tools', 'visualizations', 'multiview'].includes(activity.id)"
:id="`activity-${activity.id}`"
:key="activity.id"
:icon="activity.icon"
Expand Down Expand Up @@ -211,6 +212,15 @@
title="Settings"
tooltip="Edit preferences"
@click="onToggleSidebar('settings')" />
<ActivityItem
v-if="isAdmin"
id="activity-admin"
icon="user-cog"
:is-active="isActiveSideBar('admin')"
title="Admin"
tooltip="Administer this Galaxy"
variant="danger"
@click="onToggleSidebar('admin')" />
</b-nav>
</div>
<FlexPanel v-if="isSideBarOpen" side="left" :collapsible="false">
Expand All @@ -219,6 +229,7 @@
<MultiviewPanel v-else-if="isActiveSideBar('multiview')" />
<NotificationsPanel v-else-if="isActiveSideBar('notifications')" />
<SettingsPanel v-else-if="isActiveSideBar('settings')" />
<AdminPanel v-else-if="isActiveSideBar('admin')" />
</FlexPanel>
</div>
</template>
Expand Down
4 changes: 3 additions & 1 deletion client/src/components/ActivityBar/ActivityItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
progressStatus?: string;
options?: Option[];
to?: string;
variant?: string;
}

const props = withDefaults(defineProps<Props>(), {
Expand All @@ -37,6 +38,7 @@
to: undefined,
tooltip: undefined,
tooltipPlacement: "right",
variant: "primary",
});

const emit = defineEmits<{
Expand All @@ -54,7 +56,7 @@
<template>
<Popper reference-is="span" popper-is="span" :placement="tooltipPlacement">
<template v-slot:reference>
<div :id="id" class="activity-item" @click="onClick">

Check warning on line 59 in client/src/components/ActivityBar/ActivityItem.vue

View workflow job for this annotation

GitHub Actions / client-unit-test (18)

Visible, non-interactive elements with click handlers must have at least one keyboard listener

Check warning on line 59 in client/src/components/ActivityBar/ActivityItem.vue

View workflow job for this annotation

GitHub Actions / client-unit-test (18)

Visible, non-interactive elements should not have an interactive handler
<b-nav-item
class="position-relative my-1 p-2"
:class="{ 'nav-item-active': isActive }"
Expand All @@ -70,7 +72,7 @@
width: `${Math.round(progressPercentage)}%`,
}" />
</span>
<span class="position-relative">
<span class="position-relative" :class="`text-${variant}`">
<div class="nav-icon">
<span v-if="indicator > 0" class="nav-indicator" data-description="activity indicator">
{{ Math.min(indicator, 99) }}
Expand Down
43 changes: 30 additions & 13 deletions client/src/components/admin/AdminPanel.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import { mount } from "@vue/test-utils";
import { getLocalVue } from "tests/jest/helpers";

import { useConfig } from "@/composables/config";

import MountTarget from "./AdminPanel.vue";

const localVue = getLocalVue(true);

jest.mock("@/composables/config", () => ({
useConfig: jest.fn(() => ({
config: { value: { enable_quotas: true, tool_shed_urls: ["tool_shed_url"], version_major: "1.0.1" } },
isConfigLoaded: true,
})),
}));

function createTarget(propsData = {}) {
return mount(MountTarget, {
localVue,
Expand All @@ -16,21 +25,29 @@ function createTarget(propsData = {}) {
}

describe("AdminPanel", () => {
it("ensure reactivity to prop changes", async () => {
const wrapper = createTarget();
const sections = {
isToolshedInstalled: "#admin-link-toolshed",
enableQuotas: "#admin-link-quotas",
};
for (const elementId of Object.values(sections)) {
expect(wrapper.find(elementId).exists()).toBe(false);
}
it("ensure section visibility with config changes", async () => {
const options = [
{
name: "tool_shed_urls",
elementId: "#admin-link-toolshed",
value: ["toolshed_url"],
},
{
name: "enable_quotas",
elementId: "#admin-link-quotas",
value: true,
},
];
for (const available of [true, false]) {
for (const [propId, elementId] of Object.entries(sections)) {
for (const option of options) {
const props = {};
props[propId] = available;
await wrapper.setProps(props);
expect(wrapper.find(elementId).exists()).toBe(available);
props[option.name] = available ? option.value : undefined;
useConfig.mockImplementation(() => ({
config: { value: { ...props, version_major: "1.0.1" } },
isConfigLoaded: true,
}));
const wrapper = createTarget();
expect(wrapper.find(option.elementId).exists()).toBe(available);
}
}
});
Expand Down
Loading
Loading