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

Added component to display funding information to tool form and update tool footer view #16477

Open
wants to merge 34 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b6fbfdf
initial commit with viewers and tool footer and card implementation
hechth Jul 25, 2023
51032b8
Added Grant to schema and pulled out thing base class
hechth Jul 26, 2023
2419f0e
changed grant viewer to work as a computed
hechth Jul 26, 2023
2aee068
first attempt at implementing funding parsing
hechth Jul 26, 2023
afaea9d
fixed errors in schema definitions
hechth Jul 26, 2023
19da5d0
fixed linting
hechth Jul 27, 2023
1a61263
updated grant viewer component
hechth Jul 27, 2023
638bfbe
added test for funding for parser
hechth Jul 27, 2023
490c3b3
started implementing new details popup
hechth Jul 27, 2023
a835bc6
updated icons in creator and funding components
hechth Jul 28, 2023
ca0525f
fixed icon width
hechth Jul 28, 2023
224beb0
implemented backend unit test
hechth Jul 28, 2023
7f3285d
added creator and funding to xml order
hechth Jul 28, 2023
d3a2eac
set upper bound for creator and funding tag occurence to 1
hechth Jul 28, 2023
d3a86b4
include typo fix
hechth Jul 28, 2023
af75238
Merge branch 'dev' into grant_tool_tag
hechth Jul 28, 2023
92ded74
fixed closing brace error
hechth Jul 28, 2023
16893f9
Merge branch 'grant_tool_tag' of https://github.com/hechth/galaxy int…
hechth Jul 28, 2023
559eb69
formatting
hechth Jul 30, 2023
9dde26b
fixed wrong reference to complexType in schema
hechth Jul 30, 2023
bbbf003
format
hechth Jul 30, 2023
a9237ee
removed trailing whitespaces
hechth Jul 30, 2023
fcf5eba
fixed schema
hechth Jul 31, 2023
3c58616
try using element for schema
hechth Jul 31, 2023
30e9922
changed sponsor and funder to elements
hechth Jul 31, 2023
c7a8dba
removed sponsor and funder attributes
hechth Jul 31, 2023
2a24168
changed creator to be a thing
hechth Aug 2, 2023
120147a
added type hint to oarse_funding for xml
hechth Aug 2, 2023
b5d2d2a
implemented creator and funding parser for yaml with unit tests
hechth Aug 2, 2023
de82dd9
added type hints and formatted
hechth Aug 2, 2023
1959221
added yaml creator type hint
hechth Aug 2, 2023
5ac4a33
Removed unused import
hechth Aug 2, 2023
e728c5b
Fixed return types
hechth Aug 2, 2023
344f0b0
added citations
hechth Jul 30, 2024
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
27 changes: 27 additions & 0 deletions client/src/components/SchemaOrg/Funding.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<template>
<span>
{{ title }}
<div v-for="(grant, index) in funding" :key="index">
<GrantViewer :grant="grant" />
</div>
</span>
</template>

<script>
import GrantViewer from "./GrantViewer";

export default {
components: {
GrantViewer,
},
props: {
title: {
type: String,
default: "",
},
funding: {
type: Array,
},
},
};
</script>
73 changes: 73 additions & 0 deletions client/src/components/SchemaOrg/GrantViewer.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<script setup lang="ts">
import { library } from "@fortawesome/fontawesome-svg-core";
import { faCoins, faExternalLinkAlt } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { computed } from "vue";

const props = defineProps({
grant: {
type: Object,
required: true,
},
hoverPlacement: {
type: String,
default: "left",
},
});

library.add(faExternalLinkAlt, faCoins);

type item = {
attribute: string;
value: string;
};

const items = computed(() => {
const items: item[] = [];
for (const key in props.grant) {
if (key == "class") {
continue;
}
items.push({ attribute: key, value: props.grant[key] });
}
return items;
});

const implicitMicrodataProperties = ["name", "description", "url", "identifier"];

const explicitMetaAttributes = computed(() => {
return items.value.filter((i: item) => implicitMicrodataProperties.includes(i.attribute));
});
</script>

<template>
<span itemprop="funding" itemscope itemtype="https://schema.org/Grant">
<b-button
ref="button"
v-b-modal.funding-details
class="py-0 px-1"
size="sm"
variant="link"
title="Grant details">
<FontAwesomeIcon icon="coins" fixed-width />
</b-button>
<b-modal id="funding-details" title="Grant" hide-footer>
<b-table striped :items="items"> </b-table>
</b-modal>
<span v-if="props.grant.name">
{{ props.grant.name }}
</span>
<span v-if="props.grant.description"> - {{ props.grant.description }} </span>
<span v-if="props.grant.identifier"> ({{ props.grant.identifier }}) </span>
<a v-if="props.grant.url" v-b-tooltip.hover title="Grant URL" :href="props.grant.url" target="_blank">
<link itemprop="url" :href="props.grant.url" />
<FontAwesomeIcon icon="external-link-alt" />
</a>
<meta
v-for="attribute in explicitMetaAttributes"
:key="attribute.attribute"
:itemprop="attribute.attribute"
:content="attribute.value" />
<slot name="buttons"></slot>
</span>
</template>
18 changes: 11 additions & 7 deletions client/src/components/SchemaOrg/OrganizationViewer.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<template>
<span itemprop="creator" itemscope itemtype="https://schema.org/Organization">
<FontAwesomeIcon ref="button" icon="building" />
<b-popover
triggers="click blur"
:placement="hoverPlacement"
:target="$refs['button'] || 'works-lazily'"
title="Organization">
<b-button
ref="button"
v-b-modal.organization-details
class="py-0 px-1"
size="sm"
variant="link"
title="Organization details">
<FontAwesomeIcon icon="building" fixed-width />
</b-button>
<b-modal id="organization-details" title="Organization" hide-footer>
<b-table striped :items="items"> </b-table>
</b-popover>
</b-modal>
<span v-if="name">
<span itemprop="name">{{ name }}</span>
<span v-if="email">
Expand Down
18 changes: 11 additions & 7 deletions client/src/components/SchemaOrg/PersonViewer.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<template>
<span itemprop="creator" itemscope itemtype="https://schema.org/Person">
<FontAwesomeIcon ref="button" icon="user" />
<b-popover
triggers="click blur"
:placement="hoverPlacement"
:target="$refs['button'] || 'works-lazily'"
title="Person">
<b-button
ref="button"
v-b-modal.person-details
class="py-0 px-1"
size="sm"
variant="link"
title="Person details">
<FontAwesomeIcon icon="user" fixed-width />
</b-button>
<b-modal id="person-details" title="Person" hide-footer>
<b-table striped :items="items"> </b-table>
</b-popover>
</b-modal>
<span v-if="name">
<meta v-if="person.name" itemprop="name" :content="person.name" />
<meta v-if="person.givenName" itemprop="givenName" :content="person.givenName" />
Expand Down
1 change: 1 addition & 0 deletions client/src/components/Tool/ToolCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ function onUpdatePreferredObjectStoreId(selectedToolPreferredObjectStoreId) {
:xrefs="props.options.xrefs"
:license="props.options.license"
:creators="props.options.creator"
:funding="props.options.funding"
:requirements="props.options.requirements" />
</div>
</div>
Expand Down
23 changes: 21 additions & 2 deletions client/src/components/Tool/ToolFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
title="Learn more about Galaxy Requirements"
href="https://galaxyproject.org/tools/requirements/"
target="_blank">
See details <FontAwesomeIcon icon="external-link-alt" />
See details
<FontAwesomeIcon icon="external-link-alt" />
</a>
<div v-for="(requirement, index) in requirements" :key="index">
- {{ requirement.name }}
Expand Down Expand Up @@ -68,6 +69,10 @@
<span class="font-weight-bold">Creators:</span>
<Creators :creators="creators" />
</div>
<div v-if="hasFunding" class="mb-1">
<span class="font-weight-bold">Funding:</span>
<Funding :funding="funding" />
</div>
</b-card>
</template>

Expand All @@ -79,6 +84,7 @@ import Citation from "components/Citation/Citation";
import { getCitations } from "components/Citation/services";
import License from "components/License/License";
import Creators from "components/SchemaOrg/Creators";
import Funding from "components/SchemaOrg/Funding";
import { copy } from "utils/clipboard";

library.add(faQuestion, faCopy, faAngleDoubleDown, faAngleDoubleUp);
Expand All @@ -88,6 +94,7 @@ export default {
Citation,
License,
Creators,
Funding,
FontAwesomeIcon,
},
props: {
Expand All @@ -107,6 +114,9 @@ export default {
creators: {
type: Array,
},
funding: {
type: Array,
},
requirements: {
type: Array,
},
Expand All @@ -126,12 +136,20 @@ export default {
hasCreators() {
return this.creators && this.creators.length > 0;
},
hasFunding() {
return this.funding && this.funding.length > 0;
},
hasLicense() {
return !!this.license;
},
hasContent() {
return (
this.hasRequirements || this.hasReferences || this.hasCreators || this.hasCitations || this.hasLicense
this.hasRequirements ||
this.hasReferences ||
this.hasCreators ||
this.hasFunding ||
this.hasCitations ||
this.hasLicense
);
},
},
Expand Down Expand Up @@ -172,6 +190,7 @@ export default {
.footer-section-name {
font-weight: bold;
}

.footer-section-name::after {
content: ":";
}
Expand Down
14 changes: 11 additions & 3 deletions lib/galaxy/schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2068,9 +2068,9 @@ class SubworkflowStep(WorkflowStepBase):
)


class Creator(Model):
class_: str = Field(..., alias="class", title="Class", description="The class representing this creator.")
name: str = Field(..., title="Name", description="The name of the creator.")
class Thing(Model):
hechth marked this conversation as resolved.
Show resolved Hide resolved
class_: str = Field(..., alias="class", title="Class", description="The class representing this thing.")
name: str = Field(..., title="Name", description="The name of the thing.")
address: Optional[str] = Field(
None,
title="Address",
Expand Down Expand Up @@ -2104,6 +2104,10 @@ class Creator(Model):
)


class Creator(Thing):
class_: str = Field(..., alias="class", title="Class", description="The class representing this creator.")


class Organization(Creator):
class_: str = Field(
"Organization",
Expand Down Expand Up @@ -2144,6 +2148,10 @@ class Person(Creator):
)


class Grant(Thing):
class_: str = Field(..., alias="class", title="Class", description="The class representing this Grant.")


class StoredWorkflowDetailed(StoredWorkflowSummary):
annotation: Optional[str] = AnnotationField # Inconsistency? See comment on StoredWorkflowSummary.annotations
license: Optional[str] = Field(
Expand Down
4 changes: 4 additions & 0 deletions lib/galaxy/tool_util/linters/xml_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
"tests",
"help",
"citations",
"creator",
"funding",
]

DATASOURCE_TAG_ORDER = [
Expand All @@ -40,6 +42,8 @@
"options",
"help",
"citations",
"creator",
"funding",
]


Expand Down
7 changes: 7 additions & 0 deletions lib/galaxy/tool_util/parser/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,13 @@ def parse_creator(self):
"""
return []

def parse_funding(self):
hechth marked this conversation as resolved.
Show resolved Hide resolved
"""Return list of metadata relating to funding of tool development.

Result should be list of schema.org data model Grant objects.
"""
return []

@property
def macro_paths(self):
return []
Expand Down
22 changes: 21 additions & 1 deletion lib/galaxy/tool_util/parser/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import re
import uuid
from typing import (
Dict,
List,
Optional,
)
Expand Down Expand Up @@ -587,7 +588,7 @@ def parse_python_template_version(self):
def parse_creator(self):
creators_el = self.root.find("creator")
if creators_el is None:
return None
return []

creators = []
for creator_el in creators_el:
Expand All @@ -603,6 +604,25 @@ def parse_creator(self):
creators.append(creator_as_dict)
return creators

def parse_funding(self) -> List[Dict[str, str]]:
"""Parse the funding information from the XML tool file.

Returns:
funding: dict with array of grants holding the funding information
"""
funding_el = self.root.find("funding")
if funding_el is None:
return []

funding = []
for grant_el in funding_el:
grant_as_dict = {}
if grant_el.tag == "grant":
grant_as_dict["class"] = "Grant"
grant_as_dict.update(grant_el.attrib)
funding.append(grant_as_dict)
return funding


def _test_elem_to_dict(test_elem, i, profile=None) -> ToolSourceTest:
rval: ToolSourceTest = dict(
Expand Down
8 changes: 8 additions & 0 deletions lib/galaxy/tool_util/parser/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ def parse_xrefs(self):
xrefs = self.root_dict.get("xrefs", [])
return [dict(value=xref["value"], reftype=xref["type"]) for xref in xrefs if xref["type"]]

def parse_creator(self) -> List[Dict[str, Dict[str, str]]]:
creator = self.root_dict.get("creator")
return creator if creator else []

def parse_funding(self) -> List[Dict[str, Dict[str, str]]]:
funding = self.root_dict.get("funding")
return funding if funding else []

def parse_sanitize(self):
return self.root_dict.get("sanitize", True)

Expand Down
Loading