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

Draft
wants to merge 9 commits into
base: development
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
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"
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),
});
Comment on lines +74 to +77
Copy link
Contributor

Choose a reason for hiding this comment

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

👏 its greate to use writable computed here thank you ya Samar


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;
}
Comment on lines +89 to +103
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.

</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