-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Workflow license and creator edit keyboard access #18936
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
Merged
itisAliRH
merged 6 commits into
galaxyproject:dev
from
itisAliRH:workflow-license-creator-keyboard
Nov 18, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ba9b7c9
🛠️: migrate `LicenseSelector` to the composition API and typescript, …
itisAliRH 4608218
🛠️: make edit and cancel buttons in `CreatorEditor` accessible via ke…
itisAliRH 2afaf99
🛠️: replace unnecessary `onMounted` in `LicenseSelector` with an asyn…
itisAliRH d2ee04e
Redesign license selection using `vue-multiselect` for improved usabi…
itisAliRH 8bb73a3
Updates workflow editor license selection
itisAliRH 37b4fa4
Fix license loading logic and improve reactivity
itisAliRH File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,130 +1,112 @@ | ||
<script setup lang="ts"> | ||
import { watchImmediate } from "@vueuse/core"; | ||
import { BAlert } from "bootstrap-vue"; | ||
import { computed, ref } from "vue"; | ||
import Multiselect from "vue-multiselect"; | ||
|
||
import { GalaxyApi } from "@/api"; | ||
import { type components } from "@/api/schema"; | ||
import { errorMessageAsString } from "@/utils/simple-error"; | ||
|
||
import License from "@/components/License/License.vue"; | ||
import LoadingSpan from "@/components/LoadingSpan.vue"; | ||
|
||
const defaultLicense: LicenseType = { | ||
licenseId: null, | ||
name: "*Do not specify a license.*", | ||
}; | ||
|
||
type LicenseMetadataModel = components["schemas"]["LicenseMetadataModel"]; | ||
type LicenseType = { | ||
licenseId: string | null; | ||
name: string; | ||
}; | ||
|
||
interface Props { | ||
inputLicense: string; | ||
} | ||
|
||
const props = defineProps<Props>(); | ||
|
||
const emit = defineEmits<{ | ||
(e: "onLicense", license: string | null): void; | ||
}>(); | ||
|
||
const licensesLoading = ref(false); | ||
const errorMessage = ref<string>(""); | ||
const currentLicense = ref<LicenseType>(); | ||
const licenses = ref<LicenseMetadataModel[] | undefined>([]); | ||
|
||
const licenseOptions = computed(() => { | ||
const options: LicenseType[] = []; | ||
|
||
options.push(defaultLicense); | ||
|
||
for (const license of licenses.value || []) { | ||
if (license.licenseId == currentLicense.value?.licenseId || license.recommended) { | ||
options.push({ | ||
licenseId: license.licenseId, | ||
name: license.name, | ||
}); | ||
} | ||
} | ||
|
||
return options; | ||
}); | ||
|
||
function onLicense(license: LicenseType) { | ||
emit("onLicense", license.licenseId); | ||
} | ||
|
||
async function fetchLicenses() { | ||
const { error, data } = await GalaxyApi().GET("/api/licenses"); | ||
|
||
if (error) { | ||
errorMessage.value = errorMessageAsString(error) || "Unable to fetch licenses."; | ||
} | ||
|
||
licenses.value = data; | ||
|
||
licensesLoading.value = false; | ||
} | ||
|
||
async function setCurrentLicense() { | ||
if (!licenses.value?.length && !licensesLoading.value) { | ||
licensesLoading.value = true; | ||
|
||
await fetchLicenses(); | ||
} | ||
|
||
const inputLicense = props.inputLicense; | ||
|
||
currentLicense.value = (licenses.value || []).find((l) => l.licenseId == inputLicense) || defaultLicense; | ||
} | ||
|
||
watchImmediate( | ||
() => props.inputLicense, | ||
() => { | ||
setCurrentLicense(); | ||
} | ||
); | ||
</script> | ||
|
||
<template> | ||
<div v-if="editLicense"> | ||
<LoadingSpan v-if="licensesLoading" message="Loading licenses..." /> | ||
<b-form-select | ||
<div> | ||
<BAlert v-if="licensesLoading" variant="info" class="m-0" show> | ||
<LoadingSpan message="Loading licenses" /> | ||
</BAlert> | ||
<BAlert v-else-if="errorMessage" variant="danger" class="m-0" show> | ||
{{ errorMessage }} | ||
</BAlert> | ||
<Multiselect | ||
v-else | ||
v-model="license" | ||
v-model="currentLicense" | ||
data-description="license select" | ||
:options="licenseOptions"></b-form-select> | ||
<License v-if="currentLicenseInfo" :license-id="license" :input-license-info="currentLicenseInfo"> | ||
<template v-slot:buttons> | ||
<span v-b-tooltip.hover title="Save License" | ||
><FontAwesomeIcon data-description="license save" icon="save" @click="onSave" | ||
/></span> | ||
<span v-b-tooltip.hover title="Cancel Edit"><FontAwesomeIcon icon="times" @click="disableEdit" /></span> | ||
</template> | ||
</License> | ||
<div v-else> | ||
<a href="#" @click.prevent="onSave">Save without license</a> or | ||
<a href="#" @click.prevent="editLicense = false">cancel edit.</a> | ||
</div> | ||
</div> | ||
<div v-else-if="license" data-description="license selector" :data-license="license"> | ||
<License :license-id="license"> | ||
<template v-slot:buttons> | ||
<span v-b-tooltip.hover title="Edit License" | ||
><FontAwesomeIcon icon="edit" data-description="edit license link" @click="editLicense = true" | ||
/></span> | ||
</template> | ||
</License> | ||
</div> | ||
<div v-else data-description="license selector" data-license="null"> | ||
<i | ||
><a href="#" data-description="edit license link" @click.prevent="editLicense = true" | ||
>Specify a license for this workflow.</a | ||
></i | ||
> | ||
track-by="licenseId" | ||
:options="licenseOptions" | ||
label="name" | ||
placeholder="Select a license" | ||
@select="onLicense" /> | ||
<License v-if="currentLicense?.licenseId" :license-id="currentLicense.licenseId" /> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { library } from "@fortawesome/fontawesome-svg-core"; | ||
import { faEdit, faSave, faTimes } from "@fortawesome/free-solid-svg-icons"; | ||
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; | ||
import axios from "axios"; | ||
import BootstrapVue from "bootstrap-vue"; | ||
import LoadingSpan from "components/LoadingSpan"; | ||
import { getAppRoot } from "onload/loadConfig"; | ||
import Vue from "vue"; | ||
|
||
import License from "./License"; | ||
|
||
library.add(faSave); | ||
library.add(faTimes); | ||
library.add(faEdit); | ||
|
||
Vue.use(BootstrapVue); | ||
|
||
export default { | ||
components: { License, LoadingSpan, FontAwesomeIcon }, | ||
props: { | ||
inputLicense: { | ||
type: String, | ||
}, | ||
}, | ||
data() { | ||
return { | ||
license: this.inputLicense || null, | ||
licensesLoading: false, | ||
licenses: [], | ||
editLicense: false, | ||
}; | ||
}, | ||
computed: { | ||
currentLicenseInfo() { | ||
for (const license of this.licenses) { | ||
if (license.licenseId == this.license) { | ||
return license; | ||
} | ||
} | ||
return null; | ||
}, | ||
licenseOptions() { | ||
const options = []; | ||
options.push({ | ||
value: null, | ||
text: "*Do not specify a license.*", | ||
}); | ||
for (const license of this.licenses) { | ||
if (license.licenseId == this.license || license.recommended) { | ||
options.push({ | ||
value: license.licenseId, | ||
text: license.name, | ||
}); | ||
} | ||
} | ||
return options; | ||
}, | ||
}, | ||
watch: { | ||
inputLicense() { | ||
this.license = this.inputLicense; | ||
}, | ||
}, | ||
mounted() { | ||
const url = `${getAppRoot()}api/licenses`; | ||
axios | ||
.get(url) | ||
.then((response) => response.data) | ||
.then((data) => { | ||
this.licenses = data; | ||
this.licensesLoading = false; | ||
}) | ||
.catch((e) => { | ||
console.error(e); | ||
}); | ||
}, | ||
methods: { | ||
onSave() { | ||
this.onLicense(this.license); | ||
this.disableEdit(); | ||
}, | ||
disableEdit() { | ||
this.editLicense = false; | ||
}, | ||
onLicense(license) { | ||
this.$emit("onLicense", license); | ||
}, | ||
}, | ||
}; | ||
</script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we put this in a store, so it doesn't reload on re-rendering this component?