Skip to content

Commit

Permalink
add tags from toolform
Browse files Browse the repository at this point in the history
  • Loading branch information
PlushZ committed Dec 1, 2024
1 parent d6b92f2 commit 5bb0918
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 11 deletions.
154 changes: 147 additions & 7 deletions client/src/components/Tool/ToolForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,47 @@
@onClick="onExecute(config, currentHistoryId)" />
</template>
<template v-slot:buttons>
<ButtonSpinner
title="Run Tool"
class="mt-3 mb-3"
:disabled="!canMutateHistory"
:wait="showExecuting"
:tooltip="tooltip"
@onClick="onExecute(config, currentHistoryId)" />
<div class="tagging-section">
<div class="run-tool-container">
<ButtonSpinner
title="Run Tool"
class="mt-3 mb-3 run-tool-btn"
:disabled="!canMutateHistory"
:wait="showExecuting"
:tooltip="tooltip"
@onClick="onExecute(config, currentHistoryId)" />
<button
type="button"
class="mt-3 mb-3 run-tool-btn"
@click="toggleDropdown"
:title="'Add tags for output datasets'">

Check failure on line 113 in client/src/components/Tool/ToolForm.vue

View workflow job for this annotation

GitHub Actions / client-unit-test (18)

Attribute ":title" should go before "@click"
{{ isDropdownVisible ? "▲" : "▼" }}
</button>
</div>
<div
v-if="isDropdownVisible"
class="tags-container">
<div class="existing-tags">
<div class="tag-list">
<tag

Check failure on line 122 in client/src/components/Tool/ToolForm.vue

View workflow job for this annotation

GitHub Actions / client-unit-test (18)

Component name "tag" is not PascalCase
v-for="(tag, index) in tags"
:key="index"
:option="tag"
editable
@deleted="removeTag(index)"
/>
</div>
</div>
<div class="add-tag-section">
<input
v-model="newTag"
@keyup.enter="addTag"
placeholder="Add tag and press Enter"

Check failure on line 135 in client/src/components/Tool/ToolForm.vue

View workflow job for this annotation

GitHub Actions / client-unit-test (18)

Attribute "placeholder" should go before "@keyup.enter"
class="tag-input"

Check failure on line 136 in client/src/components/Tool/ToolForm.vue

View workflow job for this annotation

GitHub Actions / client-unit-test (18)

Attribute "class" should go before "@keyup.enter"
/>
</div>
</div>
</div>
</template>
</ToolCard>
</div>
Expand Down Expand Up @@ -133,6 +167,7 @@ import ToolCard from "./ToolCard";
import { allowCachedJobs } from "./utilities";
import FormSelect from "@/components/Form/Elements/FormSelect.vue";
import Tag from "@/components/TagsMultiselect/Tag.vue";
export default {
components: {
Expand All @@ -145,6 +180,7 @@ export default {
ToolEntryPoints,
ToolRecommendation,
Heading,
Tag,
},
props: {
id: {
Expand Down Expand Up @@ -204,6 +240,9 @@ export default {
],
immutableHistoryMessage:
"This history is immutable and you cannot run tools in it. Please switch to a different history.",
tags: [],
newTag: "",
isDropdownVisible: false,
};
},
computed: {
Expand Down Expand Up @@ -265,6 +304,9 @@ export default {
},
methods: {
...mapActions(useJobStore, ["saveLatestResponse"]),
toggleDropdown() {
this.isDropdownVisible = !this.isDropdownVisible;
},
emailAllowed(config, user) {
return config.server_mail_configured && !user.isAnonymous;
},
Expand Down Expand Up @@ -343,6 +385,7 @@ export default {
tool_version: this.formConfig.version,
inputs: {
...this.formData,
tags: this.tags,
},
};
if (this.useEmail) {
Expand Down Expand Up @@ -416,6 +459,103 @@ export default {
}
);
},
addTag() {
if (this.newTag.trim() && !this.tags.includes(this.newTag.trim())) {
this.tags.push(this.newTag.trim());
this.newTag = "";
}
},
removeTag(index) {
this.tags.splice(index, 1);
},
},
};
</script>
<style scoped>
.tagging-section {
margin-top: 1rem;
margin-bottom: 1rem;
position: relative;
}
.run-tool-container {
display: inline-flex;
align-items: center;
position: relative;
}
/*
.arrow-toggle-btn {
background: inherit;
color: inherit;
border: none;
cursor: pointer;
font-size: 1rem;
height: 100%;
padding: 0 0.5rem;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
border-radius: 4px;
}
.arrow-toggle-btn:hover {
background: #ddd;
}
.arrow-toggle-btn[title]:hover::after {
content: attr(title);
position: absolute;
bottom: 100%;
left: 50%;
transform: translateX(-50%);
background: #333;
color: #fff;
padding: 0.25rem 0.5rem;
border-radius: 4px;
font-size: 0.8rem;
white-space: nowrap;
z-index: 20;
}
*/
.tags-container {
position: absolute;
top: 100%;
left: 0;
margin-top: 0;
padding: 0.5rem;
background: #fff;
border: 1px solid #ddd;
border-radius: 4px;
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 0.5rem;
min-width: max-content;
max-width: 200px;
word-wrap: break-word;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
z-index: 10;
}
.tag-list {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
.tag-input {
padding: 0;
background: none;
border: none;
outline: none;
border-bottom: 1px solid #ccc;
width: 100%;
}
.tag-input::placeholder {
font-size: 0.9rem;
color: #888;
}
</style>
6 changes: 3 additions & 3 deletions lib/galaxy/model/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def apply_item_tag(
value=None,
flush=True,
):
self._ensure_user_owns_item(user, item)
#self._ensure_user_owns_item(user, item) TEMPORARY!!!
# Use lowercase name for searching/creating tag.
if name is None:
return
Expand Down Expand Up @@ -259,7 +259,7 @@ def apply_item_tags(
flush=True,
):
"""Apply tags to an item."""
self._ensure_user_owns_item(user, item)
#self._ensure_user_owns_item(user, item) # TEMPORARY!!!
# Parse tags.
parsed_tags = self.parse_tags(tags_str)
# Apply each tag.
Expand Down Expand Up @@ -532,4 +532,4 @@ def get_tag_by_name(self, tag_name):

class CommunityTagHandler(TagHandler):
def __init__(self, sa_session):
TagHandler.__init__(self, sa_session)
TagHandler.__init__(self, sa_session)
11 changes: 10 additions & 1 deletion lib/galaxy/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1833,6 +1833,9 @@ def expand_incoming(
]:
rerun_remap_job_id = _rerun_remap_job_id(request_context, incoming, self.id)
set_dataset_matcher_factory(request_context, self)
tags = incoming.get("tags", [])
if tags:
request_context.tags = tags

# Fixed set of input parameters may correspond to any number of jobs.
# Expand these out to individual parameters for given jobs (tool executions).
Expand Down Expand Up @@ -1981,6 +1984,12 @@ def handle_input(
collection_info=collection_info,
completed_jobs=completed_jobs,
)
tags = getattr(request_context, "tags", [])
if tags:
tag_handler = self.app.tag_handler
for output_name, hda in execution_tracker.output_datasets:
tag_handler.apply_item_tags(user=trans.user, item=hda, tags_str=",".join(tags))

# Raise an exception if there were jobs to execute and none of them were submitted,
# if at least one is submitted or there are no jobs to execute - return aggregate
# information including per-job errors. Arguably we should just always return the
Expand Down Expand Up @@ -4221,4 +4230,4 @@ def __init__(self, value):


class InterruptedUpload(Exception):
pass
pass

0 comments on commit 5bb0918

Please sign in to comment.