Make export selection consistent between platforms and allow selecting which projects to export (#789)

* Experimenting with tests

* Overhaul handling of paths for pack files to always use standardized style

Also allows disabling export of all items

* Minor improvements

* Revert test things

* Minor tweaks

* Fix clippy warning
This commit is contained in:
Jackson Kruger
2023-10-09 12:34:19 -05:00
committed by GitHub
parent e76a7d57c0
commit 772597ce2a
10 changed files with 117 additions and 118 deletions

View File

@@ -3,7 +3,7 @@ use daedalus::modded::LoaderVersion;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use theseus::prelude::*;
use theseus::{prelude::*, InnerProjectPathUnix};
use uuid::Uuid;
pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
@@ -32,7 +32,7 @@ pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
profile_edit,
profile_edit_icon,
profile_export_mrpack,
profile_get_potential_override_folders,
profile_get_pack_export_candidates,
])
.build()
}
@@ -228,20 +228,13 @@ pub async fn profile_export_mrpack(
Ok(())
}
// Given a folder path, populate a Vec of all the subfolders
// Intended to be used for finding potential override folders
// profile
// -- folder1
// -- folder2
// -- file1
// => [folder1, folder2]
/// See [`profile::get_pack_export_candidates`]
#[tauri::command]
pub async fn profile_get_potential_override_folders(
pub async fn profile_get_pack_export_candidates(
profile_path: ProfilePathId,
) -> Result<Vec<PathBuf>> {
let overrides =
profile::get_potential_override_folders(profile_path).await?;
Ok(overrides)
) -> Result<Vec<InnerProjectPathUnix>> {
let candidates = profile::get_pack_export_candidates(&profile_path).await?;
Ok(candidates)
}
// Run minecraft using a profile using the default credentials

View File

@@ -2,10 +2,9 @@
import { Button, Checkbox, Modal, XIcon, PlusIcon } from 'omorphia'
import { PackageIcon, VersionIcon } from '@/assets/icons'
import { ref } from 'vue'
import { export_profile_mrpack, get_potential_override_folders } from '@/helpers/profile.js'
import { export_profile_mrpack, get_pack_export_candidates } from '@/helpers/profile.js'
import { open } from '@tauri-apps/api/dialog'
import { handleError } from '@/store/notifications.js'
import { sep } from '@tauri-apps/api/path'
import { useTheming } from '@/store/theme'
const props = defineProps({
@@ -34,8 +33,9 @@ const themeStore = useTheming()
const initFiles = async () => {
const newFolders = new Map()
const sep = '/';
files.value = []
await get_potential_override_folders(props.instance.path).then((filePaths) =>
await get_pack_export_candidates(props.instance.path).then((filePaths) =>
filePaths
.map((folder) => ({
path: folder,

View File

@@ -151,8 +151,8 @@ export async function export_profile_mrpack(
// -- file1
// => [mods, resourcepacks]
// allows selection for 'included_overrides' in export_profile_mrpack
export async function get_potential_override_folders(profilePath) {
return await invoke('plugin:profile|profile_get_potential_override_folders', { profilePath })
export async function get_pack_export_candidates(profilePath) {
return await invoke('plugin:profile|profile_get_pack_export_candidates', { profilePath })
}
// Run Minecraft using a pathed profile