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

Workflow anonymous user buttons #17537

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion client/src/components/Workflow/WorkflowActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { BButton } from "bootstrap-vue";
import { storeToRefs } from "pinia";
import { computed, type ComputedRef } from "vue";
import { useRouter } from "vue-router/composables";

Expand Down Expand Up @@ -67,6 +68,7 @@ const emit = defineEmits<{

const router = useRouter();
const userStore = useUserStore();
const { isAnonymous } = storeToRefs(userStore);
const { confirm } = useConfirmDialog();

const shared = computed(() => {
Expand Down Expand Up @@ -164,7 +166,7 @@ const actions: ComputedRef<(AAction | BAction)[]> = computed(() => {
const menuActions: ComputedRef<BAction[]> = computed(() => {
return [
{
condition: !shared.value && !props.workflow.deleted,
condition: !isAnonymous.value && !shared.value && !props.workflow.deleted,
class: "workflow-delete-button",
component: "button",
title: "Delete workflow",
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Workflow/WorkflowActionsExtend.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async function onRestore() {
</BButton>

<BButton
v-if="!shared && !workflow.deleted"
v-if="!isAnonymous && !shared && !workflow.deleted"
id="workflow-share-button"
v-b-tooltip.hover.noninteractive
:size="buttonSize"
Expand Down
54 changes: 43 additions & 11 deletions client/src/components/Workflow/WorkflowCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { library } from "@fortawesome/fontawesome-svg-core";
import { faEdit, faEye, faPen, faUpload } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { BButton } from "bootstrap-vue";
import { storeToRefs } from "pinia";
import { computed, ref } from "vue";
import { useRouter } from "vue-router/composables";

Expand Down Expand Up @@ -42,6 +43,8 @@ const emit = defineEmits<{
const router = useRouter();
const userStore = useUserStore();

const { isAnonymous } = storeToRefs(userStore);

const showRename = ref(false);
const showPreview = ref(false);

Expand All @@ -60,6 +63,35 @@ const description = computed(() => {
return null;
}
});
const editButtonTitle = computed(() => {
if (isAnonymous.value) {
return "Log in to edit Workflow";
} else {
if (workflow.value.deleted) {
return "You cannot edit a deleted workflow. Restore it first.";
} else {
return "Edit Workflow";
}
}
});
const importedButtonTitle = computed(() => {
if (isAnonymous.value) {
return "Log in to import workflow";
} else {
return "Import this workflow to edit";
}
});
const runButtonTitle = computed(() => {
if (isAnonymous.value) {
return "Log in to run workflow";
} else {
if (workflow.value.deleted) {
return "You cannot run a deleted workflow. Restore it first.";
} else {
return "Run workflow";
}
}
});

function onEdit() {
router.push(`/workflows/edit?id=${workflow.value.id}`);
Expand Down Expand Up @@ -119,7 +151,7 @@ async function onTagClick(tag: string) {
</div>

<div class="workflow-count-actions">
<WorkflowInvocationsCount class="mx-1" :workflow="workflow" />
<WorkflowInvocationsCount v-if="!isAnonymous && !shared" class="mx-1" :workflow="workflow" />

<WorkflowActions
:workflow="workflow"
Expand All @@ -141,7 +173,7 @@ async function onTagClick(tag: string) {
<StatelessTags
clickable
:value="workflow.tags"
:disabled="workflow.deleted"
:disabled="isAnonymous || workflow.deleted || shared"
:max-visible-tags="gridView ? 2 : 8"
@input="onTagsUpdate($event)"
@tag-click="onTagClick($event)" />
Expand All @@ -155,16 +187,12 @@ async function onTagClick(tag: string) {

<div class="workflow-edit-run-buttons">
<BButton
v-if="!shared"
v-if="!isAnonymous && !shared"
v-b-tooltip.hover.noninteractive
:disabled="workflow.deleted"
size="sm"
class="workflow-edit-button"
:title="
workflow.deleted
? 'You cannot edit a deleted workflow. Restore it first.'
: 'Edit workflow'
"
:title="editButtonTitle"
variant="outline-primary"
@click="onEdit">
<FontAwesomeIcon :icon="faEdit" fixed-width />
Expand All @@ -175,20 +203,24 @@ async function onTagClick(tag: string) {
v-else
v-b-tooltip.hover.noninteractive
size="sm"
title="Import this workflow to edit"
:disabled="isAnonymous"
:title="importedButtonTitle"
:icon="faUpload"
variant="outline-primary"
:action="onImport">
Import
</AsyncButton>

<WorkflowRunButton :id="workflow.id" />
<WorkflowRunButton
:id="workflow.id"
:disabled="isAnonymous || workflow.deleted"
:title="runButtonTitle" />
</div>
</div>
</div>

<WorkflowRename
v-if="!shared && !workflow.deleted"
v-if="!isAnonymous && !shared && !workflow.deleted"
:id="workflow.id"
:show="showRename"
:name="workflow.name"
Expand Down
5 changes: 4 additions & 1 deletion client/src/components/Workflow/WorkflowRunButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ library.add(faPlay);
interface Props {
id: string;
full?: boolean;
title?: string;
disabled?: boolean;
}

const props = defineProps<Props>();
Expand All @@ -25,10 +27,11 @@ function ExecuteWorkflow() {
<BButton
id="workflow-run-button"
v-b-tooltip.hover.top.noninteractive
title="Run workflow"
:title="title ?? 'Run workflow'"
:data-workflow-run="id"
variant="primary"
size="sm"
:disabled="disabled"
@click.stop="ExecuteWorkflow">
<FontAwesomeIcon :icon="faPlay" />
<span v-if="full" v-localize>Run</span>
Expand Down
Loading