import React from "react";
import { observer } from "mobx-react";
import classNames from "classnames";
import { compareVersions } from "eez-studio-shared/util";
import { Loader } from "eez-studio-ui/loader";
import {
FIRMWARE_RELEASES_PAGE,
FIRMWARE_UPGRADE_PAGE
} from "instrument/bb3/conf";
import { openLink } from "instrument/bb3/helpers";
import { BB3Instrument } from "instrument/bb3/objects/BB3Instrument";
import { Section } from "instrument/bb3/components/Section";
import { DropdownIconAction, DropdownItem } from "eez-studio-ui/action";
const OtherReleases = observer(
({ bb3Instrument }: { bb3Instrument: BB3Instrument }) => {
if (!bb3Instrument.mcu.allReleases) {
return null;
}
if (
!bb3Instrument.mcu.firmwareVersion ||
compareVersions(bb3Instrument.mcu.firmwareVersion, "1.7.1") < 0
) {
return null;
}
const otherReleases = bb3Instrument.mcu.allReleases
.slice()
.sort((a, b) => compareVersions(b.tag_name, a.tag_name))
.filter(
release =>
compareVersions(release.tag_name, "1.7.1") >= 0 &&
release.tag_name != bb3Instrument.mcu.firmwareVersion
);
if (otherReleases.length == 0) {
return null;
}
return (
Other versions{" "}
chevron_right
| Version |
|
{otherReleases.map(release => (
| {release.tag_name} |
|
))}
);
}
);
export const ReleaseInfo = observer(
({ bb3Instrument }: { bb3Instrument: BB3Instrument }) => {
if (bb3Instrument.refreshInProgress) {
return ;
}
const firmwareVersion = bb3Instrument.mcu.firmwareVersion;
if (firmwareVersion == undefined) {
return (
Failed to get info about the latest firmware version!
);
}
if (!firmwareVersion) {
return null;
}
const latestFirmwareVersion = bb3Instrument.mcu.latestFirmwareVersion;
if (!latestFirmwareVersion) {
return (
Could not get info about the latest firmware version!
);
}
if (compareVersions(latestFirmwareVersion, firmwareVersion) > 0) {
return (
<>
>
);
}
return (
<>
This is the latest firmware version!
>
);
}
);
export const FirmwareVersionSection = observer(
({ bb3Instrument }: { bb3Instrument: BB3Instrument }) => {
const isConnected = bb3Instrument.appStore.instrument?.isConnected;
return (
) : (
))
}
titleControls={
!bb3Instrument.busy &&
isConnected && (
)
}
/>
);
}
);