refactor: align files tab with content tab design (#5621)
* fix: files.vue bugs before styling changes * feat: move files tab to shared layout structure * fix: qa * fix: qa * fix: bugs * fix: lint * fix: admonition cleanup with progress + actions * fix: cleanup * fix: modals * fix: admon title * fix: i18n standard * fix: lint + i18n pass * fix: remove transition * fix: type errors * feat: files tab in app * fix: qa * fix: backup item minmax * fix: use ContentPageHeader for server panel * fix: lint * fix: lint * fix: lint * feat: page leave safety * fix: lint * fix: cargo fmt fix * fix: blank in prod * fix: content card table stuff * Revert "fix: blank in prod" This reverts commit 74758fe185cf85a4a20355857f889cb091b97ace. * fix: import * feat: browse worlds/servers flow * fix: worlds tab parity with content tab * fix: perf bug + shader filter pill copy * feat: singleplayer filter * fix: ordering * fix: breadcrumbs * fix: lint * fix: qa * feat: store server proj id when adding to a non-linked instance * fix: lint * fix: i18n + qa * fix: conflict * qa: already installed modal + placeholders not server-specific * fix: qa * fix: add + edit server modals * fix: qa * fix: security * fix: devin flags * fix: lint * chore: change file to break build cache * fix: admon * fix: import path stuff * feat: qa * fix: fmt fmt idiot --------- Signed-off-by: Calum H. <calum@modrinth.com>
This commit is contained in:
@@ -68,10 +68,23 @@ pub async fn get_importable_instances(
|
||||
.await
|
||||
.unwrap_or_else(|| "instances".to_string()),
|
||||
ImportLauncherType::Unknown => {
|
||||
return Err(crate::ErrorKind::InputError(
|
||||
"Launcher type Unknown".to_string(),
|
||||
)
|
||||
.into());
|
||||
let types = [
|
||||
ImportLauncherType::MultiMC,
|
||||
ImportLauncherType::PrismLauncher,
|
||||
ImportLauncherType::ATLauncher,
|
||||
ImportLauncherType::GDLauncher,
|
||||
ImportLauncherType::Curseforge,
|
||||
];
|
||||
for lt in types {
|
||||
if let Ok(instances) =
|
||||
Box::pin(get_importable_instances(lt, base_path.clone()))
|
||||
.await
|
||||
&& !instances.is_empty()
|
||||
{
|
||||
return Ok(instances);
|
||||
}
|
||||
}
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
};
|
||||
|
||||
@@ -144,10 +157,39 @@ pub async fn import_instance(
|
||||
.await
|
||||
}
|
||||
ImportLauncherType::Unknown => {
|
||||
return Err(crate::ErrorKind::InputError(
|
||||
"Launcher type Unknown".to_string(),
|
||||
)
|
||||
.into());
|
||||
let types = [
|
||||
ImportLauncherType::MultiMC,
|
||||
ImportLauncherType::PrismLauncher,
|
||||
ImportLauncherType::ATLauncher,
|
||||
ImportLauncherType::GDLauncher,
|
||||
ImportLauncherType::Curseforge,
|
||||
];
|
||||
let mut matched = false;
|
||||
for lt in types {
|
||||
if let Ok(instances) =
|
||||
Box::pin(get_importable_instances(lt, base_path.clone()))
|
||||
.await
|
||||
&& instances.contains(&instance_folder)
|
||||
{
|
||||
matched = true;
|
||||
Box::pin(import_instance(
|
||||
profile_path,
|
||||
lt,
|
||||
base_path,
|
||||
instance_folder,
|
||||
))
|
||||
.await?;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if !matched {
|
||||
return Err(crate::ErrorKind::InputError(
|
||||
"Could not determine launcher type for the given path"
|
||||
.to_string(),
|
||||
)
|
||||
.into());
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -149,13 +149,33 @@ pub async fn install_zipped_mrpack_files(
|
||||
file_hashes.push(hash);
|
||||
}
|
||||
|
||||
let project_ids: Vec<String> = pack
|
||||
.files
|
||||
.iter()
|
||||
.filter_map(|f| {
|
||||
f.downloads.iter().find_map(|url| {
|
||||
let parts: Vec<&str> = url.split('/').collect();
|
||||
let data_idx = parts.iter().position(|&p| p == "data")?;
|
||||
parts.get(data_idx + 1).map(|s| s.to_string())
|
||||
})
|
||||
})
|
||||
.collect::<std::collections::HashSet<_>>()
|
||||
.into_iter()
|
||||
.collect();
|
||||
|
||||
tracing::info!(
|
||||
"Caching {} modpack file hashes for version {}",
|
||||
"Caching {} modpack file hashes and {} project IDs for version {}",
|
||||
file_hashes.len(),
|
||||
project_ids.len(),
|
||||
version_id
|
||||
);
|
||||
CachedEntry::cache_modpack_files(version_id, file_hashes, &state.pool)
|
||||
.await?;
|
||||
CachedEntry::cache_modpack_files(
|
||||
version_id,
|
||||
file_hashes,
|
||||
project_ids,
|
||||
&state.pool,
|
||||
)
|
||||
.await?;
|
||||
} else {
|
||||
tracing::warn!(
|
||||
"No version_id available, skipping modpack file hash caching"
|
||||
|
||||
@@ -142,6 +142,10 @@ pub enum WorldDetails {
|
||||
index: usize,
|
||||
address: String,
|
||||
pack_status: ServerPackStatus,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
project_id: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
content_kind: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -426,6 +430,8 @@ async fn get_server_worlds_in_profile(
|
||||
index,
|
||||
address: server.ip,
|
||||
pack_status: server.accept_textures.into(),
|
||||
project_id: None,
|
||||
content_kind: None,
|
||||
},
|
||||
};
|
||||
worlds.push(world);
|
||||
@@ -460,6 +466,15 @@ async fn get_server_worlds_in_profile(
|
||||
|
||||
fn attach_world_data_to_world(world: &mut World, data: &AttachedWorldData) {
|
||||
world.display_status = data.display_status;
|
||||
if let WorldDetails::Server {
|
||||
project_id,
|
||||
content_kind,
|
||||
..
|
||||
} = &mut world.details
|
||||
{
|
||||
*project_id = data.project_id.clone();
|
||||
*content_kind = data.content_kind.clone();
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn set_world_display_status(
|
||||
@@ -712,9 +727,12 @@ async fn try_get_world_session_lock(
|
||||
|
||||
pub async fn add_server_to_profile(
|
||||
profile_path: &Path,
|
||||
profile_path_id: &str,
|
||||
name: String,
|
||||
address: String,
|
||||
pack_status: ServerPackStatus,
|
||||
project_id: Option<String>,
|
||||
content_kind: Option<String>,
|
||||
) -> Result<usize> {
|
||||
let mut servers = servers_data::read(profile_path).await?;
|
||||
let insert_index = servers
|
||||
@@ -725,13 +743,38 @@ pub async fn add_server_to_profile(
|
||||
insert_index,
|
||||
servers_data::ServerData {
|
||||
name,
|
||||
ip: address,
|
||||
ip: address.clone(),
|
||||
accept_textures: pack_status.into(),
|
||||
hidden: false,
|
||||
icon: None,
|
||||
},
|
||||
);
|
||||
servers_data::write(profile_path, &servers).await?;
|
||||
|
||||
if project_id.is_some() || content_kind.is_some() {
|
||||
let state = State::get().await?;
|
||||
if let Some(project_id) = &project_id {
|
||||
attached_world_data::set_project_id(
|
||||
profile_path_id,
|
||||
WorldType::Server,
|
||||
&address,
|
||||
project_id,
|
||||
&state.pool,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
if let Some(content_kind) = &content_kind {
|
||||
attached_world_data::set_content_kind(
|
||||
profile_path_id,
|
||||
WorldType::Server,
|
||||
&address,
|
||||
content_kind,
|
||||
&state.pool,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(insert_index)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user