Skip to content

Commit 5b72065

Browse files
committed
Added check for mismatched versions
1 parent e240846 commit 5b72065

File tree

4 files changed

+46
-22
lines changed

4 files changed

+46
-22
lines changed

src-tauri/src/package.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pub struct MinimalPackage {
4747
pub name: String,
4848
pub version: String,
4949
pub is_file: bool,
50+
pub is_discoverable: bool,
5051
pub _type: PackageType
5152
}
5253

@@ -101,16 +102,18 @@ pub fn get_editor_package_manager_manifest(editor_version: String, app_state: &t
101102

102103
// commands
103104

105+
// need to override versions with current template versions
104106
#[tauri::command]
105107
pub fn cmd_get_default_editor_packages(editor_version: String, app_state: tauri::State<AppState>) -> Result<Vec<MinimalPackage>, errors::AnyError> {
106108
let manifest = get_editor_package_manager_manifest(editor_version, &app_state)?;
107109
let mut manifest_packages = manifest.packages
108110
.iter()
109-
.filter(|x| x.1.is_discoverable == Some(true))
111+
// .filter(|x| x.1.is_discoverable == Some(true))
110112
.map(|x| MinimalPackage {
111113
name: x.0.clone(),
112114
version: x.1.version.clone().unwrap_or_default(),
113115
is_file: x.1.is_file.unwrap_or(false),
116+
is_discoverable: x.1.is_discoverable.unwrap_or(false),
114117
_type: PackageType::Internal
115118
})
116119
.collect::<Vec<_>>();

src/context/new-project-context.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ export namespace NewProjectContext {
327327
name: action.package.id,
328328
version: action.package.url,
329329
isFile: false,
330+
isDiscoverable: true,
330331
type: TauriTypes.PackageType.Git,
331332
},
332333
],
@@ -343,6 +344,7 @@ export namespace NewProjectContext {
343344
name: action.package.path,
344345
version: "", // will get turned into file:../id
345346
isFile: false,
347+
isDiscoverable: true,
346348
type: TauriTypes.PackageType.Local,
347349
},
348350
],

src/utils/tauri-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export namespace TauriTypes {
115115
name: string;
116116
version: string;
117117
isFile: boolean;
118+
isDiscoverable: boolean;
118119
type: PackageType;
119120
}
120121

src/views/new-project/package-view.tsx

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,7 @@ export default function PackageView() {
138138
const packages = newProjectContext.state.packageInfo.selectedPackages;
139139
return (
140140
validPackages.filter((x) =>
141-
packages.find(
142-
(y) => y.name === x.package_.name && y.version === x.package_.version
143-
)
141+
packages.find((y) => y.name === x.package_.name)
144142
) ?? []
145143
);
146144
}, [
@@ -236,21 +234,24 @@ export default function PackageView() {
236234
)}
237235

238236
<div className="flex flex-col gap-2 py-3 w-full">
239-
{queriedPackages?.map((x, i) => (
240-
<Package
241-
key={i}
242-
package_={x}
243-
onClick={() =>
244-
togglePackage(x.package_.name, x.package_.version)
245-
}
246-
destroyPackage={destroyPackage}
247-
selected={newProjectContext.state.packageInfo.selectedPackages.some(
248-
(y) =>
249-
y.name === x.package_.name &&
250-
y.version === x.package_.version
251-
)}
252-
/>
253-
))}
237+
{queriedPackages?.map((x, i) => {
238+
const existingPackage =
239+
newProjectContext.state.packageInfo.selectedPackages.find(
240+
(y) => y.name === x.package_.name
241+
);
242+
return (
243+
<Package
244+
key={i}
245+
package_={x}
246+
onClick={() =>
247+
togglePackage(x.package_.name, x.package_.version)
248+
}
249+
destroyPackage={destroyPackage}
250+
selected={!!existingPackage}
251+
otherVersion={existingPackage?.version}
252+
/>
253+
);
254+
})}
254255
</div>
255256
</AsyncLazyValueComponent>
256257
</div>
@@ -285,6 +286,7 @@ function GitAdd(props: {
285286
name: gitPackageId.value,
286287
version: gitPackageUrl.value,
287288
isFile: false,
289+
isDiscoverable: true,
288290
type: TauriTypes.PackageType.Git,
289291
});
290292

@@ -324,6 +326,7 @@ function GitAdd(props: {
324326
name,
325327
version,
326328
isFile: false,
329+
isDiscoverable: true,
327330
type: TauriTypes.PackageType.Git,
328331
});
329332

@@ -449,6 +452,7 @@ function LocalAdd(props: {
449452
name: localPackage.value,
450453
version: "",
451454
isFile: false,
455+
isDiscoverable: true,
452456
type: TauriTypes.PackageType.Local,
453457
});
454458

@@ -558,6 +562,7 @@ function Package({
558562
onClick,
559563
selected,
560564
destroyPackage,
565+
otherVersion,
561566
}: {
562567
package_: {
563568
package_: TauriTypes.MinimalPackage;
@@ -566,6 +571,7 @@ function Package({
566571
onClick?: () => void;
567572
selected: boolean;
568573
destroyPackage: (package_: TauriTypes.MinimalPackage) => void;
574+
otherVersion?: string;
569575
}) {
570576
return (
571577
<div
@@ -592,9 +598,21 @@ function Package({
592598
selected ? "text-stone-50" : "text-stone-400"
593599
}`}
594600
>
595-
{package_.package_.version === ""
596-
? "N/A"
597-
: package_.package_.version}
601+
<span>
602+
{otherVersion && package_.package_.version !== otherVersion && (
603+
<>
604+
<span className="line-through text-stone-500 pr-2">
605+
{package_.package_.version}
606+
</span>
607+
{otherVersion === "" ? "N/A" : otherVersion}
608+
</>
609+
)}
610+
611+
{!otherVersion &&
612+
(package_.package_.version === ""
613+
? "N/A"
614+
: package_.package_.version)}
615+
</span>
598616
</span>
599617
</p>
600618
{/* {value.isPinned && <p>Pinned</p>} */}

0 commit comments

Comments
 (0)