/
model.go
168 lines (143 loc) · 5.38 KB
/
model.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// Copyright (c) 2021 Terminus, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package inParamsForm
import (
"github.com/erda-project/erda/apistructs"
protocol "github.com/erda-project/erda/modules/openapi/component-protocol"
)
type ComponentInParamsForm struct {
ctxBdl protocol.ContextBundle
CommonInParamsForm
}
type CommonInParamsForm struct {
Version string `json:"version,omitempty"`
Name string `json:"name,omitempty"`
Type string `json:"type,omitempty"`
Props map[string]interface{} `json:"props,omitempty"`
State State `json:"state,omitempty"`
Operations map[string]interface{} `json:"operations,omitempty"`
Data Data `json:"data,omitempty"`
InParams InParams `json:"inParams,omitempty"`
}
type Data struct {
List []ParamData `json:"list"`
}
type ParamData struct {
ParamsName string `json:"name"`
Desc string `json:"description"`
DefaultValue string `json:"value"`
Value string `json:"temp"`
ID uint64 `json:"id"`
Operations map[string]interface{} `json:"operations"`
}
type InParams struct {
SceneSetID uint64 `json:"sceneSetId__urlQuery"`
SpaceId uint64 `json:"spaceId"`
}
type PropColumn struct {
Title string `json:"title"`
Key PropsKey `json:"key"`
Width int64 `json:"width"`
Flex int64 `json:"flex"`
Render PropRender `json:"render"`
TitleTip string `json:"titleTip,omitempty"`
}
type PropRender struct {
Type string `json:"type,omitempty"`
ValueConvertType string `json:"valueConvertType,omitempty"`
Options []PropChangeOption `json:"options,omitempty"`
Required bool `json:"required,omitempty"`
UniqueValue bool `json:"uniqueValue,omitempty"`
Operations map[string]interface{} `json:"operations,omitempty"`
Rules []PropRenderRule `json:"rules,omitempty"`
Props PropRenderProp `json:"props,omitempty"`
}
type PropRenderProp struct {
MaxLength int64 `json:"maxLength,omitempty"`
Placeholder string `json:"placeholder,omitempty"`
Options []PropChangeOption `json:"options,omitempty"`
}
type PropRenderRule struct {
Pattern string `json:"pattern,omitempty"`
Msg string `json:"msg,omitempty"`
}
type PropChangeOption struct {
Label string `json:"label"`
Value string `json:"value"`
IsLeaf bool `json:"isLeaf"`
ToolTip string `json:"tooltip"`
Children []PropChangeOption `json:"children"`
}
func (pct *PropChangeOption) FindValue(v string) *PropChangeOption {
if pct.Value == v {
return pct
}
for i := range pct.Children {
k := pct.Children[i].FindValue(v)
if k != nil {
return k
}
}
return nil
}
type PropsKey string
const (
PropsKeyParamsName PropsKey = "name"
PropsKeyDesc PropsKey = "description"
PropsKeyDefaultValue PropsKey = "value"
PropsKeyValue PropsKey = "temp"
)
type OptionValue string
func (ov OptionValue) String() string {
return string(ov)
}
const (
BeforeSceneOutPutOptionValue OptionValue = "beforeSceneOutPut" // 前置场景出参
SceneOptionValue OptionValue = "scene" // 场景 X
refSceneSetOptionValue OptionValue = "refSceneSet" // 引用场景集
SceneOutPutOptionValue OptionValue = "sceneOutPut" // 场景出参 X
MockOptionValue OptionValue = "mock" // MOCK
MockValueOptionValue OptionValue = "mockValue" // MOCK值
GlobalOptionValue OptionValue = "global" // 全局参数
GlobalValueOptionValue OptionValue = "globalValue" // 全局参数环境
GlobalGlobalOptionValue OptionValue = "globalGlobal" // 全局参数环境Global
)
type State struct {
AutotestSceneRequest apistructs.AutotestSceneRequest `json:"autotestSceneRequest"`
List []apistructs.AutoTestSceneInput `json:"list"`
SceneId uint64 `json:"sceneId"`
SetId uint64 `json:"setId"`
}
type OperationBaseInfo struct {
Key string `json:"key"`
// 操作展示名称
Text string `json:"text,omitempty"`
// 确认提示
Confirm string `json:"confirm,omitempty"`
// 前端操作是否需要触发后端
Reload bool `json:"reload"`
Disabled bool `json:"disabled"`
DisabledTip string `json:"disabledTip"`
FillMeta string `json:"fillMeta"`
}
type OpMetaInfo struct {
apistructs.AutotestSceneRequest
SelectOption []PropChangeOption `json:"selectOption"`
}
type OperationInfo struct {
OperationBaseInfo
Meta OpMetaInfo `json:"meta"`
}
type DeleteOperation OperationInfo
type OnSelectOperation OperationInfo