Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
nomnomab committed Aug 29, 2024
2 parents eb946a4 + b75ba93 commit 8124174
Show file tree
Hide file tree
Showing 15 changed files with 83 additions and 22 deletions.
Binary file added .github/assets/editors.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/assets/file-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/assets/git-packages.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/assets/new-template.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/assets/packages.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed .github/assets/preview.png
Binary file not shown.
Binary file added .github/assets/projects.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/assets/templates.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,33 @@ pnpm tauri build
```

Then find the exe in `\src-tauri\target\release\`

## Screenshots

#### Projects

![Projects](.github/assets/projects.png)

#### Editors

![Editors](.github/assets/editors.png)

#### Templates

![Templates](.github/assets/templates.png)

#### Packages

![Packages](.github/assets/packages.png)

#### Git Packages

![Git Packages](.github/assets/git-packages.png)

#### File View

![Files](.github/assets/file-view.png)

#### Template Creation

![Template Creation](.github/assets/new-template.png)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nomnom-unity-hub",
"private": true,
"version": "1.0.3",
"version": "1.0.4",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
12 changes: 9 additions & 3 deletions src-tauri/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@ pub struct SearchOptions {
}

// load a project at a given path
pub fn load(path: impl AsRef<Path>) -> anyhow::Result<Project> {
pub fn load(path: impl AsRef<Path>) -> Result<Project, errors::AnyError> {
let path = path.as_ref();
let assets_path = path.join("Assets");

if !assets_path.exists() {
return Err(errors::io_not_found("Invalid project path"));
}

let file_name = path
.file_name()
.ok_or(errors::io_not_found("Invalid project path"))?;
Expand Down Expand Up @@ -90,7 +96,7 @@ pub fn remove_missing_projects(app_state: &tauri::State<AppState>) -> anyhow::Re
.map_err(|_| errors::str_error("Failed to lock projects"))?;
let missing_projects = projects
.iter()
.filter(|x| !x.path.clone().exists())
.filter(|x| !x.path.clone().exists() || !x.path.clone().join("Assets").exists())
.map(|x| x.clone())
.collect::<Vec<_>>();

Expand Down Expand Up @@ -167,7 +173,7 @@ pub fn cmd_get_default_project_path(app_state: tauri::State<AppState>) -> Result
}

#[tauri::command]
pub fn cmd_remove_missing_projects(app_handle: tauri::AppHandle, app_state: tauri::State<AppState>) -> Result<Vec<Project>, errors::AnyError> {
pub async fn cmd_remove_missing_projects(app_handle: tauri::AppHandle, app_state: tauri::State<'_, AppState>) -> Result<Vec<Project>, errors::AnyError> {
let removed_projects = remove_missing_projects(&app_state)?;
let projects = app::get_projects(&app_state)?;
app::save_projects_to_disk(&projects, &app_handle)?;
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"package": {
"productName": "Nomnoms Unity Hub",
"version": "1.0.3"
"version": "1.0.4"
},
"tauri": {
"allowlist": {
Expand Down
41 changes: 31 additions & 10 deletions src/views/new-project/package-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import FolderOpen from "../../components/svg/folder-open";
import { open } from "@tauri-apps/api/dialog";
import Delete from "../../components/svg/delete";
import { Buttons } from "../../components/parts/buttons";
import toast from "react-hot-toast";

const categories = ["All", "In Package", "Default", "Internal", "Git", "Local"];

Expand Down Expand Up @@ -302,8 +303,10 @@ export default function PackageView() {
onClick={() => onlyShowSelectedPackages.set((s) => !s)}
>
<div className="w-7 aspect-square border rounded-md border-stone-600 select-none">
<div className="p-1">
{onlyShowSelectedPackages.value && <Checkmark />}
<div className="flex items-center justify-center w-full h-full">
{onlyShowSelectedPackages.value && (
<Checkmark width={16} height={16} />
)}
</div>
</div>
<p className="select-none">
Expand Down Expand Up @@ -368,8 +371,16 @@ function GitAdd(props: {

async function addPackage() {
if (tab.value === "url") {
if (gitPackageId.value === "") return;
if (gitPackageUrl.value === "") return;
if (gitPackageId.value === "") {
toast.error(
"Invalid package name. You can find this in the package.json"
);
return;
}
if (gitPackageUrl.value === "") {
toast.error("Invalid URL");
return;
}
if (
newProjectContext.state.packageInfo.gitPackages.some(
(x) =>
Expand All @@ -380,9 +391,11 @@ function GitAdd(props: {
return;
}

const id = gitPackageId.value.trim();
const version = gitPackageUrl.value.trim();
await TauriRouter.add_git_package_to_cache({
name: gitPackageId.value,
version: gitPackageUrl.value,
name: id,
version,
isFile: false,
isDiscoverable: true,
type: TauriTypes.PackageType.Git,
Expand All @@ -391,8 +404,8 @@ function GitAdd(props: {
newProjectContext.dispatch({
type: "add_git_package",
package: {
id: gitPackageId.value,
url: gitPackageUrl.value,
id,
url: version,
},
});

Expand All @@ -414,11 +427,19 @@ function GitAdd(props: {
gitPackageUrl.value
);
} else {
if (gitPackageJson.value === "") return;
if (gitPackageJson.value === "") {
toast.error("Invalid JSON");
return;
}

try {
// make json more acceptable
let gitPackageJson_ = gitPackageJson.value.trim();
if (gitPackageJson_.endsWith(",")) {
gitPackageJson_ = gitPackageJson_.slice(0, -1);
}
const obj: { [key: string]: string } = JSON.parse(
`{${gitPackageJson.value}}`
`{${gitPackageJson_}}`
);
const [name, version] = Object.entries(obj)[0];

Expand Down
17 changes: 11 additions & 6 deletions src/views/projects/projects-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { TauriRouter } from "../../utils/tauri-router";
import { open } from "@tauri-apps/api/dialog";
import { UseState } from "../../utils";
import { ProjectViewData } from "./projects-view";
import { routeErrorToToast } from "../../utils/toast-utils";

export default function ProjectsHeader({
projectData,
Expand All @@ -21,14 +22,18 @@ export default function ProjectsHeader({
});
if (!folder) return;

const project = await TauriRouter.add_project(folder as string);
// console.log("project:", project);
try {
const project = await TauriRouter.add_project(folder as string);
// console.log("project:", project);

const results = await TauriRouter.get_projects();
// console.log("projects:", results);
const results = await TauriRouter.get_projects();
// console.log("projects:", results);

projectData.set((s) => ({ ...s, projects: results }));
// dispatch({ type: "set_projects", projects: results });
projectData.set((s) => ({ ...s, projects: results }));
// dispatch({ type: "set_projects", projects: results });
} catch (error) {
routeErrorToToast(error);
}
}

async function startNewProject() {
Expand Down
1 change: 0 additions & 1 deletion src/views/projects/projects-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import LoadingSpinner from "../../components/svg/loading-spinner";
import useBetterState from "../../hooks/useBetterState";
import Box from "../../components/svg/box";
import Pin from "../../components/svg/pin";
import { Buttons } from "../../components/parts/buttons";
import Sort from "../../components/svg/sort";
import toast from "react-hot-toast";
import { routeErrorToToast } from "../../utils/toast-utils";
Expand Down

0 comments on commit 8124174

Please sign in to comment.