github.com/erda-project/erda-infra@v1.0.9/providers/component-protocol/components/cardlist/impl/default.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 impl
    16  
    17  import (
    18  	"github.com/erda-project/erda-infra/providers/component-protocol/components/cardlist"
    19  	"github.com/erda-project/erda-infra/providers/component-protocol/components/defaults"
    20  	"github.com/erda-project/erda-infra/providers/component-protocol/cptype"
    21  	"github.com/erda-project/erda-infra/providers/component-protocol/utils/cputil"
    22  )
    23  
    24  // DefaultCard .
    25  type DefaultCard struct {
    26  	defaults.DefaultImpl
    27  	Impl cardlist.ICard
    28  
    29  	*StdStructuredPtr
    30  }
    31  
    32  // StdStructuredPtr .
    33  type StdStructuredPtr struct {
    34  	StdInParamsPtr *cptype.ExtraMap
    35  	StdDataPtr     *cardlist.Data
    36  	StdStatePtr    *cptype.ExtraMap
    37  }
    38  
    39  // DataPtr .
    40  func (s *StdStructuredPtr) DataPtr() interface{} { return s.StdDataPtr }
    41  
    42  // StatePtr .
    43  func (s *StdStructuredPtr) StatePtr() interface{} { return s.StdStatePtr }
    44  
    45  // InParamsPtr .
    46  func (s *StdStructuredPtr) InParamsPtr() interface{} { return s.StdInParamsPtr }
    47  
    48  // RegisterCompStdOps .
    49  func (d *DefaultCard) RegisterCompStdOps() (opFuncs map[cptype.OperationKey]cptype.OperationFunc) {
    50  	return map[cptype.OperationKey]cptype.OperationFunc{
    51  		cardlist.OpCardListStar{}.OpKey(): func(sdk *cptype.SDK) cptype.IStdStructuredPtr {
    52  			return d.Impl.RegisterCardListStarOp(*cputil.MustObjJSONTransfer(sdk.Event.OperationData, &cardlist.OpCardListStar{}).(*cardlist.OpCardListStar))(sdk)
    53  		},
    54  	}
    55  }
    56  
    57  // RegisterCompNonStdOps .
    58  func (d *DefaultCard) RegisterCompNonStdOps() (opFuncs map[cptype.OperationKey]cptype.OperationFunc) {
    59  	return nil
    60  }
    61  
    62  // Initialize .
    63  func (d *DefaultCard) Initialize(sdk *cptype.SDK) {}
    64  
    65  // Finalize .
    66  func (d *DefaultCard) Finalize(sdk *cptype.SDK) {}
    67  
    68  // SkipOp providers default impl for user.
    69  func (d *DefaultCard) SkipOp(sdk *cptype.SDK) bool { return !d.Impl.Visible(sdk) }
    70  
    71  // BeforeHandleOp providers default impl for user.
    72  func (d *DefaultCard) BeforeHandleOp(sdk *cptype.SDK) {}
    73  
    74  // AfterHandleOp providers default impl for user.
    75  func (d *DefaultCard) AfterHandleOp(sdk *cptype.SDK) {}
    76  
    77  // StdStructuredPtrCreator .
    78  func (d *DefaultCard) StdStructuredPtrCreator() func() cptype.IStdStructuredPtr {
    79  	return func() cptype.IStdStructuredPtr {
    80  		return &StdStructuredPtr{
    81  			StdInParamsPtr: &cptype.ExtraMap{},
    82  			StdStatePtr:    &cptype.ExtraMap{},
    83  			StdDataPtr:     &cardlist.Data{},
    84  		}
    85  	}
    86  }
    87  
    88  // Visible .
    89  func (d *DefaultCard) Visible(sdk *cptype.SDK) bool { return true }