Skip to content

Group all toggles in one component #4161

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3f7cce2
Group all toggles in one component
samaradel May 21, 2025
fa4f269
- Fix type check
samaradel May 21, 2025
760518e
Set default values for props
samaradel May 21, 2025
6204356
Verify passed value type
samaradel May 21, 2025
41d3b58
Avoid inline assignments
samaradel May 21, 2025
f611dfe
Handle null values
samaradel May 21, 2025
2d45b5f
Removed the onUpdated functions
samaradel May 22, 2025
14684ef
Fix types
samaradel May 22, 2025
e5d8373
Get the old changes back
samaradel May 22, 2025
8aa1d50
Move rental switchs component inside selection details component
samaradel May 28, 2025
6080d4b
Merge branch 'development' into dev_toggles_component
samaradel May 28, 2025
33a4aff
Remove the default true value
samaradel Jun 1, 2025
4364f4f
Merge branch 'development' into dev_toggles_component
samaradel Jun 3, 2025
5e9df5d
Remove static showGPU prop
samaradel Jun 3, 2025
7088c08
Fix conflicts
samaradel Jun 4, 2025
0b0a8fc
Fix eslint config file
samaradel Jun 4, 2025
286647e
Merge branch 'development' into dev_toggles_component
samaradel Jun 12, 2025
599346c
lint fix
samaradel Jun 12, 2025
6148f14
Merge branch 'development' into dev_toggles_component
samaradel Jun 12, 2025
29dace4
Remove unrelated changes
samaradel Jun 18, 2025
1b40ce9
Merge branch 'development' into dev_toggles_component
samaradel Jun 18, 2025
236c0f2
Update eslint.config.js
samaradel Jun 18, 2025
2673096
Revert unwanted changes
samaradel Jun 22, 2025
770abe7
Removed the unnecessary handler functions
samaradel Jul 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions packages/playground/src/components/caprover_worker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,12 @@
v-model:mycelium="$props.modelValue.mycelium"
v-model:wireguard="$props.modelValue.wireguard"
/>
<!-- <input-tooltip inline tooltip="" :href="manual"> -->
<v-switch color="primary" inset label="Rented By Me" v-model="$props.modelValue.rentedByMe" hide-details />
<!-- </input-tooltip> -->
<input-tooltip inline tooltip="Click to know more about dedicated machines." :href="manual.dedicated_machines">
<v-switch color="primary" inset label="Rentable" v-model="$props.modelValue.dedicated" hide-details />
</input-tooltip>
<input-tooltip inline tooltip="Renting capacity on certified nodes is charged 25% extra.">
<v-switch color="primary" inset label="Certified" v-model="$props.modelValue.certified" hide-details />
</input-tooltip>

<TfRentalFilterSwitches
v-model:rentedByMe="$props.modelValue.rentedByMe"
v-model:dedicated="$props.modelValue.dedicated"
v-model:certified="$props.modelValue.certified"
/>

<TfSelectionDetails
:selected-machines="selectedMachines"
Expand Down Expand Up @@ -70,8 +67,8 @@ import { computed, type PropType } from "vue";

import { useGrid } from "@/stores";
import type { SelectedMachine } from "@/types/nodeSelector";
import { manual } from "@/utils/manual";

import TfRentalFilterSwitches from "../components/filters/TfRentalFilterSwitches.vue";
import Networks from "../components/networks.vue";
import type { CaproverWorker } from "../types";
import { generateName } from "../utils/strings";
Expand Down Expand Up @@ -107,7 +104,7 @@ function toMachine(rootFilesystemSize: number, worker?: CaproverWorker): Selecte

export default {
name: "CaproverWorker",
components: { SelectSolutionFlavor, Networks },
components: { SelectSolutionFlavor, Networks, TfRentalFilterSwitches },
props: {
modelValue: {
type: Object as PropType<CaproverWorker>,
Expand Down Expand Up @@ -142,7 +139,7 @@ export default {
}, [] as SelectedMachine[]);
});

return { rootFilesystemSize, manual, selectedMachines, rentedBy };
return { rootFilesystemSize, selectedMachines, rentedBy };
},
};
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<template>
<div class="flex flex-col gap-4">
<input-tooltip
v-if="showGPU"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can just remove this v-if condition and remove showGPU prop since it will always be true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same, it's just check for only 2 solutions not the rest

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please refer to replies above

inline
tooltip="
Selecting a Node with GPU.
When selecting a node with GPU resources, please make sure that you have a rented node. To rent a node and gain access to GPU capabilities, you can use our dashboard.
"
>
<v-switch
color="primary"
inset
label="GPU"
:model-value="hasGPUModel"
@update:model-value="onUpdateHasGPU"
hide-details
/>
</input-tooltip>

<v-switch
color="primary"
inset
label="Rented By Me"
:model-value="rentedByMeModel"
@update:model-value="onUpdateRentedByMe"
hide-details
/>

<input-tooltip inline tooltip="Click to know more about dedicated machines." :href="manual?.dedicated_machines">
<v-switch
color="primary"
inset
label="Rentable"
:model-value="dedicatedModel"
@update:model-value="onUpdateDedicated"
hide-details
/>
</input-tooltip>

<input-tooltip inline tooltip="Renting capacity on certified nodes is charged 25% extra.">
<v-switch
color="primary"
inset
label="Certified"
:model-value="certifiedModel"
@update:model-value="onUpdateCertified"
hide-details
/>
</input-tooltip>
</div>
</template>

<script setup lang="ts">
import { computed } from "vue";

import { manual } from "@/utils/manual";

const props = defineProps({
rentedByMe: Boolean,
dedicated: Boolean,
certified: Boolean,
hasGPU: Boolean,
showGPU: { type: Boolean, default: false },
});

const emit = defineEmits(["update:rentedByMe", "update:dedicated", "update:certified", "update:hasGPU"]);

const rentedByMeModel = computed({
get: () => !!props.rentedByMe,
set: val => emit("update:rentedByMe", val),
});

const dedicatedModel = computed({
get: () => !!props.dedicated,
set: val => emit("update:dedicated", val),
});

const certifiedModel = computed({
get: () => !!props.certified,
set: val => emit("update:certified", val),
});

const hasGPUModel = computed({
get: () => !!props.hasGPU,
set: val => emit("update:hasGPU", val),
});

function onUpdateRentedByMe(val: boolean | null) {
rentedByMeModel.value = !!val;
}

function onUpdateDedicated(val: boolean | null) {
dedicatedModel.value = !!val;
}

function onUpdateCertified(val: boolean | null) {
certifiedModel.value = !!val;
}

function onUpdateHasGPU(val: boolean | null) {
hasGPUModel.value = !!val;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think inline change the values in template would be better, Those founciton are not used anywhere else
example :

:model-value="(val)=> gpuModule = val"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did, but it caused type-check errors, let me try adding types there

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@0oM4R I tried it, but it caused the same error I mentioned, so I returned to the previous solution.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  <v-switch
      color="primary"
      inset
      label="Rented By Me"
      :model-value="rentedByMeModel"
      hide-details
      @update:model-value="(val) => rentedByMeModel = !!val"
    />

this works fine with me without any errors

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samaradel please check this comment

</script>

<script lang="ts">
export default {
name: "RentalFilterSwitches",
};
</script>
21 changes: 8 additions & 13 deletions packages/playground/src/components/k8s_worker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,11 @@
v-model.number="$props.modelValue.rootFsSize"
/>

<!-- <input-tooltip inline tooltip="" :href="manual"> -->
<v-switch color="primary" inset label="Rented By Me" v-model="$props.modelValue.rentedByMe" hide-details />
<!-- </input-tooltip> -->
<input-tooltip inline tooltip="Click to know more about dedicated machines." :href="manual.dedicated_machines">
<v-switch color="primary" inset label="Rentable" v-model="$props.modelValue.dedicated" hide-details />
</input-tooltip>

<input-tooltip inline tooltip="Renting capacity on certified nodes is charged 25% extra.">
<v-switch color="primary" inset label="Certified" v-model="$props.modelValue.certified" hide-details />
</input-tooltip>
<TfRentalFilterSwitches
v-model:rentedByMe="$props.modelValue.rentedByMe"
v-model:dedicated="$props.modelValue.dedicated"
v-model:certified="$props.modelValue.certified"
/>

<TfSelectionDetails
:selected-machines="selectedMachines"
Expand Down Expand Up @@ -124,8 +119,8 @@ import { computed, type PropType } from "vue";

import { useGrid } from "@/stores";
import type { SelectedMachine } from "@/types/nodeSelector";
import { manual } from "@/utils/manual";

import TfRentalFilterSwitches from "../components/filters/TfRentalFilterSwitches.vue";
import Networks from "../components/networks.vue";
import type { K8SWorker } from "../types";
import { generateName } from "../utils/strings";
Expand Down Expand Up @@ -167,7 +162,7 @@ function toMachine(worker?: K8SWorker): SelectedMachine | undefined {

export default {
name: "K8SWorker",
components: { RootFsSize, Networks },
components: { RootFsSize, Networks, TfRentalFilterSwitches },
props: {
modelValue: {
type: Object as PropType<K8SWorker>,
Expand All @@ -193,7 +188,7 @@ export default {
}, [] as SelectedMachine[]);
});

return { calculateRootFileSystem, manual, selectedMachines, rentedBy };
return { calculateRootFileSystem, selectedMachines, rentedBy };
},
};
</script>
20 changes: 7 additions & 13 deletions packages/playground/src/weblets/tf_algorand.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,11 @@
</input-tooltip>
</AlgorandCapacity>

<!-- <input-tooltip inline tooltip="" :href="manual"> -->
<v-switch color="primary" inset label="Rented By Me" v-model="rentedByMe" hide-details />
<!-- </input-tooltip> -->
<input-tooltip inline tooltip="Click to know more about dedicated machines." :href="manual.dedicated_machines">
<v-switch color="primary" inset label="Rentable" v-model="dedicated" hide-details />
</input-tooltip>

<input-tooltip inline tooltip="Renting capacity on certified nodes is charged 25% extra.">
<v-switch color="primary" inset label="Certified" v-model="certified" hide-details />
</input-tooltip>
<TfRentalFilterSwitches
v-model:rentedByMe="rentedByMe"
v-model:dedicated="dedicated"
v-model:certified="certified"
/>

<TfSelectionDetails
:filters-validators="{
Expand Down Expand Up @@ -124,8 +119,6 @@
<script lang="ts" setup>
import { computed, type Ref, ref, watch } from "vue";

import { manual } from "@/utils/manual";

import { useLayout } from "../components/weblet_layout.vue";
import { useGrid } from "../stores";
import { type Flist, ProjectName } from "../types";
Expand Down Expand Up @@ -223,6 +216,7 @@ function updateSSHkeyEnv(selectedKeys: string) {
import { FLISTS, type GridClient } from "@threefold/grid_client";

import AlgorandCapacity from "../components/algorand_capacity.vue";
import TfRentalFilterSwitches from "../components/filters/TfRentalFilterSwitches.vue";
import Networks, { useNetworks } from "../components/networks.vue";
import ManageSshDeployemnt from "../components/ssh_keys/ManageSshDeployemnt.vue";
import { deploymentListEnvironments } from "../constants";
Expand All @@ -232,6 +226,6 @@ import { normalizeError } from "../utils/helpers";

export default {
name: "TfAlgorand",
components: { AlgorandCapacity, Networks, ManageSshDeployemnt },
components: { AlgorandCapacity, Networks, ManageSshDeployemnt, TfRentalFilterSwitches },
};
</script>
20 changes: 7 additions & 13 deletions packages/playground/src/weblets/tf_casperlabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,11 @@
require-domain
/>

<!-- <input-tooltip inline tooltip="" :href="manual"> -->
<v-switch color="primary" inset label="Rented By Me" v-model="rentedByMe" hide-details />
<!-- </input-tooltip> -->
<input-tooltip inline tooltip="Click to know more about dedicated machines." :href="manual.dedicated_machines">
<v-switch color="primary" inset label="Rentable" v-model="dedicated" hide-details />
</input-tooltip>

<input-tooltip inline tooltip="Renting capacity on certified nodes is charged 25% extra.">
<v-switch color="primary" inset label="Certified" v-model="certified" hide-details />
</input-tooltip>
<TfRentalFilterSwitches
v-model:rentedByMe="rentedByMe"
v-model:dedicated="dedicated"
v-model:certified="certified"
/>

<TfSelectionDetails
:filters="{
Expand Down Expand Up @@ -95,8 +90,6 @@
import { calculateRootFileSystem, FLISTS, type GridClient } from "@threefold/grid_client";
import { computed, type Ref, ref } from "vue";

import { manual } from "@/utils/manual";

import { useLayout } from "../components/weblet_layout.vue";
import { useGrid, useProfileManager } from "../stores";
import type { Flist, solutionFlavor as SolutionFlavor } from "../types";
Expand Down Expand Up @@ -218,6 +211,7 @@ function updateSSHkeyEnv(selectedKeys: string) {
</script>

<script lang="ts">
import TfRentalFilterSwitches from "../components/filters/TfRentalFilterSwitches.vue";
import Networks, { useNetworks } from "../components/networks.vue";
import SelectSolutionFlavor from "../components/select_solution_flavor.vue";
import ManageSshDeployemnt from "../components/ssh_keys/ManageSshDeployemnt.vue";
Expand All @@ -227,6 +221,6 @@ import { updateGrid } from "../utils/grid";

export default {
name: "TFCasperlabs",
components: { SelectSolutionFlavor, Networks, ManageSshDeployemnt },
components: { SelectSolutionFlavor, Networks, ManageSshDeployemnt, TfRentalFilterSwitches },
};
</script>
19 changes: 7 additions & 12 deletions packages/playground/src/weblets/tf_discourse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,11 @@
:has-smtp="true"
/>

<!-- <input-tooltip inline tooltip="" :href="manual"> -->
<v-switch color="primary" inset label="Rented By Me" v-model="rentedByMe" hide-details />
<!-- </input-tooltip> -->
<input-tooltip inline tooltip="Click to know more about dedicated machines." :href="manual.dedicated_machines">
<v-switch color="primary" inset label="Rentable" v-model="dedicated" hide-details />
</input-tooltip>

<input-tooltip inline tooltip="Renting capacity on certified nodes is charged 25% extra.">
<v-switch color="primary" inset label="Certified" v-model="certified" hide-details />
</input-tooltip>
<TfRentalFilterSwitches
v-model:rentedByMe="rentedByMe"
v-model:dedicated="dedicated"
v-model:certified="certified"
/>

<TfSelectionDetails
:filters="{
Expand Down Expand Up @@ -126,8 +121,6 @@ import { Buffer } from "buffer";
import TweetNACL from "tweetnacl";
import { computed, type Ref, ref, watch } from "vue";

import { manual } from "@/utils/manual";

import { useLayout } from "../components/weblet_layout.vue";
import { useGrid, useProfileManager } from "../stores";
import type { Flist, solutionFlavor as SolutionFlavor } from "../types";
Expand Down Expand Up @@ -279,6 +272,7 @@ watch(
</script>

<script lang="ts">
import TfRentalFilterSwitches from "../components/filters/TfRentalFilterSwitches.vue";
import Networks, { useNetworks } from "../components/networks.vue";
import SelectSolutionFlavor from "../components/select_solution_flavor.vue";
import SmtpServer, { createSMTPServer } from "../components/smtp_server.vue";
Expand All @@ -294,6 +288,7 @@ export default {
SelectSolutionFlavor,
Networks,
ManageSshDeployemnt,
TfRentalFilterSwitches,
},
};
</script>
19 changes: 7 additions & 12 deletions packages/playground/src/weblets/tf_freeflow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,12 @@
:has-custom-domain="selectionDetails?.domain?.enabledCustomDomain"
require-domain
/>
<!-- <input-tooltip inline tooltip="" :href="manual"> -->
<v-switch color="primary" inset label="Rented By Me" v-model="rentedByMe" hide-details />
<!-- </input-tooltip> -->
<input-tooltip inline tooltip="Click to know more about dedicated machines." :href="manual.dedicated_machines">
<v-switch color="primary" inset label="Rentable" v-model="dedicated" hide-details />
</input-tooltip>

<input-tooltip inline tooltip="Renting capacity on certified nodes is charged 25% extra.">
<v-switch color="primary" inset label="Certified" v-model="certified" hide-details />
</input-tooltip>
<TfRentalFilterSwitches
v-model:rentedByMe="rentedByMe"
v-model:dedicated="dedicated"
v-model:certified="certified"
/>

<TfSelectionDetails
:filters="{
Expand Down Expand Up @@ -101,8 +97,6 @@
import { calculateRootFileSystem, FLISTS, type GridClient } from "@threefold/grid_client";
import { computed, onMounted, type Ref, ref } from "vue";

import { manual } from "@/utils/manual";

import { useLayout } from "../components/weblet_layout.vue";
import { useGrid } from "../stores";
import type { Flist, solutionFlavor as SolutionFlavor } from "../types";
Expand Down Expand Up @@ -227,6 +221,7 @@ function updateSSHkeyEnv(selectedKeys: string) {
</script>

<script lang="ts">
import TfRentalFilterSwitches from "../components/filters/TfRentalFilterSwitches.vue";
import Networks, { useNetworks } from "../components/networks.vue";
import SelectSolutionFlavor from "../components/select_solution_flavor.vue";
import ManageSshDeployemnt from "../components/ssh_keys/ManageSshDeployemnt.vue";
Expand All @@ -236,6 +231,6 @@ import { updateGrid } from "../utils/grid";

export default {
name: "TFFreeflow",
components: { SelectSolutionFlavor, Networks, ManageSshDeployemnt },
components: { SelectSolutionFlavor, Networks, ManageSshDeployemnt, TfRentalFilterSwitches },
};
</script>
Loading
Loading