Skip to content

Commit 9fe9fcc

Browse files
authored
Merge pull request #911 from Support-pl/dev
Dev
2 parents 702b5e7 + 6883235 commit 9fe9fcc

File tree

2 files changed

+21
-24
lines changed

2 files changed

+21
-24
lines changed

src/components/cloud/modules/ione-vpn/init.vue

+9-14
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ const props = defineProps({
1919
productSize: { type: String, required: true },
2020
isFlavorsLoading: { type: Boolean, default: false },
2121
});
22-
const { isFlavorsLoading, plans } = toRefs(props);
22+
const { isFlavorsLoading } = toRefs(props);
2323
2424
const emits = defineEmits(["update:periods", "update:product-size"]);
2525
2626
const cloudStore = useCloudStore();
2727
const instancesStore = useInstancesStore();
28-
const { provider, authData } = storeToRefs(useCloudStore());
28+
const { provider, authData, plan } = storeToRefs(cloudStore);
2929
const [options, setOptions] = inject("useOptions")();
3030
3131
const images = computed(() => {
3232
const { templates } = provider.value.publicData;
3333
const images = {};
3434
3535
Object.entries(templates ?? {}).forEach(([key, value]) => {
36-
if (cloudStore.plan.meta.hidedOs?.includes(key)) return;
36+
if (plan.value.meta.hidedOs?.includes(key)) return;
3737
if (value.is_public !== false) {
3838
images[key] = value;
3939
}
@@ -42,10 +42,6 @@ const images = computed(() => {
4242
return images;
4343
});
4444
45-
const plan = computed(() => {
46-
return cloudStore.plan;
47-
});
48-
4945
emits("update:periods", getPeriods(props.productSize, props.plans));
5046
watch(
5147
() => props.productSize,
@@ -65,9 +61,9 @@ watch(
6561
}
6662
);
6763
68-
function getProduct(size, plan = cloudStore.plan) {
69-
const isDynamic = cloudStore.plan.kind === "DYNAMIC";
70-
const products = Object.values(plan.products);
64+
function getProduct(size) {
65+
const isDynamic = plan.value.kind === "DYNAMIC";
66+
const products = Object.values(plan.value.products);
7167
const product = products.find(
7268
({ title, period }) =>
7369
title === size && (getTarification(period) === props.mode || isDynamic)
@@ -80,11 +76,10 @@ async function setProduct(value) {
8076
emits("update:product-size", value);
8177
8278
await nextTick();
83-
const plan = cloudStore.plan;
8479
85-
if (!plan) return;
86-
const resources = getProduct(value, plan) ?? {};
87-
const minDisk = (plan.meta.minDiskSize ?? {})[options.disk.type];
80+
if (!plan.value) return;
81+
const resources = getProduct(value) ?? {};
82+
const minDisk = (plan.value.meta.minDiskSize ?? {})[options.disk.type];
8883
8984
setOptions("cpu.size", resources.cpu ?? 0);
9085
setOptions("ram.size", (resources.ram ?? 0) / 1024);

src/hooks/cloud/plans.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -137,23 +137,25 @@ function useCloudPlans(tarification, options) {
137137

138138
if (cachedPlans.value[cacheKey]) {
139139
plansStore.setPlans(cachedPlans.value[cacheKey]);
140-
141-
const { items } =
142-
showcases.value.find(({ uuid }) => uuid === showcaseId.value) ?? {};
143-
const { plan } =
144-
items?.find((item) => item.locations.includes(locationId.value)) ??
145-
{};
146-
147-
planId.value =
148-
planId.value ?? plan ?? filteredPlans.value[0]?.uuid ?? "";
149140
} else {
150141
const { pool } = await plansStore.fetch({
151142
sp_uuid: provider.uuid,
152143
anonymously: !authStore.isLogged,
153144
});
154145
cachedPlans.value[cacheKey] = pool;
146+
}
147+
148+
const { items } =
149+
showcases.value.find(({ uuid }) => uuid === showcaseId.value) ?? {};
150+
const { plan } =
151+
items?.find((item) => item.locations.includes(locationId.value)) ?? {};
152+
153+
if (
154+
!planId.value ||
155+
!filteredPlans.value.find((p) => planId.value === p.uuid)
156+
) {
155157
planId.value =
156-
planId.value ?? filteredPlans.value[0]?.uuid ?? pool[0]?.uuid ?? "";
158+
plan ?? filteredPlans.value[0]?.uuid ?? planId.value ?? "";
157159
}
158160

159161
await addonsStore.fetch({

0 commit comments

Comments
 (0)