Skip to content

Commit

Permalink
Replaced with Workflow-Card component for design consistency with Wor…
Browse files Browse the repository at this point in the history
…kflows Landing Page (instead of design consistency with Workflows Annotation History Panel). Added 'show-actions' Boolean parameter to focus user on running the workflow as consistent with their intended behavior from the prior step; when 'show-actions' equals False, all actions are hidden (note: not same terminology as technical 'read-only' as 'show-actions' also prohibits Share/Favorite which are separate from being able to Edit a workflow).
  • Loading branch information
hujambo-dunia committed Sep 19, 2024
1 parent 0a97b12 commit c5bdd47
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 38 deletions.
10 changes: 6 additions & 4 deletions client/src/components/Workflow/List/WorkflowCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ interface Props {
workflow: any;
gridView?: boolean;
publishedView?: boolean;
showActions?: boolean;
}
const props = withDefaults(defineProps<Props>(), {
gridView: false,
publishedView: false,
showActions: true,
});
const emit = defineEmits<{
Expand Down Expand Up @@ -132,6 +134,7 @@ async function onTagClick(tag: string) {
<WorkflowInvocationsCount v-if="!isAnonymous && !shared" class="mx-1" :workflow="workflow" />

<WorkflowActions
v-if="showActions"
:workflow="workflow"
:published="publishedView"
@refreshList="emit('refreshList', true)"
Expand All @@ -155,7 +158,7 @@ async function onTagClick(tag: string) {
size="sm"
title="Rename"
@click="showRename = !showRename">
<FontAwesomeIcon :icon="faPen" fixed-width />
<FontAwesomeIcon v-if="showActions" :icon="faPen" fixed-width />
</BButton>
</span>

Expand All @@ -169,15 +172,14 @@ async function onTagClick(tag: string) {
<div class="workflow-card-footer">
<div class="workflow-card-tags">
<StatelessTags
clickable
:value="workflow.tags"
:disabled="isAnonymous || workflow.deleted || shared"
:disabled="!showActions || isAnonymous || workflow.deleted || shared"
:max-visible-tags="gridView ? 2 : 8"
@input="onTagsUpdate($event)"
@tag-click="onTagClick($event)" />
</div>

<div class="workflow-card-actions">
<div v-if="showActions" class="workflow-card-actions">
<WorkflowActionsExtend
:workflow="workflow"
:published="publishedView"
Expand Down
54 changes: 20 additions & 34 deletions client/src/components/Workflow/Run/WorkflowRunName.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<script setup lang="ts">
import { library } from "@fortawesome/fontawesome-svg-core";
import { faChevronDown, faChevronUp } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { BAlert } from "bootstrap-vue";
import { onMounted, ref } from "vue";
import { computed, ref } from "vue";
import { getWorkflowInfo } from "@/components/Workflow/workflows.services";
import WorkflowCard from "@/components/Workflow/List/WorkflowCard.vue";
import { errorMessageAsString } from "../../../utils/simple-error";
import WorkflowInformation from "@/components/Workflow/Published/WorkflowInformation.vue";
library.add(faChevronDown, faChevronUp);
const props = defineProps({
model: {
Expand All @@ -16,29 +15,18 @@ const props = defineProps({
},
});
const loading = ref(true);
const messageText = ref<string | null>(null);
const messageVariant = ref<string | null>(null);
const expandAnnotations = ref(true);
const workflowInfoData = ref(null);
onMounted(() => {
loadAnnotation();
const workflow = computed(() => {
return {
id: props.model.runData.id,
name: props.model.runData.name,
owner: props.model.runData.owner,
tags: props.model.runData.annotation.tags.map((t: { user_tname: string }) => t.user_tname),
annotations: [props.model.runData.annotation.annotation],
update_time: props.model.runData.annotation.update_time,
};
});
async function loadAnnotation() {
loading.value = true;
try {
const workflowInfoDataPromise = getWorkflowInfo(props.model.runData.id);
workflowInfoData.value = await workflowInfoDataPromise;
} catch (e) {
messageVariant.value = "danger";
messageText.value = errorMessageAsString(e, "Failed to fetch Workflow Annotation.");
} finally {
loading.value = false;
}
}
</script>

<template>
Expand All @@ -57,14 +45,12 @@ async function loadAnnotation() {
</span>
</div>
<div class="portlet-content" :style="expandAnnotations ? 'display: none;' : ''">
<WorkflowInformation
v-if="workflowInfoData"
class="workflow-information-container"
:workflow-info="workflowInfoData"
:embedded="false" />
<BAlert v-else :show="messageText" :variant="messageVariant">
{{ messageText }}
</BAlert>
<WorkflowCard
:workflow="workflow"
:published-view="true"
:grid-view="true"
:show-actions="false"
:class="'grid-view'" />
</div>
</div>
</template>
23 changes: 23 additions & 0 deletions lib/galaxy/managers/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,23 @@ def _workflow_from_raw_description(

return workflow, missing_tool_tups

def convert_to_dict_from_many(self, obj, depth=0, max_depth=5):
if depth > max_depth:
return "<max depth reached>"

if isinstance(obj, list):
return [self.convert_to_dict_from_many(item, depth=depth + 1, max_depth=max_depth) for item in obj]
elif isinstance(obj, dict) or hasattr(obj, "__dict__"):
if isinstance(obj, dict):
items = obj.items() # Dictionary case
else:
items = obj.__dict__.items() # Custom object case

return {key: self.convert_to_dict_from_many(value, depth=depth + 1, max_depth=max_depth)
for key, value in items if not key.startswith('_')}
else:
return obj

def workflow_to_dict(self, trans, stored, style="export", version=None, history=None):
"""Export the workflow contents to a dictionary ready for JSON-ification and to be
sent out via API for instance. There are three styles of export allowed 'export', 'instance', and
Expand Down Expand Up @@ -1059,13 +1076,19 @@ def _workflow_to_dict_run(self, trans, stored, workflow, history=None):
}
for oc in step.output_connections
]
annotations_dict = {
"annotation": stored.annotations[0].annotation,
"update_time": (stored.annotations[0].stored_workflow.update_time).isoformat(),
"tags": self.convert_to_dict_from_many(stored.annotations[0].stored_workflow.tags),
}
if step.annotations:
step_model["annotation"] = step.annotations[0].annotation
if step.upgrade_messages:
step_model["messages"] = step.upgrade_messages
step_models.append(step_model)
return {
"id": trans.app.security.encode_id(stored.id),
"annotation": annotations_dict,
"history_id": trans.app.security.encode_id(history.id) if history else None,
"name": stored.name,
"owner": stored.user.username,
Expand Down

0 comments on commit c5bdd47

Please sign in to comment.