diff --git a/src/lib/components/icons/ArrowUpCircle.svelte b/src/lib/components/icons/ArrowUpCircle.svelte new file mode 100644 index 000000000..caa5f219b --- /dev/null +++ b/src/lib/components/icons/ArrowUpCircle.svelte @@ -0,0 +1,19 @@ + + + diff --git a/src/lib/components/workspace/Models.svelte b/src/lib/components/workspace/Models.svelte index d7a922c91..ce70fbe50 100644 --- a/src/lib/components/workspace/Models.svelte +++ b/src/lib/components/workspace/Models.svelte @@ -94,6 +94,35 @@ window.addEventListener('message', messageHandler, false); }; + const moveToTopHandler = async (model) => { + let info = model.info; + + if (!info) { + info = { + id: model.id, + name: model.name, + meta: { + position: 0 + }, + params: {} + }; + } + + info.meta = { + ...info.meta, + position: 0 + }; + + const res = await updateModelById(localStorage.token, info.id, info); + + if (res) { + toast.success($i18n.t(`Model {{name}} is now at the top`, { name: info.id })); + } + + await models.set(await getModels(localStorage.token)); + _models = $models; + }; + const hideModelHandler = async (model) => { let info = model.info; @@ -440,6 +469,9 @@ exportHandler={() => { exportModelHandler(model); }} + moveToTopHandler={() => { + moveToTopHandler(model); + }} hideHandler={() => { hideModelHandler(model); }} diff --git a/src/lib/components/workspace/Models/ModelMenu.svelte b/src/lib/components/workspace/Models/ModelMenu.svelte index f3a21d510..49cefec1a 100644 --- a/src/lib/components/workspace/Models/ModelMenu.svelte +++ b/src/lib/components/workspace/Models/ModelMenu.svelte @@ -12,6 +12,7 @@ import ArchiveBox from '$lib/components/icons/ArchiveBox.svelte'; import DocumentDuplicate from '$lib/components/icons/DocumentDuplicate.svelte'; import ArrowDownTray from '$lib/components/icons/ArrowDownTray.svelte'; + import ArrowUpCircle from '$lib/components/icons/ArrowUpCircle.svelte'; const i18n = getContext('i18n'); @@ -21,6 +22,7 @@ export let cloneHandler: Function; export let exportHandler: Function; + export let moveToTopHandler: Function; export let hideHandler: Function; export let deleteHandler: Function; export let onClose: Function; @@ -80,6 +82,17 @@