Search fixes (#134)

* Search fixes

* Fix small instance ui

* fix javaw issue

* menu fix

* Add confirm modal for deletion

* fix build
This commit is contained in:
Geometrically
2023-06-11 15:26:25 -07:00
committed by GitHub
parent e836738887
commit 3535f0c4b4
24 changed files with 796 additions and 576 deletions

View File

@@ -126,22 +126,22 @@ import { process_listener, profile_listener } from '@/helpers/events'
import { useRoute, useRouter } from 'vue-router'
import { ref, onUnmounted } from 'vue'
import { convertFileSrc } from '@tauri-apps/api/tauri'
import { handleError, useBreadcrumbs, useLoading, useSearch } from '@/store/state'
import { handleError, useBreadcrumbs, useLoading } from '@/store/state'
import { showInFolder } from '@/helpers/utils.js'
import ContextMenu from '@/components/ui/ContextMenu.vue'
const route = useRoute()
const router = useRouter()
const searchStore = useSearch()
const breadcrumbs = useBreadcrumbs()
const instance = ref(await get(route.params.id).catch(handleError))
searchStore.instanceContext = instance.value
breadcrumbs.setName('Instance', instance.value.metadata.name)
breadcrumbs.setContext({
name: instance.value.metadata.name,
link: route.path,
query: route.query,
})
const loadingBar = useLoading()
@@ -183,7 +183,6 @@ const stopInstance = async () => {
const unlistenProfiles = await profile_listener(async (event) => {
if (event.path === route.params.id) {
instance.value = await get(route.params.id).catch(handleError)
searchStore.instanceContext = instance.value
}
})
@@ -242,6 +241,7 @@ const handleOptionsClick = async (args) => {
case 'add_content':
await router.push({
path: `/browse/${instance.value.metadata.loader === 'vanilla' ? 'datapack' : 'mod'}`,
query: { i: route.params.id },
})
break
case 'edit':

View File

@@ -2,12 +2,12 @@
<Card class="log-card">
<div class="button-row">
<DropdownSelect
v-model="selectedLogIndex"
:default-value="0"
name="Log date"
:model-value="logs[selectedLogIndex]"
:options="logs"
:display-name="(option) => option?.name"
:options="logs.map((_, index) => index)"
:display-name="(option) => logs[option]?.name"
:disabled="logs.length === 0"
@change="(value) => (selectedLogIndex = value.index)"
/>
<div class="button-group">
<Button :disabled="!logs[selectedLogIndex]" @click="copyLog()">
@@ -30,7 +30,11 @@
</div>
</div>
<div ref="logContainer" class="log-text">
<span v-for="line in logs[selectedLogIndex]?.stdout.split('\n')" :key="line" class="no-wrap">
<span
v-for="(line, index) in logs[selectedLogIndex]?.stdout.split('\n')"
:key="index"
class="no-wrap"
>
{{ line }} <br />
</span>
</div>
@@ -68,15 +72,18 @@ const props = defineProps({
})
async function getLiveLog() {
const uuids = await get_uuids_by_profile_path(route.params.id).catch(handleError)
let returnValue
if (uuids.length === 0) {
returnValue = 'No live game detected. \nStart your game to proceed'
} else {
returnValue = await get_stdout_by_uuid(uuids[0]).catch(handleError)
}
if (route.params.id) {
const uuids = await get_uuids_by_profile_path(route.params.id).catch(handleError)
let returnValue
if (uuids.length === 0) {
returnValue = 'No live game detected. \nStart your game to proceed'
} else {
returnValue = await get_stdout_by_uuid(uuids[0]).catch(handleError)
}
return { name: 'Live Log', stdout: returnValue, live: true }
return { name: 'Live Log', stdout: returnValue, live: true }
}
return null
}
async function getLogs() {

View File

@@ -30,6 +30,7 @@
@click="
router.push({
path: `/browse/${props.instance.metadata.loader === 'vanilla' ? 'datapack' : 'mod'}`,
query: { i: $route.params.id },
})
"
>
@@ -80,7 +81,11 @@
</Button>
</div>
<div class="table-cell table-text name-cell">
<router-link v-if="mod.slug" :to="`/project/${mod.slug}/`" class="mod-text">
<router-link
v-if="mod.slug"
:to="{ path: `/project/${mod.slug}/`, query: { i: props.instance.path } }"
class="mod-text"
>
<Avatar :src="mod.icon" />
{{ mod.name }}
</router-link>
@@ -305,7 +310,6 @@ async function updateProject(mod) {
async function toggleDisableMod(mod) {
mod.path = await toggle_disable_project(props.instance.path, mod.path).catch(handleError)
console.log(mod.disabled)
mod.disabled = !mod.disabled
}

View File

@@ -1,4 +1,12 @@
<template>
<ModalConfirm
ref="modal_confirm"
title="Are you sure you want to delete this instance?"
description="If you proceed, all data for your instance will be removed. You will not be able to recover it."
:has-to-type="false"
proceed-label="Delete"
@proceed="removeProfile"
/>
<Modal ref="changeVersionsModal" header="Change instance versions">
<div class="change-versions-modal universal-body">
<div class="input-row">
@@ -105,8 +113,8 @@
placeholder="Select categories..."
@tag="
(newTag) => {
groups.push(newTag)
availableGroups.push(newTag)
groups.push(newTag.trim().substring(0, 32))
availableGroups.push(newTag.trim().substring(0, 32))
}
"
/>
@@ -288,7 +296,7 @@
id="delete-profile"
class="btn btn-danger"
:disabled="removing"
@click="removeProfile"
@click="$refs.modal_confirm.show()"
>
<TrashIcon /> Delete
</button>
@@ -311,6 +319,7 @@ import {
XIcon,
SaveIcon,
HammerIcon,
ModalConfirm,
} from 'omorphia'
import { Multiselect } from 'vue-multiselect'
import { useRouter } from 'vue-router'
@@ -398,7 +407,8 @@ const hooks = ref(props.instance.hooks ?? globalSettings.hooks)
watch(
[
title,
groups.value,
groups,
groups,
overrideJavaInstall,
javaInstall,
overrideJavaArgs,
@@ -406,17 +416,17 @@ watch(
overrideEnvVars,
envVars,
overrideMemorySettings,
memory.value,
memory,
overrideWindowSettings,
resolution.value,
resolution,
overrideHooks,
hooks.value,
hooks,
],
async () => {
const editProfile = {
metadata: {
name: title.value,
groups: groups.value,
name: title.value.trim().substring(0, 16) ?? 'Instance',
groups: groups.value.map((x) => x.trim().substring(0, 32)).filter((x) => x.length > 0),
},
java: {},
}
@@ -424,6 +434,10 @@ watch(
if (overrideJavaInstall.value) {
if (javaInstall.value.path !== '') {
editProfile.java.override_version = javaInstall.value
editProfile.java.override_version.path = editProfile.java.override_version.path.replace(
'java.exe',
'javaw.exe'
)
}
}
@@ -456,7 +470,8 @@ watch(
}
await edit(props.instance.path, editProfile)
}
},
{ deep: true }
)
const repairing = ref(false)