Skip to content

Commit c51a50c

Browse files
committed
chore: update project details behavior and v2.4.2 cleanup
1 parent eeeb61e commit c51a50c

File tree

4 files changed

+50
-25
lines changed

4 files changed

+50
-25
lines changed

src/components/Project/ProjectDetails.tsx

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ type ProjectDetailsProps = {
1010
createdAt: string;
1111
updatedAt: string;
1212
buildMode?: string;
13+
version: string;
1314
};
1415
};
1516

@@ -37,6 +38,17 @@ export const ProjectDetails = forwardRef<HTMLDivElement, ProjectDetailsProps>(
3738
[project.key],
3839
);
3940

41+
const showBuildMode = project.type == "Project" && project.buildMode;
42+
43+
const ProjectSize = () => (
44+
<div className="flex flex-col gap-0.5 flex-1 only:contents">
45+
<h3 className="flex-1 font-medium text-white">
46+
Project Size
47+
</h3>
48+
<div className="flex-1">{fileSize(size)}</div>
49+
</div>
50+
);
51+
4052
return (
4153
<div
4254
className="space-y-3 text-sm [&>*+*]:pt-3 [&>*+*]:border-t [&>*+*]:border-base-content/[8%]"
@@ -61,7 +73,9 @@ export const ProjectDetails = forwardRef<HTMLDivElement, ProjectDetailsProps>(
6173
<div className="flex flex-col gap-0.5 flex-1">
6274
<h3 className="font-medium text-white">Last Updated</h3>
6375
<div>
64-
{new Date(project.updatedAt).toLocaleString()}
76+
{project.updatedAt
77+
? new Date(project.updatedAt).toLocaleString()
78+
: "Unknown"}
6579
</div>
6680
</div>
6781

@@ -76,23 +90,33 @@ export const ProjectDetails = forwardRef<HTMLDivElement, ProjectDetailsProps>(
7690
</div>
7791

7892
<div className="flex flex-wrap gap-x-4 gap-y-1.5">
79-
{(project.type == "Project" && project.buildMode) && (
80-
<div className="flex flex-col gap-0.5 flex-1 only:contents">
81-
<h3 className="flex-1 font-medium text-white">
82-
Build Mode
83-
</h3>
84-
<div className="flex-1">{project.buildMode}</div>
85-
</div>
86-
)}
87-
8893
<div className="flex flex-col gap-0.5 flex-1 only:contents">
8994
<h3 className="flex-1 font-medium text-white">
90-
Project Size
95+
KAPLAY Version
9196
</h3>
92-
<div className="flex-1">{fileSize(size)}</div>
97+
<div className="flex-1">{project.version}</div>
9398
</div>
99+
100+
{showBuildMode
101+
? (
102+
<div className="flex flex-col gap-0.5 flex-1 only:contents">
103+
<h3 className="flex-1 font-medium text-white">
104+
Build Mode
105+
</h3>
106+
<div className="flex-1">
107+
{project.buildMode}
108+
</div>
109+
</div>
110+
)
111+
: <ProjectSize />}
94112
</div>
95113

114+
{showBuildMode && (
115+
<div className="flex flex-wrap gap-x-4 gap-y-1.5">
116+
<ProjectSize />
117+
</div>
118+
)}
119+
96120
{tags.length > 0 && (
97121
<div className="flex flex-wrap gap-x-4 gap-y-1.5">
98122
<div className="flex flex-col gap-0.5 flex-1">

src/components/Toolbar/ToolbarProjectDropdown.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export const ToolbarProjectDropdown: FC = () => {
117117

118118
<ToolbarDropdownButton
119119
onClick={() => openProjectDetails()}
120+
disabled={projectKey == null}
120121
>
121122
Details
122123
</ToolbarDropdownButton>

src/features/Projects/services/projectActions.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ type DeleteOptions = {
2121
};
2222
};
2323

24-
export const openProjectDetails = (
24+
export function openProjectPreferences(key?: string) {
25+
openDialog("project-preferences", { ...(key && { projectKey: key }) });
26+
}
27+
28+
export function openProjectDetails(
2529
key: string | null = useProject.getState().projectKey,
26-
) => {
30+
) {
2731
if (!key) {
2832
throw new Error(
2933
`Project doesn't exist: ${key}`,
@@ -40,12 +44,12 @@ export const openProjectDetails = (
4044
confirmText: "Close",
4145
},
4246
);
43-
};
47+
}
4448

45-
export const exportProject = (
49+
export function exportProject(
4650
key: string | null = useProject.getState().projectKey,
4751
options?: ToastOptions,
48-
) => {
52+
) {
4953
const { saveNewProject, getProjectMetadata } = useProject.getState();
5054

5155
if (!key) {
@@ -75,9 +79,9 @@ export const exportProject = (
7579
...(options?.toastContainerId
7680
&& { containerId: options?.toastContainerId }),
7781
});
78-
};
82+
}
7983

80-
export const cloneProject = (key?: string, options?: ToastOptions) => {
84+
export function cloneProject(key?: string, options?: ToastOptions) {
8185
const clonedOk = useProject.getState().cloneProject(key);
8286

8387
toast(
@@ -90,7 +94,7 @@ export const cloneProject = (key?: string, options?: ToastOptions) => {
9094
&& { containerId: options?.toastContainerId }),
9195
},
9296
);
93-
};
97+
}
9498

9599
export async function confirmAndDeleteProject(
96100
key: string | null = useProject.getState().projectKey,
@@ -201,7 +205,3 @@ export async function confirmAndDeleteProject(
201205

202206
return true;
203207
}
204-
205-
export function openProjectPreferences(key?: string) {
206-
openDialog("project-preferences", { ...(key && { projectKey: key }) });
207-
}

src/features/Projects/stores/slices/project.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export interface ProjectSlice {
141141
*/
142142
unserializeProject(id: string): Project;
143143
/**
144-
* Remove project from localStorage, current if not specified
144+
* Clone any stored project, current if not specified
145145
*
146146
* @param id - Optional roject id
147147
* @returns If cloned project successfully

0 commit comments

Comments
 (0)