1- import type {
2- Images ,
3- State ,
4- GoogleCloudConfiguration as GoogleCloudConfigurationType ,
5- ComputeServerTemplate ,
6- GoogleCloudAcceleratorType ,
7- } from "@cocalc/util/db-schema/compute-servers" ;
8- import { reloadImages , useImages , useGoogleImages } from "./images-hook" ;
9- import { GOOGLE_CLOUD_DEFAULTS } from "@cocalc/util/db-schema/compute-servers" ;
10- import {
11- getMinDiskSizeGb ,
12- getArchitecture ,
13- } from "@cocalc/util/db-schema/compute-servers" ;
141import {
152 Alert ,
163 Button ,
@@ -25,44 +12,60 @@ import {
2512 Tooltip ,
2613 Typography ,
2714} from "antd" ;
28- import { currency , cmp , plural } from "@cocalc/util/misc" ;
15+ import { isEqual } from "lodash" ;
16+ import { useEffect , useState } from "react" ;
17+
18+ import { useTypedRedux } from "@cocalc/frontend/app-framework" ;
19+ import { A } from "@cocalc/frontend/components/A" ;
20+ import ShowError from "@cocalc/frontend/components/error" ;
21+ import { Icon } from "@cocalc/frontend/components/icon" ;
22+ import Disk from "@cocalc/frontend/compute/cloud/common/disk" ;
23+ import DNS from "@cocalc/frontend/compute/cloud/common/dns" ;
24+ import Template from "@cocalc/frontend/compute/cloud/common/template" ;
25+ import { displayAcceleratorType } from "@cocalc/frontend/compute/cloud/google-cloud/accelerator" ;
26+ import Specs , {
27+ RamAndCpu ,
28+ } from "@cocalc/frontend/compute/cloud/google-cloud/specs" ;
29+ import ExcludeFromSync from "@cocalc/frontend/compute/exclude-from-sync" ;
30+ import { filterOption } from "@cocalc/frontend/compute/util" ;
2931import computeCost , {
30- GoogleCloudData ,
31- EXTERNAL_IP_COST ,
32- DATA_TRANSFER_OUT_COST_PER_GiB ,
33- markup ,
3432 computeAcceleratorCost ,
35- computeInstanceCost ,
3633 computeDiskCost ,
34+ computeInstanceCost ,
35+ DATA_TRANSFER_OUT_COST_PER_GiB ,
36+ EXTERNAL_IP_COST ,
37+ GoogleCloudData ,
38+ markup ,
3739} from "@cocalc/util/compute/cloud/google-cloud/compute-cost" ;
40+ import type {
41+ Architecture ,
42+ ComputeServerTemplate ,
43+ GoogleCloudAcceleratorType ,
44+ GoogleCloudConfiguration as GoogleCloudConfigurationType ,
45+ Images ,
46+ State ,
47+ } from "@cocalc/util/db-schema/compute-servers" ;
48+ import {
49+ getArchitecture ,
50+ getMachineTypeArchitecture ,
51+ getMinDiskSizeGb ,
52+ GOOGLE_CLOUD_DEFAULTS ,
53+ } from "@cocalc/util/db-schema/compute-servers" ;
54+ import { cmp , currency , plural } from "@cocalc/util/misc" ;
55+ import AllowCollaboratorControl from "./allow-collaborator-control" ;
3856import {
3957 getGoogleCloudPriceData ,
4058 setImageTested ,
4159 setServerConfiguration ,
4260} from "./api" ;
43- import { useEffect , useState } from "react" ;
44- import { A } from "@cocalc/frontend/components/A" ;
45- import { Icon } from "@cocalc/frontend/components/icon" ;
46- import { isEqual } from "lodash" ;
47- import { useTypedRedux } from "@cocalc/frontend/app-framework" ;
48- import SelectImage , { ImageLinks , ImageDescription } from "./select-image" ;
49- import Ephemeral from "./ephemeral" ;
5061import AutoRestart from "./auto-restart" ;
51- import AllowCollaboratorControl from "./allow-collaborator-control" ;
62+ import { availableClouds } from "./config" ;
63+ import CostOverview from "./cost-overview" ;
64+ import Ephemeral from "./ephemeral" ;
65+ import { reloadImages , useGoogleImages , useImages } from "./images-hook" ;
5266import NestedVirtualization from "./nested-virtualization" ;
53- import ShowError from "@cocalc/frontend/components/error" ;
5467import Proxy from "./proxy" ;
55- import CostOverview from "./cost-overview" ;
56- import Disk from "@cocalc/frontend/compute/cloud/common/disk" ;
57- import DNS from "@cocalc/frontend/compute/cloud/common/dns" ;
58- import ExcludeFromSync from "@cocalc/frontend/compute/exclude-from-sync" ;
59- import { availableClouds } from "./config" ;
60- import Template from "@cocalc/frontend/compute/cloud/common/template" ;
61- import Specs , {
62- RamAndCpu ,
63- } from "@cocalc/frontend/compute/cloud/google-cloud/specs" ;
64- import { displayAcceleratorType } from "@cocalc/frontend/compute/cloud/google-cloud/accelerator" ;
65- import { filterOption } from "@cocalc/frontend/compute/util" ;
68+ import SelectImage , { ImageDescription , ImageLinks } from "./select-image" ;
6669
6770export const SELECTOR_WIDTH = "350px" ;
6871
@@ -794,9 +797,7 @@ function Provisioning({ priceData, setConfig, configuration, disabled }) {
794797 </ Radio . Button >
795798 < Radio . Button value = "standard" >
796799 Standard{ " " }
797- { prices != null
798- ? `${ currency ( prices . standard ) } /hour`
799- : undefined } { " " }
800+ { prices != null ? `${ currency ( prices . standard ) } /hour` : undefined } { " " }
800801 </ Radio . Button >
801802 </ Radio . Group >
802803 < div style = { { color : "#666" , marginTop : "5px" } } >
@@ -939,17 +940,19 @@ function Zone({ priceData, setConfig, configuration, disabled }) {
939940}
940941
941942function MachineType ( { priceData, setConfig, configuration, disabled, state } ) {
942- const [ archType , setArchType ] = useState < "x86_64" | "arm64" > (
943+ const [ archType , setArchType ] = useState < Architecture > (
943944 getArchitecture ( configuration ) ,
944945 ) ;
945946 const [ sortByPrice , setSortByPrice ] = useState < boolean > ( true ) ;
946947 const [ newMachineType , setNewMachineType ] = useState < string > (
947948 configuration . machineType ?? "" ,
948949 ) ;
950+
949951 useEffect ( ( ) => {
950952 setNewMachineType ( configuration . machineType ) ;
951953 setArchType ( getArchitecture ( configuration ) ) ;
952954 } , [ configuration . machineType ] ) ;
955+
953956 useEffect ( ( ) => {
954957 if ( archType == "arm64" && getArchitecture ( configuration ) != "arm64" ) {
955958 setNewMachineType ( "t2a-standard-4" ) ;
@@ -964,17 +967,19 @@ function MachineType({ priceData, setConfig, configuration, disabled, state }) {
964967 } , [ archType , configuration . machineType ] ) ;
965968
966969 const machineTypes = Object . keys ( priceData . machineTypes ) ;
967- let allOptions = machineTypes
970+ const allOptions = machineTypes
968971 . filter ( ( machineType ) => {
969972 const { acceleratorType } = configuration ;
970973 if ( ! acceleratorType ) {
971974 if ( machineType . startsWith ( "g" ) || machineType . startsWith ( "a" ) ) {
972975 return false ;
973976 }
974- if ( archType == "arm64" && getArchitecture ( configuration ) != "arm64" ) {
977+ // Check if the machine type's architecture matches the selected architecture
978+ const machineArch = getMachineTypeArchitecture ( machineType ) ;
979+ if ( archType == "arm64" && machineArch != "arm64" ) {
975980 return false ;
976981 }
977- if ( archType == "x86_64" && getArchitecture ( configuration ) == "arm64 ") {
982+ if ( archType == "x86_64" && machineArch != "x86_64 ") {
978983 return false ;
979984 }
980985 } else {
@@ -1049,8 +1054,8 @@ function MachineType({ priceData, setConfig, configuration, disabled, state }) {
10491054 ( state ?? "deprovisioned" ) != "deprovisioned"
10501055 ? "Can only be changed when machine is deprovisioned"
10511056 : archType == "x86_64"
1052- ? "Intel or AMD X86_64 architecture machines"
1053- : "ARM64 architecture machines"
1057+ ? "Intel or AMD X86_64 architecture machines"
1058+ : "ARM64 architecture machines"
10541059 }
10551060 >
10561061 < Radio . Group
0 commit comments