-
Notifications
You must be signed in to change notification settings - Fork 8
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
Enhance networks Component #3344
Draft
MohamedElmdary
wants to merge
20
commits into
development
Choose a base branch
from
development_enhance_networks_input
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 3 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
39cb05d
feat: Add NetworkItem component to make it less complex
MohamedElmdary ffa1dd1
feat: Apply solution to all need solutions
MohamedElmdary d2a40aa
feat: Support has-custom-domain in Networks component
MohamedElmdary b0e953e
chore: update default value for hasCustomDomain to 'false'
MohamedElmdary 66c76e6
chore: Merge branch 'development' into development_enhance_networks_i…
MohamedElmdary 4b619af
feat: Add createNetworks function
MohamedElmdary 7445413
chore: Refactor useNetworks method
MohamedElmdary c2762cd
feat: Use 'useNetworks' in freeflow solution
MohamedElmdary 954d979
feat: Use 'useNetworks' in full_vm solution
MohamedElmdary a9ff88f
feat: Use 'useNetworks' in jenkins solution
MohamedElmdary 8c30abf
feat: Use 'useNetworks' in all solutions
MohamedElmdary 921c8fd
Merge pull request #3352 from threefoldtech/development_enhance_netwo…
MohamedElmdary 30b685a
fix: mark wg input as readonly if domain is needed while use didn't e…
MohamedElmdary ae76920
fix: mark wg input as readonly if domain is needed while use didn't e…
MohamedElmdary a61d2e0
Merge branch 'development' into development_enhance_networks_input
MohamedElmdary 96851d8
chore: Remove has-custom-domain from TfSelectionDetails component
MohamedElmdary 0f0f9c9
chore: turn ipv4 into readonly in caprover
MohamedElmdary 89d323e
merge development
0oM4R a5e7957
chore: jenkins
0oM4R a2eae58
chore: wirguard
0oM4R File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<template> | ||
<input-tooltip v-if="value !== null" inline :tooltip="tooltipText"> | ||
<v-switch | ||
hide-details | ||
color="primary" | ||
inset | ||
:label="label" | ||
:model-value="value" | ||
@update:model-value="callEmitFunction($event ?? false)" | ||
:readonly="readonly" | ||
:style="{ opacity: readonly ? 0.5 : 1 }" | ||
/> | ||
</input-tooltip> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { computed, type PropType } from "vue"; | ||
|
||
export default { | ||
name: "NetworkItem", | ||
props: { | ||
tooltipText: { type: String, required: true }, | ||
label: { type: String, required: true }, | ||
value: Boolean as PropType<boolean | null | undefined>, | ||
emitFunction: Function as PropType<any>, | ||
}, | ||
setup(props) { | ||
const readonly = computed(() => typeof props.emitFunction !== "function"); | ||
function callEmitFunction(value?: boolean): void { | ||
if (typeof props.emitFunction === "function") { | ||
props.emitFunction(value); | ||
} | ||
} | ||
|
||
return { readonly, callEmitFunction }; | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,151 +1,91 @@ | ||
<template> | ||
<div ref="input"> | ||
<input-tooltip tooltip="Enable the network options to be able access your deployment"> | ||
<v-expansion-panels variant="inset" class="mb-4"> | ||
<v-expansion-panel expand-icon="mdi-menu-down" collapse-icon="mdi-menu-up" :disabled="$props.disabled"> | ||
<template v-slot:title> | ||
<span class="text-h6">Network</span> | ||
<v-chip v-if="error" variant="text"> | ||
<v-icon color="warning" icon="mdi-alert-circle" /> | ||
</v-chip> | ||
<v-chip v-if="ipv4" variant="outlined" class="ml-2"> IPV4 </v-chip> | ||
<v-chip v-if="ipv6" variant="outlined" class="ml-2"> IPV6 </v-chip> | ||
<v-chip v-if="planetary" variant="outlined" class="ml-2"> Planetary </v-chip> | ||
<v-chip v-if="mycelium" variant="outlined" class="ml-2"> Mycelium </v-chip> | ||
<v-chip v-if="wireguard" variant="outlined" class="ml-2"> Wireguard </v-chip> | ||
</template> | ||
<v-expansion-panel-text> | ||
<input-tooltip | ||
v-if="ipv4 !== null" | ||
inline | ||
tooltip="An Internet Protocol version 4 address that is globally unique and accessible over the internet." | ||
> | ||
<v-switch | ||
hide-details | ||
color="primary" | ||
inset | ||
label="Public IPv4" | ||
:readonly="enableIpv4" | ||
:model-value="$props.ipv4" | ||
@update:model-value="$emit('update:ipv4', $event ?? undefined)" | ||
:style="enableIpv4 ? 'opacity: .5' : 'opacity: 1'" | ||
/> | ||
</input-tooltip> | ||
<input-tooltip | ||
v-if="ipv6 !== null" | ||
inline | ||
tooltip="Public IPv6 is the next-generation Internet Protocol that offers an expanded address space to connect a vast number of devices." | ||
> | ||
<v-switch | ||
hide-details | ||
color="primary" | ||
inset | ||
label="Public IPv6" | ||
:modelValue="$props.ipv6" | ||
@update:modelValue="$emit('update:ipv6', $event ?? undefined)" | ||
/> | ||
</input-tooltip> | ||
<input-tooltip | ||
v-if="planetary !== null" | ||
inline | ||
tooltip="The Planetary Network is a distributed network infrastructure that spans across multiple regions and countries, providing global connectivity." | ||
> | ||
<v-switch | ||
hide-details | ||
color="primary" | ||
inset | ||
label="Planetary Network" | ||
:modelValue="$props.planetary" | ||
@update:modelValue="$emit('update:planetary', $event ?? undefined)" | ||
/> | ||
</input-tooltip> | ||
<input-tooltip | ||
v-if="mycelium !== null" | ||
inline | ||
tooltip="Mycelium is an IPv6 overlay network. Each node that joins the overlay network will receive an overlay network IP." | ||
> | ||
<v-switch | ||
hide-details | ||
color="primary" | ||
inset | ||
label="mycelium" | ||
:modelValue="$props.mycelium" | ||
@update:modelValue="$emit('update:mycelium', $event ?? undefined)" | ||
/> | ||
</input-tooltip> | ||
<input-tooltip | ||
v-if="wireguard !== null" | ||
inline | ||
tooltip="Enabling WireGuard Access allows you to establish private, secure, and encrypted connections to your instance." | ||
> | ||
<v-switch | ||
hide-details | ||
color="primary" | ||
inset | ||
label="Add Wireguard Access" | ||
:modelValue="$props.wireguard" | ||
@update:modelValue="$emit('update:wireguard', $event ?? undefined)" | ||
/> | ||
</input-tooltip> | ||
<v-alert v-show="error" class="mb-2" type="warning" variant="tonal"> | ||
You must enable at least one of network options. | ||
</v-alert> | ||
</v-expansion-panel-text> | ||
</v-expansion-panel> | ||
</v-expansion-panels> | ||
</input-tooltip> | ||
</div> | ||
<input-tooltip ref="input" tooltip="Enable the network options to be able access your deployment"> | ||
<v-expansion-panels variant="inset" class="mb-4"> | ||
<v-expansion-panel expand-icon="mdi-menu-down" collapse-icon="mdi-menu-up" :disabled="$props.disabled"> | ||
<v-expansion-panel-title> | ||
<v-card-title class="py-0" v-text="'Network'" /> | ||
<v-icon v-if="error" color="warning" icon="mdi-alert-circle" class="ml-2" size="small" /> | ||
<v-chip v-if="ipv4" variant="outlined" class="ml-2" text="IPV4" /> | ||
<v-chip v-if="ipv6" variant="outlined" class="ml-2" text="IPV6" /> | ||
<v-chip v-if="planetary" variant="outlined" class="ml-2" text="Planetary" /> | ||
<v-chip v-if="mycelium" variant="outlined" class="ml-2" text="Mycelium" /> | ||
<v-chip v-if="wireguard" variant="outlined" class="ml-2" text="Wireguard" /> | ||
</v-expansion-panel-title> | ||
|
||
<v-expansion-panel-text> | ||
<NetworkItem | ||
tooltip-text="An Internet Protocol version 4 address that is globally unique and accessible over the internet." | ||
label="Public IPv4" | ||
:value="$props.ipv4" | ||
:emit-function="$attrs['onUpdate:ipv4']" | ||
/> | ||
|
||
<NetworkItem | ||
tooltip-text="Public IPv6 is the next-generation Internet Protocol that offers an expanded address space to connect a vast number of devices." | ||
label="Public IPv6" | ||
:value="$props.ipv6" | ||
:emit-function="$attrs['onUpdate:ipv6']" | ||
/> | ||
|
||
<NetworkItem | ||
tooltip-text="The Planetary Network is a distributed network infrastructure that spans across multiple regions and countries, providing global connectivity." | ||
label="Planetary Network" | ||
:value="$props.planetary" | ||
:emit-function="$attrs['onUpdate:planetary']" | ||
/> | ||
|
||
<NetworkItem | ||
tooltip-text="Mycelium is an IPv6 overlay network. Each node that joins the overlay network will receive an overlay network IP." | ||
label="Mycelium" | ||
:value="$props.mycelium" | ||
:emit-function="$attrs['onUpdate:mycelium']" | ||
/> | ||
|
||
<NetworkItem | ||
tooltip-text="Enabling WireGuard Access allows you to establish private, secure, and encrypted connections to your instance." | ||
label="Add Wireguard Access" | ||
:value="$props.wireguard" | ||
:emit-function="readonlyWireguard ? undefined : $attrs['onUpdate:wireguard']" | ||
/> | ||
|
||
<v-alert | ||
v-if="error" | ||
class="my-2" | ||
type="warning" | ||
variant="tonal" | ||
text="You must enable at least one of network options." | ||
/> | ||
</v-expansion-panel-text> | ||
</v-expansion-panel> | ||
</v-expansion-panels> | ||
</input-tooltip> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { noop } from "lodash"; | ||
import { computed, getCurrentInstance, onMounted, onUnmounted, ref, watch } from "vue"; | ||
import { computed, getCurrentInstance, onMounted, onUnmounted, ref, toRefs, watch } from "vue"; | ||
|
||
import { useForm, ValidatorStatus } from "@/hooks/form_validator"; | ||
import type { InputValidatorService } from "@/hooks/input_validator"; | ||
|
||
import NetworkItem from "./NetworkItem.vue"; | ||
|
||
export default { | ||
name: "Network", | ||
components: { NetworkItem }, | ||
props: { | ||
required: { | ||
type: Boolean, | ||
default: () => false, | ||
}, | ||
ipv4: { | ||
type: Boolean, | ||
default: () => null, | ||
}, | ||
ipv6: { | ||
type: Boolean, | ||
default: () => null, | ||
}, | ||
planetary: { | ||
type: Boolean, | ||
default: () => null, | ||
}, | ||
mycelium: { | ||
type: Boolean, | ||
default: () => null, | ||
}, | ||
wireguard: { | ||
type: Boolean, | ||
default: () => null, | ||
}, | ||
disabled: { type: Boolean }, | ||
enableIpv4: { | ||
type: Boolean, | ||
default: () => null, | ||
}, | ||
}, | ||
emits: { | ||
"update:ipv4": (value?: boolean) => value, | ||
"update:ipv6": (value?: boolean) => value, | ||
"update:planetary": (value?: boolean) => value, | ||
"update:mycelium": (value?: boolean) => value, | ||
"update:wireguard": (value?: boolean) => value, | ||
required: { type: Boolean, default: () => false }, | ||
ipv4: { type: Boolean, default: () => null }, | ||
ipv6: { type: Boolean, default: () => null }, | ||
planetary: { type: Boolean, default: () => null }, | ||
mycelium: { type: Boolean, default: () => null }, | ||
wireguard: { type: Boolean, default: () => null }, | ||
hasCustomDomain: { type: Boolean, default: () => true }, | ||
disabled: Boolean, | ||
}, | ||
setup(props, { expose }) { | ||
setup(props, { attrs }) { | ||
const input = ref(); | ||
const $el = computed(() => input.value?.$el); | ||
|
||
if ( | ||
props.ipv4 === null && | ||
|
@@ -156,11 +96,8 @@ export default { | |
) { | ||
throw new Error("You must provide at least one network option"); | ||
} | ||
const error = computed( | ||
() => !(props.ipv4 || props.ipv6 || props.planetary || props.wireguard || props.mycelium) && props.required, | ||
); | ||
expose({ | ||
error, | ||
const error = computed(() => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is because it's not required but I checked early versions and it wasn't require too should I turn it into required? |
||
return !(props.ipv4 || props.ipv6 || props.planetary || props.wireguard || props.mycelium) && props.required; | ||
}); | ||
|
||
/* Adapter to work with old code validation */ | ||
|
@@ -173,7 +110,7 @@ export default { | |
reset: noop, | ||
status: ValidatorStatus.Valid, | ||
error: null, | ||
$el: input, | ||
$el, | ||
highlightOnError: true, | ||
}; | ||
|
||
|
@@ -185,9 +122,22 @@ export default { | |
form?.updateStatus(uid.toString(), fakeService.status); | ||
}); | ||
|
||
const readonlyWireguard = computed(() => props.hasCustomDomain && !props.ipv4); | ||
MohamedElmdary marked this conversation as resolved.
Show resolved
Hide resolved
|
||
watch( | ||
readonlyWireguard, | ||
readonly => { | ||
const fn = attrs["onUpdate:wireguard"]; | ||
if (readonly && !props.wireguard && typeof fn === "function") { | ||
fn(true); | ||
} | ||
MohamedElmdary marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
{ immediate: true }, | ||
); | ||
|
||
return { | ||
error, | ||
input, | ||
readonlyWireguard, | ||
}; | ||
}, | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on caprover we need the ipv4 to be read only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be fixed