github.com/erda-project/erda-infra@v1.0.9/providers/component-protocol/components/list/operation.go (about) 1 // Copyright (c) 2021 Terminus, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package list 16 17 import ( 18 "github.com/erda-project/erda-infra/providers/component-protocol/components/commodel" 19 "github.com/erda-project/erda-infra/providers/component-protocol/cptype" 20 ) 21 22 const ( 23 // OpListChangePageKey list level 24 OpListChangePageKey = "changePage" 25 26 // OpItemStarKey item level 27 OpItemStarKey = "star" 28 // OpItemClickGotoKey item level 29 OpItemClickGotoKey = "clickGoto" 30 // OpItemClickKey . 31 OpItemClickKey = "click" 32 // OpBatchRowsHandleKey . 33 OpBatchRowsHandleKey = "batchRowsHandle" 34 ) 35 36 // list-level 37 type ( 38 // OpChangePage paging operation data 39 OpChangePage struct { 40 cptype.Operation 41 ServerData OpChangePageServerData `json:"serverData,omitempty"` 42 ClientData OpChangePageClientData `json:"clientData,omitempty"` 43 } 44 45 // OpChangePageServerData server data 46 OpChangePageServerData struct{} 47 48 // OpChangePageClientData data 49 OpChangePageClientData struct { 50 PageNo uint64 `json:"pageNo,omitempty"` 51 PageSize uint64 `json:"pageSize,omitempty"` 52 } 53 ) 54 55 // OpKey . 56 func (o OpChangePage) OpKey() cptype.OperationKey { return OpListChangePageKey } 57 58 type ( 59 // OpItemStar . 60 OpItemStar struct { 61 cptype.Operation 62 ServerData OpItemStarServerData `json:"serverData,omitempty"` 63 ClientData OpItemStarClientData `json:"clientData,omitempty"` 64 } 65 66 // OpItemStarServerData server data 67 OpItemStarServerData struct{} 68 69 // OpItemStarClientData data 70 OpItemStarClientData struct { 71 DataRef *Item `json:"dataRef,omitempty"` 72 } 73 ) 74 75 // OpKey . 76 func (o OpItemStar) OpKey() cptype.OperationKey { return OpItemStarKey } 77 78 type ( 79 // OpItemClickGoto . 80 OpItemClickGoto struct { 81 cptype.Operation 82 ServerData OpItemClickGotoServerData `json:"serverData,omitempty"` 83 ClientData OpItemClickGotoClientData `json:"clientData,omitempty"` 84 } 85 86 // OpItemClickGotoServerData server data 87 OpItemClickGotoServerData struct { 88 OpItemBasicServerData 89 } 90 91 // OpItemClickGotoClientData data 92 OpItemClickGotoClientData struct{} 93 ) 94 95 // OpItemBasicServerData . 96 type OpItemBasicServerData struct { 97 // open a new fronted page 98 JumpOut bool `json:"jumpOut,omitempty"` 99 // the jump out target of the new opened fronted page, e.g: projectAllIssue page 100 Target string `json:"target,omitempty"` 101 // params needed for jumping to the new page, e.g: projectId 102 Params map[string]interface{} `json:"params,omitempty"` 103 // the query condition of the new page, e.g: issueFilter__urlQuery 104 Query map[string]interface{} `json:"query,omitempty"` 105 } 106 107 // OpKey . 108 func (o OpItemClickGoto) OpKey() cptype.OperationKey { return OpItemClickGotoKey } 109 110 type ( 111 // OpItemClick . 112 OpItemClick struct { 113 cptype.Operation 114 ServerData OpItemClickServerData `json:"serverData,omitempty"` 115 ClientData OpItemClickClientData `json:"clientData,omitempty"` 116 } 117 118 // OpItemClickServerData server data 119 OpItemClickServerData struct { 120 OpItemBasicServerData 121 } 122 123 // OpItemClickClientData data 124 OpItemClickClientData struct { 125 DataRef *Item `json:"dataRef,omitempty"` 126 OperationRef MoreOpItem `json:"operationRef"` 127 } 128 ) 129 130 // OpKey . 131 func (o OpItemClick) OpKey() cptype.OperationKey { return OpItemClickKey } 132 133 // OpBatchRowsHandleOptionServerData . 134 type OpBatchRowsHandleOptionServerData struct { 135 // AllowedRowIDs which rows has this op 136 AllowedRowIDs []string `json:"allowedRowIDs"` 137 // Icon . 138 Icon *commodel.Icon `json:"icon"` 139 // ID of this op. 140 ID string `json:"id"` 141 // Text 142 Text string `json:"text"` 143 } 144 145 // OpBatchRowsHandleBasicServerData . 146 type OpBatchRowsHandleBasicServerData struct { 147 Options []OpBatchRowsHandleOptionServerData 148 } 149 type ( 150 // OpBatchRowsHandle . 151 OpBatchRowsHandle struct { 152 cptype.Operation 153 ServerData OpBatchRowsHandleServerData `json:"serverData,omitempty"` 154 ClientData OpBatchRowsHandleClientData `json:"clientData,omitempty"` 155 } 156 157 // OpBatchRowsHandleServerData server data 158 OpBatchRowsHandleServerData struct { 159 OpBatchRowsHandleBasicServerData 160 } 161 162 // OpBatchRowsHandleClientData data 163 OpBatchRowsHandleClientData struct { 164 DataRef *Item `json:"dataRef,omitempty"` 165 SelectedOptionsID string `json:"selectedOptionsID"` 166 SelectedRowIDs []string `json:"selectedRowIDs"` 167 } 168 ) 169 170 // OpKey . 171 func (o OpBatchRowsHandle) OpKey() cptype.OperationKey { return OpBatchRowsHandleKey }