Skip to content

Commit

Permalink
fixed developer menu, added mac os version check for podman 5
Browse files Browse the repository at this point in the history
  • Loading branch information
corn-potage committed May 9, 2024
1 parent 8188c53 commit a80d60d
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 59 deletions.
2 changes: 2 additions & 0 deletions assets/locales/en/systemRequirements.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"macOSTitle": "MacOS version is at least {{minVersion}} to run Podman 5.0",
"macOSDescription": "MacOS version: {{version}}",
"processorCoresTitle": "Processor has {{minCores}} cores or more",
"processorCoresDescription": "Processor cores: {{cores}}",
"memorySizeTitle": "At least {{minSize}}GB of system memory (RAM)",
Expand Down
6 changes: 5 additions & 1 deletion src/main/nn-auto-updater/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ export class nnAutoUpdater
if (isLinux()) {
console.log('nnAutoUpdater setFeedURL in linux!');
} else {
this.nativeUpdater.setFeedURL(options);
try {
this.nativeUpdater.setFeedURL(options);
} catch (e) {
console.error('Error in setFeedURL: ', e);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
import type { TFunction } from 'i18next';
import type { ReactElement } from 'react';
import type { TFunction } from "i18next";
import type { ReactElement } from "react";
import type {
CpuRequirements,
// DockerRequirements,
InternetRequirements,
MemoryRequirements,
StorageRequirements,
} from '../../../common/systemRequirements';
} from "../../../common/systemRequirements";

import type { ChecklistItemProps } from '../../Generics/redesign/Checklist/ChecklistItem';
import ExternalLink from '../../Generics/redesign/Link/ExternalLink';
import { bytesToGB } from '../../utils';
import type { NodeRequirementsProps } from './NodeRequirements';
import { findSystemStorageDetailsAtALocation } from './nodeStorageUtil';
import type { ChecklistItemProps } from "../../Generics/redesign/Checklist/ChecklistItem";
import ExternalLink from "../../Generics/redesign/Link/ExternalLink";
import { bytesToGB } from "../../utils";
import type { NodeRequirementsProps } from "./NodeRequirements";
import { findSystemStorageDetailsAtALocation } from "./nodeStorageUtil";

const isVersionHigher = (currentVersion: string, targetVersion: string) => {
const parseVersion = (version: string) => version.split(".").map(Number);

const current = parseVersion(currentVersion);
const target = parseVersion(targetVersion);

for (let i = 0; i < Math.max(current.length, target.length); i++) {
const currentPart = current[i] || 0;
const targetPart = target[i] || 0;
if (currentPart > targetPart) return true;
if (currentPart < targetPart) return false;
}
return false;
};

const TARGET_MACOS_VERSION = "13.0.0";

export const makeCheckList = (
{ nodeRequirements, systemData, nodeStorageLocation }: NodeRequirementsProps,
Expand All @@ -30,90 +47,107 @@ export const makeCheckList = (
nodeStorageLocation,
);
}
console.log('nodeLocationStorageDetails', nodeLocationStorageDetails);
console.log("nodeLocationStorageDetails", nodeLocationStorageDetails);

if (systemData?.os?.platform === "darwin") {
const checkListItem: ChecklistItemProps = {
checkTitle: t("macOSTitle", {
minVersion: TARGET_MACOS_VERSION,
}),
valueText: t("macOSDescription", {
version: systemData?.os?.release,
}),
status: "",
};
if (isVersionHigher(systemData?.os?.release, TARGET_MACOS_VERSION)) {
checkListItem.status = "complete";
} else {
checkListItem.status = "error";
}
newChecklistItems.push(checkListItem);
}
for (const [nodeReqKey, nodeReqValue] of Object.entries(nodeRequirements)) {
console.log(`${nodeReqKey}: ${nodeReqValue}`);
if (nodeReqKey === 'documentationUrl' || nodeReqKey === 'description') {
if (nodeReqKey === "documentationUrl" || nodeReqKey === "description") {
continue;
}
// title and desc depends on req type
// title and desc depends on whether the req is met or not
// if cpu, if cores meets, add success
// if minSpeed doesn't meet
let checkTitle = '';
let valueText = '';
let checkTitle = "";
let valueText = "";
let valueComponent: ReactElement = <></>;
const captionText = '';
let status: ChecklistItemProps['status'] = 'loading';
if (nodeReqKey === 'cpu') {
const captionText = "";
let status: ChecklistItemProps["status"] = "loading";
if (nodeReqKey === "cpu") {
const req = nodeReqValue as CpuRequirements;
if (req.cores !== undefined) {
checkTitle = t('processorCoresTitle', {
checkTitle = t("processorCoresTitle", {
minCores: req.cores,
});
if (systemData?.cpu?.cores) {
valueText = t('processorCoresDescription', {
valueText = t("processorCoresDescription", {
cores: systemData?.cpu.cores,
});
if (systemData?.cpu.cores >= req.cores) {
status = 'complete';
status = "complete";
} else {
status = 'incomplete';
status = "incomplete";
}
} else {
status = 'error';
status = "error";
}
}
}
if (nodeReqKey === 'memory') {
if (nodeReqKey === "memory") {
const req = nodeReqValue as MemoryRequirements;
if (req.minSizeGBs !== undefined) {
checkTitle = t('memorySizeTitle', {
checkTitle = t("memorySizeTitle", {
minSize: req.minSizeGBs,
});
if (systemData?.memLayout[0]?.size) {
valueText = t('memorySizeDescription', {
valueText = t("memorySizeDescription", {
size: bytesToGB(systemData?.memLayout[0]?.size),
});
if (systemData?.memLayout[0]?.size >= req.minSizeGBs) {
status = 'complete';
status = "complete";
} else {
status = 'incomplete';
status = "incomplete";
}
} else {
status = 'error';
status = "error";
}
}
}
if (nodeReqKey === 'storage') {
if (nodeReqKey === "storage") {
const req = nodeReqValue as StorageRequirements;
const disk = nodeLocationStorageDetails;
if (req.ssdRequired === true) {
checkTitle = t('storageTypeTitle', {
type: 'SSD',
checkTitle = t("storageTypeTitle", {
type: "SSD",
});
if (disk?.type || disk?.name) {
if (disk?.type.includes('NVMe') || disk?.name.includes('NVMe')) {
valueText = t('storageTypeDescription', {
type: disk?.type ? disk?.type : 'NVMe SSD',
if (disk?.type.includes("NVMe") || disk?.name.includes("NVMe")) {
valueText = t("storageTypeDescription", {
type: disk?.type ? disk?.type : "NVMe SSD",
});
status = 'complete';
} else if (disk?.type.includes('SSD') || disk?.name.includes('SSD')) {
valueText = t('storageTypeDescription', {
type: disk?.type ? disk?.type : 'SSD',
status = "complete";
} else if (disk?.type.includes("SSD") || disk?.name.includes("SSD")) {
valueText = t("storageTypeDescription", {
type: disk?.type ? disk?.type : "SSD",
});
status = 'complete';
} else if (disk?.type.includes('HDD') || disk?.name.includes('HDD')) {
valueText = t('storageTypeDescription', {
type: disk?.type ? disk?.type : 'HDD',
status = "complete";
} else if (disk?.type.includes("HDD") || disk?.name.includes("HDD")) {
valueText = t("storageTypeDescription", {
type: disk?.type ? disk?.type : "HDD",
});
status = 'error';
status = "error";
} else {
status = 'incomplete';
status = "incomplete";
}
} else {
status = 'error';
status = "error";
}
const checkListItem: ChecklistItemProps = {
checkTitle,
Expand All @@ -123,51 +157,51 @@ export const makeCheckList = (
newChecklistItems.push(checkListItem);
}
if (req.minSizeGBs !== undefined) {
checkTitle = t('storageSizeTitle', {
checkTitle = t("storageSizeTitle", {
minSize: req.minSizeGBs,
});
if (disk?.freeSpaceGBs) {
const diskSizeGbs = Math.round(disk.freeSpaceGBs);
// todo: use free space for storage calculations?
valueText = t('storageSizeDescription', {
valueText = t("storageSizeDescription", {
freeSize: diskSizeGbs,
storageName: disk.name,
});
if (diskSizeGbs >= req.minSizeGBs) {
status = 'complete';
status = "complete";
} else {
status = 'incomplete';
status = "incomplete";
}
} else {
status = 'error';
status = "error";
}
}
}
if (nodeReqKey === 'internet') {
if (nodeReqKey === "internet") {
const req = nodeReqValue as InternetRequirements;
if (req.minDownloadSpeedMbps !== undefined) {
checkTitle = t('internetSpeedTitle', {
checkTitle = t("internetSpeedTitle", {
minDownloadSpeed: req.minDownloadSpeedMbps,
minUploadSpeed: req.minUploadSpeedMbps,
});
valueText = t('internetSpeedPleaseTest');
valueText = t("internetSpeedPleaseTest");
valueComponent = (
<>
{`${t('internetSpeedTestWebsites')} `}
{`${t("internetSpeedTestWebsites")} `}
<ExternalLink
text={t('internetSpeedGoogleSpeedTest')}
text={t("internetSpeedGoogleSpeedTest")}
url="https://www.google.com/search?q=speed+test"
inline
/>{' '}
or{' '}
/>{" "}
or{" "}
<ExternalLink
text={t('internetSpeedOoklaSpeedTest')}
text={t("internetSpeedOoklaSpeedTest")}
url="https://speedtest.net"
inline
/>
</>
);
status = 'information';
status = "information";
}
}
// Todoo: Don't make user think about Podman?
Expand Down
9 changes: 8 additions & 1 deletion src/renderer/Presentational/PodmanModal/PodmanWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useCallback } from "react";
import type { ModalConfig } from "../ModalManager/modalUtils.js";
import PodmanInstallation from "../PodmanInstallation/PodmanInstallation.tsx";

Expand All @@ -10,10 +11,16 @@ const PodmanWrapper = ({
modalOnChangeConfig,
disableSaveButton,
}: PodmanWrapperProps) => {
const onChangeDockerInstall = useCallback((newValue: string) => {
if (newValue === "done") {
disableSaveButton(false);
}
}, []);

return (
<PodmanInstallation
disableSaveButton={disableSaveButton}
// onChange={onChangeDockerInstall}
onChange={onChangeDockerInstall}
/>
);
};
Expand Down

0 comments on commit a80d60d

Please sign in to comment.