Skip to content

Commit

Permalink
Merge pull request galaxyproject#16040 from ElectronicBlueberry/histo…
Browse files Browse the repository at this point in the history
…ry-selector

New history selector with quick actions
  • Loading branch information
davelopez authored May 5, 2023
2 parents 41d93e9 + c73c75c commit 853d009
Show file tree
Hide file tree
Showing 16 changed files with 445 additions and 178 deletions.
10 changes: 5 additions & 5 deletions client/docs/composables.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Example: accessing the current user from the store

```vue
<script setup>
import { useCurrentUser } from "composables/user";
import { useCurrentUser } from "@/composables/user";
const { currentUser } = useCurrentUser();
</script>
Expand All @@ -30,7 +30,7 @@ Composables are not limited to the composition api. This is the same example fro

```vue
<script>
import { useCurrentUser } from "composables/user";
import { useCurrentUser } from "@/composables/user";
export default {
setup() {
Expand Down Expand Up @@ -75,7 +75,7 @@ const store = new Vuex.Store({
The second option is to mock the composable:

```js
import { useCurrentUser } from "composables/user";
import { useCurrentUser } from "@/composables/user";

jest.mock("composables/user");
useCurrentUser.mockReturnValue({
Expand All @@ -87,13 +87,13 @@ While simpler in this example, you may need to manually mock more return values

## Using Composables for more than Stores

Composables can be of great use to extract any reactive code from your components. For an example of this, take a look at [useFilterObjectArray](https://github.com/galaxyproject/galaxy/blob/dev/client/src/composables/utils/filter.js).
Composables can be of great use to extract any reactive code from your components. For an example of this, take a look at [useFilterObjectArray](https://github.com/galaxyproject/galaxy/blob/dev/client/src/composables/filter/filter.ts).

Usage:

```vue
<script setup>
import { useFilterObjectArray } from "composables/utils/filter";
import { useFilterObjectArray } from "@/composables/filter/filter";
const filteredArray = useFilterObjectArray(someReactiveArray, searchValue, ["name", "description"]);
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { ref } from "vue";
import { useDetailedDatatypes, type DetailedDatatypes } from "@/composables/datatypes";
import { useFilterObjectArray } from "@/composables/utils/filter";
import { useFilterObjectArray } from "@/composables/filter";
import DelayedInput from "@/components/Common/DelayedInput.vue";
const filter = ref("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import HistoryNavigation from "./HistoryNavigation";

const localVue = getLocalVue();

jest.mock("@/composables/filter");

// all options
const expectedOptions = [
"Show Histories Side-by-Side",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
id="selector-history-modal"
:histories="histories"
:current-history-id="history.id"
:additional-options="['center', 'multi']"
@selectHistory="$emit('setCurrentHistory', $event)" />

<CopyModal id="copy-current-history-modal" :history="history" />
Expand Down
17 changes: 13 additions & 4 deletions client/src/components/History/Modals/SelectorModal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import flushPromises from "flush-promises";
import SelectorModal from "./SelectorModal";
import { getLocalVue } from "tests/jest/helpers";
import { useHistoryStore } from "stores/historyStore";
import { BListGroupItem } from "bootstrap-vue";

jest.mock("@/composables/filter");

const localVue = getLocalVue();

Expand Down Expand Up @@ -58,9 +61,14 @@ describe("History SelectorModal.vue", () => {
it("paginates the histories", async () => {
await mountWith(PROPS_WITH_10_HISTORIES);

const displayedRows = wrapper.findAll("tbody > tr").wrappers;
const displayedRows = wrapper.findAllComponents(BListGroupItem).wrappers;
expect(displayedRows.length).toBe(3);
expect(wrapper.vm.histories.length).toBe(10);

// filter out all page buttons. e.g [1] [2] [3] etc...
const pages = wrapper
.findAll(".pagination > .page-item")
.wrappers.filter((item) => item.text().match(/[0-9]+/));
expect(pages.length).toBe(4);
});

it("emits selectHistory with the correct history ID when a row is clicked", async () => {
Expand Down Expand Up @@ -90,9 +98,10 @@ describe("History SelectorModal.vue", () => {
const targetRow2 = wrapper.find(`[data-pk="${targetHistoryId2}"]`);
await targetRow2.trigger("click");

expect(wrapper.vm.selectedHistories.length).toBe(2);
const selectedHistories = wrapper.findAll(".list-group-item.active").wrappers;
expect(selectedHistories.length).toBe(2);

const button = wrapper.find(".btn-primary");
const button = wrapper.find("footer > .btn-primary");

await button.trigger("click");

Expand Down
Loading

0 comments on commit 853d009

Please sign in to comment.