github.com/erda-project/erda-infra@v1.0.9/providers/component-protocol/components/commodel/dropdownmenu.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 commodel
    16  
    17  import (
    18  	"github.com/erda-project/erda-infra/providers/component-protocol/cptype"
    19  )
    20  
    21  // DropDownMenu .
    22  type DropDownMenu struct {
    23  	Menus []DropDownMenuItem `json:"menus,omitempty"`
    24  
    25  	Operations map[cptype.OperationKey]cptype.Operation `json:"operations,omitempty"`
    26  }
    27  
    28  // DropDownMenuItem .
    29  type DropDownMenuItem struct {
    30  	ID   string `json:"id,omitempty"`
    31  	Text string `json:"text,omitempty"`
    32  
    33  	Icon          *Icon         `json:"icon,omitempty"`
    34  	UnifiedStatus UnifiedStatus `json:"unifiedStatus,omitempty"`
    35  
    36  	Selected bool   `json:"selected,omitempty"`
    37  	Disabled bool   `json:"disabled,omitempty"`
    38  	Hidden   bool   `json:"hidden,omitempty"`
    39  	Tip      string `json:"tip,omitempty"`
    40  }
    41  
    42  type (
    43  	// OpDropDownMenuChange .
    44  	OpDropDownMenuChange struct {
    45  		cptype.Operation
    46  		ServerData OpDropDownMenuChangeServerData `json:"serverData,omitempty"`
    47  		ClientData OpDropDownMenuChangeClientData `json:"clientData,omitempty"`
    48  	}
    49  	// OpDropDownMenuChangeServerData .
    50  	OpDropDownMenuChangeServerData struct{}
    51  	// OpDropDownMenuChangeClientData .
    52  	OpDropDownMenuChangeClientData struct {
    53  		DataRef        *DropDownMenuItem `json:"dataRef,omitempty"`
    54  		SelectedItemID string            `json:"selectedItemID,omitempty"`
    55  	}
    56  )
    57  
    58  // OpKey .
    59  func (o OpDropDownMenuChange) OpKey() cptype.OperationKey { return "dropDownMenuChange" }
    60  
    61  // ModelType .
    62  func (m DropDownMenu) ModelType() string { return "dropDownMenu" }