Skip to content

Commit

Permalink
Supplement required markups for required fields (#706)
Browse files Browse the repository at this point in the history
  • Loading branch information
powerfooI authored Jan 9, 2025
1 parent bf11911 commit badd20b
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 38 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ui-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ jobs:
run: cd ui && yarn check-style
- name: Lint
run: cd ui && yarn lint
- name: build
run: cd ui && yarn build
9 changes: 5 additions & 4 deletions internal/dashboard/business/oceanbase/obcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,11 @@ func buildOBClusterTopology(topology []param.ZoneTopology) []apitypes.OBZoneTopo
topo.Tolerations = make([]corev1.Toleration, 0)
for _, kv := range zone.Tolerations {
toleration := corev1.Toleration{
Key: kv.Key,
Operator: corev1.TolerationOpEqual,
Value: kv.Value,
Effect: corev1.TaintEffectNoSchedule,
Key: kv.Key,
Operator: corev1.TolerationOperator(kv.Operator),
Value: kv.Value,
Effect: corev1.TaintEffect(kv.Effect),
TolerationSeconds: kv.TolerationSeconds,
}
topo.Tolerations = append(topo.Tolerations, toleration)
}
Expand Down
23 changes: 13 additions & 10 deletions internal/dashboard/model/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ See the Mulan PSL v2 for more details.
package common

type KVPair struct {
Key string `json:"key"`
Value string `json:"value"`
Key string `json:"key" binding:"required"`
Value string `json:"value" binding:"required"`
}

type ResourceSpec struct {
Cpu int64 `json:"cpu"`
MemoryGB int64 `json:"memory"`
Cpu int64 `json:"cpu" binding:"required"`
MemoryGB int64 `json:"memory" binding:"required"`
}

type StorageSpec struct {
Expand All @@ -28,8 +28,9 @@ type StorageSpec struct {
}

type SelectorExpression struct {
Key string `json:"key"`
Operator string `json:"operator,omitempty"`
Key string `json:"key" binding:"required"`
// Enum: In, NotIn, Exists, DoesNotExist
Operator string `json:"operator,omitempty" binding:"required"`
Values []string `json:"values,omitempty"`
}

Expand All @@ -38,15 +39,17 @@ type AffinityType string
type AffinitySpec struct {
SelectorExpression `json:",inline"`
// Enum: NODE, POD, POD_ANTI
Type AffinityType `json:"type"`
Type AffinityType `json:"type" binding:"required"`
Weight int32 `json:"weight,omitempty"`
Preferred bool `json:"preferred,omitempty"`
}

type TolerationSpec struct {
KVPair `json:",inline"`
Operator string `json:"operator"`
Effect string `json:"effect"`
KVPair `json:",inline"`
// Enum: Exists, Equal
Operator string `json:"operator" binding:"required"`
// Enum: PreferNoSchedule, NoSchedule, NoExecute
Effect string `json:"effect" binding:"required"`
TolerationSeconds *int64 `json:"tolerationSeconds,omitempty"`
}

Expand Down
40 changes: 20 additions & 20 deletions internal/dashboard/model/param/obcluster_param.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,32 @@ import (
)

type ZoneTopology struct {
Zone string `json:"zone"`
Replicas int `json:"replicas"`
Zone string `json:"zone" binding:"required"`
Replicas int `json:"replicas" binding:"required"`
NodeSelector []common.KVPair `json:"nodeSelector,omitempty"`
Tolerations []common.TolerationSpec `json:"tolerations,omitempty"`
Affinities []common.AffinitySpec `json:"affinities,omitempty"`
}

type OBServerStorageSpec struct {
Data common.StorageSpec `json:"data"`
RedoLog common.StorageSpec `json:"redoLog"`
Log common.StorageSpec `json:"log"`
Data common.StorageSpec `json:"data" binding:"required"`
RedoLog common.StorageSpec `json:"redoLog" binding:"required"`
Log common.StorageSpec `json:"log" binding:"required"`
}

type MonitorStorageSpec struct {
Config common.StorageSpec `json:"config"`
}

type OBServerSpec struct {
Image string `json:"image"`
Resource common.ResourceSpec `json:"resource"`
Storage *OBServerStorageSpec `json:"storage"`
Image string `json:"image" binding:"required"`
Resource common.ResourceSpec `json:"resource" binding:"required"`
Storage *OBServerStorageSpec `json:"storage" binding:"required"`
}

type MonitorSpec struct {
Image string `json:"image"`
Resource common.ResourceSpec `json:"resource"`
Image string `json:"image" binding:"required"`
Resource common.ResourceSpec `json:"resource" binding:"required"`
}

type NFSVolumeSpec struct {
Expand All @@ -52,30 +52,30 @@ type NFSVolumeSpec struct {
}

type CreateOBClusterParam struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
ClusterName string `json:"clusterName"`
ClusterId int64 `json:"clusterId"`
RootPassword string `json:"rootPassword"`
Namespace string `json:"namespace" binding:"required"`
Name string `json:"name" binding:"required"`
ClusterName string `json:"clusterName" binding:"required"`
ClusterId int64 `json:"clusterId" binding:"required"`
RootPassword string `json:"rootPassword" binding:"required"`
Topology []ZoneTopology `json:"topology"`
OBServer *OBServerSpec `json:"observer"`
OBServer *OBServerSpec `json:"observer" binding:"required"`
Monitor *MonitorSpec `json:"monitor"`
Parameters []common.KVPair `json:"parameters"`
BackupVolume *NFSVolumeSpec `json:"backupVolume"`
Mode common.ClusterMode `json:"mode"`
Mode common.ClusterMode `json:"mode" binding:"required"`

// Enum: express_oltp, express_oltp, olap, kv, htap, express_oltp_perf
Scenario string `json:"scenario"`
Scenario string `json:"scenario" binding:"required"`
DeletionProtection bool `json:"deletionProtection"`
PvcIndependent bool `json:"pvcIndependent"`
}

type UpgradeOBClusterParam struct {
Image string `json:"image"`
Image string `json:"image" binding:"required"`
}

type ScaleOBServerParam struct {
Replicas int `json:"replicas"`
Replicas int `json:"replicas" binding:"required"`
}

type K8sObjectIdentity struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/dashboard/model/param/obtenant_param.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type CreateOBTenantParam struct {
Source *TenantSourceSpec `json:"source,omitempty"`

// Enum: express_oltp, express_oltp, olap, kv, htap, express_oltp_perf
Scenario string `json:"scenario"`
Scenario string `json:"scenario" binding:"required"`
DeletionProtection bool `json:"deletionProtection"`
Parameters []common.KVPair `json:"parameters"`
Variables []common.KVPair `json:"variables"`
Expand Down
15 changes: 12 additions & 3 deletions ui/src/pages/Cluster/Detail/Overview/BasicInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,16 @@ const nodeSelectorColumns: ColumnsType<ExtendedAffinity> = [
{
title: 'Values',
dataIndex: 'values',
render(value: string[] | undefined) {
return value?.join(', ') || '-';
},
},
{
title: 'Weight',
dataIndex: 'weight',
render(value: number | undefined) {
return value || '-';
},
},
];

Expand Down Expand Up @@ -78,6 +84,9 @@ const tolerationColumns: ColumnsType<ExtendedToleration> = [
{
title: 'Value',
dataIndex: 'value',
render(value: string | undefined) {
return value || '-';
},
},
{
title: 'Effect',
Expand Down Expand Up @@ -308,7 +317,7 @@ export default function BasicInfo({
</Title>
{topologyRendering.nodeSelectors.length > 0 && (
<>
<Text style={{ marginBottom: 8, display: 'block' }}>
<Text style={{ marginBottom: 8, marginTop: 8, display: 'block' }}>
Node Selector
</Text>
<Table
Expand All @@ -323,7 +332,7 @@ export default function BasicInfo({
)}
{topologyRendering.affinities.length > 0 && (
<>
<Text style={{ marginBottom: 8, display: 'block' }}>
<Text style={{ marginBottom: 8, marginTop: 8, display: 'block' }}>
Pod Affinity
</Text>
<Table
Expand All @@ -338,7 +347,7 @@ export default function BasicInfo({
)}
{topologyRendering.tolerations.length > 0 && (
<>
<Text style={{ marginBottom: 8, display: 'block' }}>
<Text style={{ marginBottom: 8, marginTop: 8, display: 'block' }}>
Tolerations
</Text>
<Table
Expand Down

0 comments on commit badd20b

Please sign in to comment.