Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
2eha0 committed Dec 27, 2024
1 parent 40f73b0 commit ed16e19
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<FieldArrayCardContainer
v-for="(node, index) of nodes"
:key="`${index}`"
:disabled="readonly"
@remove-item="removeItem(index)"
>
<div class="cluster-node-items">
Expand All @@ -20,6 +21,7 @@
info: t('form.fields.cluster_node_ip.tooltip'),
tooltipAttributes: { maxWidth: '400' },
}"
:readonly="readonly"
required
/>
<KInput
Expand All @@ -29,12 +31,14 @@
info: t('form.fields.cluster_node_port.tooltip'),
tooltipAttributes: { maxWidth: '400' },
}"
:readonly="readonly"
type="number"
/>
</div>
</FieldArrayCardContainer>
<KButton
appearance="tertiary"
:disabled="readonly"
@click="addItem"
>
<AddCircleIcon />
Expand All @@ -52,6 +56,10 @@ import composables from '../composables'
import type { ClusterNode, Identifiable } from '../types'
import { genDefaultClusterNode } from '../helpers'
defineProps<{
readonly?: boolean
}>()
const nodes = defineModel<Identifiable<ClusterNode>[]>({ required: true })
const { i18n: { t } } = composables.useI18n()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<KButton
appearance="tertiary"
class="array-card-remove-button"
:disabled="disabled"
@click="$emit('remove-item')"
>
<TrashIcon />
Expand All @@ -30,6 +31,10 @@ defineProps({
type: Number,
default: undefined,
},
disabled: {
type: Boolean,
default: false,
},
})
defineEmits<{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
>
<KSelect
v-model="form.fields.mode"
:disabled="isEdit"
:items="typeOptions"
:label="t('form.fields.type.label')"
:readonly="form.readonly"
required
>
<template #selected-item-template="{ item }">
Expand All @@ -39,6 +41,7 @@
v-model.trim="form.fields.name"
:label="t('form.fields.name.label')"
:placeholder="t('form.fields.name.placeholder')"
:readonly="form.readonly"
required
/>
</EntityFormSection>
Expand All @@ -55,6 +58,7 @@
info: t('form.fields.sentinel_master.tooltip'),
tooltipAttributes: { maxWidth: '400' },
}"
:readonly="form.readonly"
/>
<KSelect
v-model="form.fields.sentinel_role"
Expand All @@ -64,18 +68,24 @@
info: t('form.fields.sentinel_role.tooltip'),
tooltipAttributes: { maxWidth: '400' },
}"
:readonly="form.readonly"
/>
<SentinelNodes
v-model="form.fields.sentinel_nodes"
:readonly="form.readonly"
/>
<SentinelNodes v-model="form.fields.sentinel_nodes" />
<KInput
v-model.trim="form.fields.sentinel_username"
:label="t('form.fields.sentinel_username.label')"
:label-attributes="{
info: t('form.fields.sentinel_username.tooltip'),
tooltipAttributes: { maxWidth: '400' },
}"
:readonly="form.readonly"
/>
<VaultSecretPickerProvider
class="secret-picker-provider"
:disabled="form.readonly"
:update="v => form.fields.sentinel_username = v"
:value="form.fields.sentinel_username"
@open="(value, update) => setUpVaultSecretPicker(value, update)"
Expand All @@ -87,10 +97,12 @@
info: t('form.fields.sentinel_password.tooltip'),
tooltipAttributes: { maxWidth: '400' },
}"
:readonly="form.readonly"
type="password"
/>
<VaultSecretPickerProvider
class="secret-picker-provider"
:disabled="form.readonly"
:update="v => form.fields.sentinel_password = v"
:value="form.fields.sentinel_password"
@open="(value, update) => setUpVaultSecretPicker(value, update)"
Expand All @@ -102,14 +114,18 @@
:description="t('form.sections.cluster.description')"
:title="t('form.sections.cluster.title')"
>
<ClusterNodes v-model="form.fields.cluster_nodes" />
<ClusterNodes
v-model="form.fields.cluster_nodes"
:readonly="form.readonly"
/>
<KInput
v-model="form.fields.cluster_max_redirections"
:label="t('form.fields.cluster_max_redirections.label')"
:label-attributes="{
info: t('form.fields.cluster_max_redirections.tooltip'),
tooltipAttributes: { maxWidth: '400' },
}"
:readonly="form.readonly"
type="number"
/>
</EntityFormSection>
Expand All @@ -126,7 +142,7 @@
info: t('form.fields.host.tooltip'),
tooltipAttributes: { maxWidth: '400' },
}"
required
:readonly="form.readonly"
/>
<KInput
v-if="form.fields.mode === Mode.HOST_PORT_OPEN_SOURCE || form.fields.mode === Mode.HOST_PORT_ENTERPRISE"
Expand All @@ -136,12 +152,14 @@
info: t('form.fields.port.tooltip'),
tooltipAttributes: { maxWidth: '400' },
}"
:readonly="form.readonly"
type="number"
/>

<KCheckbox
v-if="form.fields.mode === Mode.HOST_PORT_ENTERPRISE"
v-model="form.fields.connection_is_proxied"
:disabled="form.readonly"
:label="t('form.fields.connection_is_proxied.label')"
:label-attributes="{
info: t('form.fields.connection_is_proxied.tooltip'),
Expand All @@ -157,6 +175,7 @@
info: t('form.fields.timeout.tooltip'),
tooltipAttributes: { maxWidth: '400' },
}"
:readonly="form.readonly"
type="number"
/>

Expand All @@ -167,6 +186,7 @@
info: t('form.fields.database.tooltip'),
tooltipAttributes: { maxWidth: '400' },
}"
:readonly="form.readonly"
type="number"
/>
<KInput
Expand All @@ -176,9 +196,11 @@
info: t('form.fields.username.tooltip'),
tooltipAttributes: { maxWidth: '400' },
}"
:readonly="form.readonly"
/>
<VaultSecretPickerProvider
class="secret-picker-provider"
:disabled="form.readonly"
:update="v => form.fields.username = v"
:value="form.fields.username"
@open="(value, update) => setUpVaultSecretPicker(value, update)"
Expand All @@ -190,10 +212,12 @@
info: t('form.fields.password.tooltip'),
tooltipAttributes: { maxWidth: '400' },
}"
:readonly="form.readonly"
type="password"
/>
<VaultSecretPickerProvider
class="secret-picker-provider"
:disabled="form.readonly"
:update="v => form.fields.password = v"
:value="form.fields.password"
@open="(value, update) => setUpVaultSecretPicker(value, update)"
Expand All @@ -207,11 +231,13 @@
<KCheckbox
v-model="form.fields.ssl"
:description="t('form.fields.ssl.description')"
:disabled="form.readonly"
:label="t('form.fields.ssl.label')"
/>
<KCheckbox
v-model="form.fields.ssl_verify"
:description="t('form.fields.ssl_verify.description')"
:disabled="form.readonly"
:label="t('form.fields.ssl_verify.label')"
/>
<KInput
Expand All @@ -221,6 +247,7 @@
info: t('form.fields.server_name.tooltip'),
tooltipAttributes: { maxWidth: '400' },
}"
:readonly="form.readonly"
/>
</EntityFormSection>

Expand All @@ -236,6 +263,7 @@
info: t('form.fields.keepalive_backlog.tooltip'),
tooltipAttributes: { maxWidth: '400' },
}"
:readonly="form.readonly"
type="number"
/>
<KInput
Expand All @@ -245,6 +273,7 @@
info: t('form.fields.keepalive_pool_size.tooltip'),
tooltipAttributes: { maxWidth: '400' },
}"
:readonly="form.readonly"
type="number"
/>
</EntityFormSection>
Expand All @@ -257,16 +286,19 @@
<KInput
v-model="form.fields.read_timeout"
:label="t('form.fields.read_timeout.label')"
:readonly="form.readonly"
type="number"
/>
<KInput
v-model="form.fields.send_timeout"
:label="t('form.fields.send_timeout.label')"
:readonly="form.readonly"
type="number"
/>
<KInput
v-model="form.fields.connect_timeout"
:label="t('form.fields.connect_timeout.label')"
:readonly="form.readonly"
type="number"
/>
</EntityFormSection>
Expand Down Expand Up @@ -357,7 +389,10 @@ const {
form,
canSubmit,
payload,
} = useRedisConfigurationForm()
isEdit,
} = useRedisConfigurationForm({
partialId: props.partialId,
})
</script>

<style lang="scss" scoped>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<FieldArrayCardContainer
v-for="(node, index) of nodes"
:key="node.id"
:disabled="readonly"
@remove-item="removeItem(index)"
>
<div class="sentinel-node-items">
Expand All @@ -20,6 +21,7 @@
info: t('form.fields.sentinel_node_host.tooltip'),
tooltipAttributes: { maxWidth: '400' },
}"
:readonly="readonly"
required
/>
<KInput
Expand All @@ -29,12 +31,14 @@
info: t('form.fields.sentinel_node_port.tooltip'),
tooltipAttributes: { maxWidth: '400' },
}"
:readonly="readonly"
type="number"
/>
</div>
</FieldArrayCardContainer>
<KButton
appearance="tertiary"
:disabled="readonly"
@click="addItem"
>
<AddCircleIcon />
Expand All @@ -52,6 +56,10 @@ import composables from '../composables'
import type { Identifiable, SentinelNode } from '../types'
import { genDefaultSentinelNode } from '../helpers'
defineProps<{
readonly?: boolean
}>()
const nodes = defineModel<Identifiable<SentinelNode>[]>({ required: true })
const { i18n: { t } } = composables.useI18n()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import { shallowCopyWithoutId } from '../helpers'

import type { RedisConfigurationFormState } from '../types'

export const useRedisConfigurationForm = () => {
export type Options = {
partialId?: string
}

export const useRedisConfigurationForm = (options: Options) => {
const { partialId } = options
const isEdit = !!partialId
const form = reactive<RedisConfigurationFormState>({
fields: {
name: '',
Expand Down Expand Up @@ -139,5 +145,6 @@ export const useRedisConfigurationForm = () => {
form,
canSubmit,
payload,
isEdit,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"tooltip": "Sentinel password to authenticate with a Redis Sentinel instance. If undefined, no AUTH commands are sent to Redis Sentinels."
},
"cluster_node_ip": {
"label": "Ip",
"label": "IP",
"tooltip": "A string representing a host name, such as example.com."
},
"cluster_node_port": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
>
<template #cta>
<span
class="vault-secret-picker-provider-action"
@click="() => emit('open', props.value, props.update)"
:class="{ 'vault-secret-picker-provider-action': true, 'disabled': props.disabled }"
@click="() => !props.disabled && emit('open', props.value, props.update)"
>
{{ t('vault_secret_picker.provider.cta') }}
</span>
Expand All @@ -21,6 +21,7 @@ import composables from '../composables'
type Props = {
value: string
disabled?: boolean
update: (value: string) => void
}
Expand All @@ -41,6 +42,11 @@ const { i18n: { t }, i18nT } = composables.useI18n()
&-action {
color: $kui-color-text-primary;
cursor: pointer;
&.disabled {
color: $kui-color-text-disabled;
cursor: not-allowed;
}
}
}
</style>

0 comments on commit ed16e19

Please sign in to comment.