Skip to content

Commit d6c4291

Browse files
move Galaxy config citation to CitationsList directly instead of services
We decided that it makes more sense for the Galaxy citation to be shown in the `Export Tool References` view, rather than on each tool form as well.
1 parent 967c8fd commit d6c4291

3 files changed

Lines changed: 88 additions & 17 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { getLocalVue } from "@tests/jest/helpers";
2+
import { mount, type Wrapper } from "@vue/test-utils";
3+
import flushPromises from "flush-promises";
4+
5+
import CitationItem from "./CitationItem.vue";
6+
import MountTarget from "./CitationsList.vue";
7+
8+
const localVue = getLocalVue(true);
9+
10+
jest.mock("@/composables/config", () => ({
11+
useConfig: jest.fn(() => ({
12+
config: {
13+
value: {
14+
citation_bibtex:
15+
"@article{Galaxy2024, title={The Galaxy platform for accessible, reproducible, and collaborative data analyses: 2024 update}, author={{The Galaxy Community}}, journal={Nucleic Acids Research}, year={2024}, doi={10.1093/nar/gkae410}, url={https://doi.org/10.1093/nar/gkae410}}",
16+
},
17+
},
18+
})),
19+
}));
20+
21+
jest.mock("@/components/Citation/services", () => ({
22+
getCitations: jest.fn(() =>
23+
Promise.resolve([
24+
{
25+
raw: "@article{Hourahine_2020,\n\tdoi = {10.1063/1.5143190},\n\turl = {https://doi.org/10.1063%2F1.5143190},\n\tyear = 2020,\n\tmonth = {mar},\n\tpublisher = {{AIP} Publishing},\n\tvolume = {152},\n\tnumber = {12},\n\tpages = {124101},\n\tauthor = {B. Hourahine and B. Aradi and V. Blum and F. Bonaf{\\'{e}} and A. Buccheri and C. Camacho and C. Cevallos and M. Y. Deshaye and T. Dumitric{\\u{a}} and A. Dominguez and S. Ehlert and M. Elstner and T. van der Heide and J. Hermann and S. Irle and J. J. Kranz and C. K\u00f6hler and T. Kowalczyk and T. Kuba{\\v{r}} and I. S. Lee and V. Lutsker and R. J. Maurer and S. K. Min and I. Mitchell and C. Negre and T. A. Niehaus and A. M. N. Niklasson and A. J. Page and A. Pecchia and G. Penazzi and M. P. Persson and J. {\\v{R}}ez{\\'{a}}{\\v{c}} and C. G. S{\\'{a}}nchez and M. Sternberg and M. St\u00f6hr and F. Stuckenberg and A. Tkatchenko and V. W.-z. Yu and T. Frauenheim},\n\ttitle = {{DFTB}$\\mathplus$, a software package for efficient approximate density functional theory based atomistic simulations},\n\tjournal = {The Journal of Chemical Physics}\n}",
26+
cite: {
27+
format: jest.fn(
28+
() =>
29+
'<div class="csl-bib-body"><div data-csl-entry-id="Hourahine_2020" class="csl-entry">Hourahine, B. (2020). DFTB$\\mathplus$, a software package for efficient approximate density functional theory based atomistic simulations. The Journal of Chemical Physics, 152(12), 124101. https://doi.org/10.1063/1.5143190</div></div>'
30+
),
31+
},
32+
},
33+
])
34+
),
35+
}));
36+
37+
describe("CitationsList", () => {
38+
let wrapper: Wrapper<Vue>;
39+
40+
beforeEach(async () => {
41+
wrapper = mount(MountTarget as object, {
42+
propsData: {
43+
id: "test-id",
44+
source: "histories",
45+
},
46+
localVue,
47+
});
48+
49+
await flushPromises();
50+
});
51+
52+
it("renders the config Galaxy citation and any fetched citations", () => {
53+
const citationItems = wrapper.findAllComponents(CitationItem);
54+
55+
// It finds the Galaxy citation from the config, and the mocked citation for the history tools.
56+
expect(citationItems.length).toBe(2);
57+
58+
expect(citationItems.at(0).text()).toContain(
59+
"The Galaxy platform for accessible, reproducible, and collaborative data analyses: 2024 update"
60+
);
61+
expect(citationItems.at(1).text()).toContain(
62+
"DFTB$\\mathplus$, a software package for efficient approximate density functional theory based atomistic simulations"
63+
);
64+
});
65+
});

‎client/src/components/Citation/CitationsList.vue‎

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
import { faCopy, faDownload } from "@fortawesome/free-solid-svg-icons";
33
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
44
import { BButton, BCard, BCollapse, BNav, BNavItem, BSpinner } from "bootstrap-vue";
5-
import { onMounted, onUpdated, ref } from "vue";
5+
import { computed, onMounted, onUpdated, ref } from "vue";
66
77
import { getCitations } from "@/components/Citation/services";
88
import { useConfig } from "@/composables/config";
99
import { copy } from "@/utils/clipboard";
1010
1111
import type { Citation } from ".";
12+
import { Cite } from "./cite";
1213
1314
import CitationItem from "@/components/Citation/CitationItem.vue";
1415
import Heading from "@/components/Common/Heading.vue";
@@ -34,7 +35,7 @@ const { config } = useConfig(true);
3435
const emit = defineEmits(["rendered", "show", "shown", "hide", "hidden"]);
3536
3637
const outputFormat = ref<string>(outputFormats.CITATION);
37-
const citations = ref<Citation[]>([]);
38+
const fetchedCitations = ref<Citation[]>([]);
3839
const isLoading = ref<boolean>(false);
3940
4041
onUpdated(() => {
@@ -44,14 +45,32 @@ onUpdated(() => {
4445
onMounted(async () => {
4546
try {
4647
isLoading.value = true;
47-
citations.value = await getCitations(props.source, props.id);
48+
fetchedCitations.value = await getCitations(props.source, props.id);
4849
} catch (e) {
4950
console.error(e);
5051
} finally {
5152
isLoading.value = false;
5253
}
5354
});
5455
56+
/** The fetched Citations in addition to the Galaxy citation from config */
57+
const citations = computed<Citation[]>(() => {
58+
const allCitations = [...fetchedCitations.value];
59+
60+
if (!config.value?.citation_bibtex) {
61+
return allCitations;
62+
}
63+
64+
try {
65+
const cite = new Cite(config.value.citation_bibtex);
66+
const galaxyCitation = { raw: config.value.citation_bibtex, cite };
67+
return [galaxyCitation, ...allCitations];
68+
} catch (err) {
69+
console.warn("Error parsing Galaxy BibTeX citation:", config.value.citation_bibtex, err);
70+
return allCitations;
71+
}
72+
});
73+
5574
function copyBibtex() {
5675
const text = citationsToBibtexAsText();
5776
copy(text, "References copied to your clipboard as BibTeX");

‎client/src/components/Citation/services.ts‎

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import axios from "axios";
22

3-
import { useConfig } from "@/composables/config";
43
import { getAppRoot } from "@/onload/loadConfig";
54
import { rethrowSimple } from "@/utils/simple-error";
65

@@ -20,19 +19,7 @@ export async function getCitations(source: string, id: string): Promise<Citation
2019
console.warn(`Error parsing bibtex: ${err}`);
2120
}
2221
}
23-
// Inject Galaxy citation from config, using Cite for formatting
24-
const { config } = useConfig();
25-
let galaxyCitation = null;
26-
const galaxy_bibtex = config.value?.citation_bibtex;
27-
if (galaxy_bibtex) {
28-
try {
29-
const cite = new Cite(galaxy_bibtex);
30-
galaxyCitation = { raw: galaxy_bibtex, cite };
31-
} catch (err) {
32-
console.warn("Error parsing Galaxy BibTeX:", err);
33-
}
34-
}
35-
return galaxyCitation ? [galaxyCitation, ...citations] : citations;
22+
return citations;
3623
} catch (e) {
3724
rethrowSimple(e);
3825
}

0 commit comments

Comments
 (0)