Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometrically committed Jul 20, 2024
2 parents 11f1793 + f171364 commit facd20f
Show file tree
Hide file tree
Showing 16 changed files with 144 additions and 205 deletions.
1 change: 0 additions & 1 deletion apps/app-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"floating-vue": "^5.2.2",
"mixpanel-browser": "^2.49.0",
"ofetch": "^1.3.4",
"omorphia": "^0.4.41",
"pinia": "^2.1.7",
"tauri-plugin-window-state-api": "github:tauri-apps/tauri-plugin-window-state#v1",
"vite-svg-loader": "^5.1.0",
Expand Down
2 changes: 1 addition & 1 deletion apps/app-frontend/src/components/GridDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ const filteredResults = computed(() => {
<div class="iconified-input">
<SearchIcon />
<input v-model="search" type="text" placeholder="Search" class="search-input" />
<Button @click="() => (search = '')">
<Button class="r-btn" @click="() => (search = '')">
<XIcon />
</Button>
</div>
Expand Down
63 changes: 63 additions & 0 deletions apps/app-frontend/src/components/ui/AddContentButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<script setup lang="ts">
import { DropdownIcon, FolderOpenIcon, SearchIcon } from '@modrinth/assets'
import { Button, OverflowMenu } from '@modrinth/ui'
import { open } from '@tauri-apps/api/dialog'
import { add_project_from_path } from '@/helpers/profile.js'
import { handleError } from '@/store/notifications.js'
import { useRouter } from 'vue-router'
const props = defineProps({
instance: {
type: Object,
required: true,
},
})
const router = useRouter()
const handleAddContentFromFile = async () => {
const newProject = await open({ multiple: true })
if (!newProject) return
for (const project of newProject) {
await add_project_from_path(props.instance.path, project).catch(handleError)
}
}
const handleSearchContent = async () => {
await router.push({
path: `/browse/${props.instance.loader === 'vanilla' ? 'datapack' : 'mod'}`,
query: { i: props.instance.path },
})
}
</script>

<template>
<div class="joined-buttons">
<Button color="primary" @click="handleSearchContent"><SearchIcon /> Add content </Button>

<OverflowMenu
:options="[
{
id: 'search',
action: () => handleSearchContent,
},
{
id: 'from_file',
action: () => handleAddContentFromFile,
},
]"
class="btn btn-primary btn-dropdown-animation icon-only"
>
<DropdownIcon />
<template #search>
<SearchIcon />
<span class="no-wrap"> Search </span>
</template>
<template #from_file>
<FolderOpenIcon />
<span class="no-wrap"> Add from file </span>
</template>
</OverflowMenu>
</div>
</template>
4 changes: 2 additions & 2 deletions apps/app-frontend/src/components/ui/ExportModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const exportPack = async () => {
<div class="iconified-input">
<PackageIcon />
<input v-model="nameInput" type="text" placeholder="Modpack name" class="input" />
<Button @click="nameInput = ''">
<Button class="r-btn" @click="nameInput = ''">
<XIcon />
</Button>
</div>
Expand All @@ -123,7 +123,7 @@ const exportPack = async () => {
<div class="iconified-input">
<VersionIcon />
<input v-model="versionInput" type="text" placeholder="1.0.0" class="input" />
<Button @click="versionInput = ''">
<Button class="r-btn" @click="versionInput = ''">
<XIcon />
</Button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
placeholder="Path to launcher"
@change="setPath"
/>
<Button @click="() => (selectedLauncherPath = '')">
<Button class="r-btn" @click="() => (selectedLauncherPath = '')">
<XIcon />
</Button>
</div>
Expand Down
6 changes: 5 additions & 1 deletion apps/app-frontend/src/components/ui/RunningAppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,12 @@ onBeforeUnmount(() => {
width: 1.25rem !important;
height: 1.25rem !important;
svg {
min-width: 1.25rem;
}
&.stop {
--text-color: var(--color-red) !important;
color: var(--color-red);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ const createInstance = async () => {
<div class="profiles" :class="{ 'hide-creation': !showCreation }">
<div v-for="profile in shownProfiles" :key="profile.name" class="option">
<Button
color="raised"
transparent
class="profile-button"
@click="$router.push(`/instance/${encodeURIComponent(profile.path)}`)"
>
Expand Down
2 changes: 1 addition & 1 deletion apps/app-frontend/src/pages/Browse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ const showLoaders = computed(
:placeholder="`Search ${projectType}s...`"
@input="onSearchChange(1)"
/>
<Button @click="() => clearSearch()">
<Button class="r-btn" @click="() => clearSearch()">
<XIcon />
</Button>
</div>
Expand Down
12 changes: 4 additions & 8 deletions apps/app-frontend/src/pages/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@ const accessSettings = async () => {
const fetchSettings = await accessSettings().catch(handleError)
const settings = ref(fetchSettings)
console.log(fetchSettings)
// const settingsDir = ref(settings.value.loaded_config_dir)
// const maxMemory = ref(Math.floor((await get_max_memory().catch(handleError)) / 1024))
const maxMemory = ref(100000)
const maxMemory = ref(Math.floor((await get_max_memory().catch(handleError)) / 1024))
watch(
settings,
async (oldSettings, newSettings) => {
console.log('hellooo')
if (oldSettings.loaded_config_dir !== newSettings.loaded_config_dir) {
return
}
Expand Down Expand Up @@ -85,17 +84,14 @@ watch(
{ deep: true },
)
console.log('hellooo')
const credentials = ref(await getCreds().catch(handleError))
const loginScreenModal = ref()
console.log('hellooo')
async function logOut() {
await logout().catch(handleError)
credentials.value = await getCreds().catch(handleError)
}
console.log('hellooo')
async function signInAfter() {
loginScreenModal.value.hide()
credentials.value = await getCreds().catch(handleError)
Expand Down Expand Up @@ -170,7 +166,7 @@ async function signInAfter() {
<!-- <div class="iconified-input">-->
<!-- <BoxIcon />-->
<!-- <input id="appDir" v-model="settingsDir" type="text" class="input" />-->
<!-- <Button @click="findLauncherDir">-->
<!-- <Button class="r-btn" @click="findLauncherDir">-->
<!-- <FolderSearchIcon />-->
<!-- </Button>-->
<!-- </div>-->
Expand Down
83 changes: 20 additions & 63 deletions apps/app-frontend/src/pages/instance/Mods.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
class="text-input"
autocomplete="off"
/>
<Button @click="() => (searchFilter = '')">
<Button class="r-btn" @click="() => (searchFilter = '')">
<XIcon />
</Button>
</div>
Expand All @@ -42,24 +42,7 @@
<UpdatedIcon />
Update all
</Button>

<!-- <DropdownButton-->
<!-- v-if="!isPackLocked"-->
<!-- :options="['search', 'from_file']"-->
<!-- default-value="search"-->
<!-- name="add-content-dropdown"-->
<!-- color="primary"-->
<!-- @option-click="handleContentOptionClick"-->
<!-- >-->
<!-- <template #search>-->
<!-- <SearchIcon />-->
<!-- <span class="no-wrap"> Add content </span>-->
<!-- </template>-->
<!-- <template #from_file>-->
<!-- <FolderOpenIcon />-->
<!-- <span class="no-wrap"> Add from file </span>-->
<!-- </template>-->
<!-- </DropdownButton>-->
<AddContentButton v-if="!isPackLocked" :instance="instance" />
</Card>
<Pagination
v-if="projects.length > 0"
Expand Down Expand Up @@ -241,7 +224,7 @@
<TrashIcon />
</Button>
</div>
<AnimatedLogo v-if="mod.updating" class="btn icon-only updating-indicator"></AnimatedLogo>
<AnimatedLogo v-if="mod.updating" class="btn icon-only updating-indicator" />
<div
v-else
v-tooltip="isPackLocked ? 'Unlock this instance to update mods.' : 'Update project'"
Expand Down Expand Up @@ -283,24 +266,7 @@
</div>
<h3>No projects found</h3>
<p class="empty-subtitle">Add a project to get started</p>
<div class="empty-action">
<DropdownButton
:options="['search', 'from_file']"
default-value="search"
name="add-content-dropdown-from-empty"
color="primary"
@option-click="handleContentOptionClick"
>
<template #search>
<SearchIcon />
<span class="no-wrap"> Add content </span>
</template>
<template #from_file>
<FolderOpenIcon />
<span class="no-wrap"> Add from file </span>
</template>
</DropdownButton>
</div>
<AddContentButton :instance="instance" />
</div>
<Pagination
v-if="projects.length > 0"
Expand Down Expand Up @@ -372,7 +338,6 @@ import {
SearchIcon,
UpdatedIcon,
FolderOpenIcon,
// DropdownButton,
XIcon,
ShareIcon,
DropdownIcon,
Expand All @@ -395,7 +360,6 @@ import {
} from '@modrinth/ui'
import { formatProjectType } from '@modrinth/utils'
import { computed, onUnmounted, ref, watch } from 'vue'
import { useRouter } from 'vue-router'
import {
add_project_from_path,
get,
Expand All @@ -407,12 +371,12 @@ import {
} from '@/helpers/profile.js'
import { handleError } from '@/store/notifications.js'
import { mixpanel_track } from '@/helpers/mixpanel'
import { open } from '@tauri-apps/api/dialog'
import { listen } from '@tauri-apps/api/event'
import { highlightModInProfile } from '@/helpers/utils.js'
import { MenuIcon, ToggleIcon, TextInputIcon, AddProjectImage, PackageIcon } from '@/assets/icons'
import ExportModal from '@/components/ui/ExportModal.vue'
import ModpackVersionModal from '@/components/ui/ModpackVersionModal.vue'
import AddContentButton from '@/components/ui/AddContentButton.vue'
import {
get_organization_many,
get_project_many,
Expand All @@ -421,8 +385,6 @@ import {
} from '@/helpers/cache.js'
import { profile_listener } from '@/helpers/events.js'
const router = useRouter()
const props = defineProps({
instance: {
type: Object,
Expand Down Expand Up @@ -875,23 +837,6 @@ const handleRightClick = (event, mod) => {
}
}
const handleContentOptionClick = async (args) => {
if (args.option === 'search') {
await router.push({
path: `/browse/${props.instance.loader === 'vanilla' ? 'datapack' : 'mod'}`,
query: { i: props.instance.path },
})
} else if (args.option === 'from_file') {
const newProject = await open({ multiple: true })
if (!newProject) return
for (const project of newProject) {
await add_project_from_path(props.instance.path, project, 'mod').catch(handleError)
}
initProjects(await get(props.instance.path).catch(handleError))
}
}
watch(selectAll, () => {
for (const [key, value] of Array.from(selectionMap.value)) {
if (value !== selectAll.value) {
Expand All @@ -903,7 +848,7 @@ watch(selectAll, () => {
const unlisten = await listen('tauri://file-drop', async (event) => {
for (const file of event.payload) {
if (file.endsWith('.mrpack')) continue
await add_project_from_path(props.instance.path, file, 'mod').catch(handleError)
await add_project_from_path(props.instance.path, file).catch(handleError)
}
initProjects(await get(props.instance.path).catch(handleError))
})
Expand Down Expand Up @@ -996,13 +941,21 @@ onUnmounted(() => {
}
}
.btn {
:deep(.btn) {
height: 2.5rem;
}
.dropdown-input {
flex-grow: 1;
.animated-dropdown {
width: unset;
:deep(.selected) {
border-radius: var(--radius-md) 0 0 var(--radius-md);
}
}
.iconified-input {
width: 100%;
Expand Down Expand Up @@ -1188,8 +1141,12 @@ onUnmounted(() => {
</style>
<style lang="scss">
.updating-indicator {
height: 2.25rem !important;
width: 2.25rem !important;
svg {
margin-left: 0.5rem !important;
height: 1.25rem !important;
width: 1.25rem !important;
}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/app/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
}
},
"security": {
"csp": "default-src 'self'; connect-src https://modrinth.com https://*.modrinth.com https://mixpanel.com https://*.mixpanel.com https://*.cloudflare.com https://api.mclo.gs; font-src https://cdn-raw.modrinth.com/fonts/inter/; img-src tauri: https: data: blob: 'unsafe-inline' asset: https://asset.localhost; script-src https://*.cloudflare.com 'self'; frame-src https://*.cloudflare.com https://www.youtube.com https://www.youtube-nocookie.com https://discord.com 'self'; style-src unsafe-inline 'self'"
"csp": "default-src 'self'; connect-src https://modrinth.com https://*.modrinth.com https://mixpanel.com https://*.mixpanel.com https://*.cloudflare.com https://api.mclo.gs; font-src https://cdn-raw.modrinth.com/fonts/inter/; img-src tauri: https: data: blob: 'unsafe-inline' asset: https://asset.localhost; script-src https://*.cloudflare.com 'self'; frame-src https://*.cloudflare.com https://www.youtube.com https://www.youtube-nocookie.com https://discord.com 'self'; style-src 'unsafe-inline' 'self'"
},
"updater": {
"active": false
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
"version": "0.0.0",
"private": true,
"scripts": {
"web:build": "turbo run build --filter=@modrinth/frontend",
"pages:build": "NITRO_PRESET=cloudflare-pages pnpm --filter frontend run build",
"web:dev": "turbo run dev --filter=@modrinth/frontend",
"web:build": "turbo run build --filter=@modrinth/frontend",
"app:dev": "turbo run dev --filter=@modrinth/app",
"app:build": "turbo run build --filter=@modrinth/app",
"pages:build": "NITRO_PRESET=cloudflare-pages pnpm --filter frontend run build",
"build": "turbo run build --continue",
"lint": "turbo run lint --continue",
"test": "turbo run test --continue"
Expand Down
Loading

0 comments on commit facd20f

Please sign in to comment.