diff --git a/internal/cmd/extensions/apply.go b/internal/cmd/extensions/apply.go index be2a49d7..a605d560 100644 --- a/internal/cmd/extensions/apply.go +++ b/internal/cmd/extensions/apply.go @@ -60,8 +60,8 @@ If an extension-id is found an updated is performed, if not instead a new extens extensionData.ExtensionID = o.EntityID } - if extensionData.ExtensionType == "" { - extensionData.ExtensionType = IFrameExtensionType + if extensionData.Type == "" { + extensionData.Type = IFrameExtensionType } extensibilityClient := New(client) diff --git a/internal/cmd/extensions/apply_test.go b/internal/cmd/extensions/apply_test.go index 4a808972..31086df0 100644 --- a/internal/cmd/extensions/apply_test.go +++ b/internal/cmd/extensions/apply_test.go @@ -23,26 +23,27 @@ import ( ) func TestReadExtensionFromFile(t *testing.T) { - order := 200.0 + var order extensibility.Order = 200.0 expectedRecord := &extensibility.Extension{ - Name: "Extension 1", - Description: "My extension 1", - Entry: "https://example.com/", - Contexts: []string{"project"}, - Routes: []*extensibility.ExtensionRoute{ - { - ID: "extension-1", - ParentID: "workloads", - LocationID: "runtime", - LabelIntl: map[string]string{ - "en": "SomeLabel", - "it": "SomeLabelInItalian", - }, - DestinationPath: "/", - RenderType: "menu", - Order: &order, - Icon: &extensibility.Icon{Name: "PiHardDrives"}, + Name: "Extension 1", + Description: "My extension 1", + Entry: "https://example.com/", + ActivationContexts: []extensibility.Context{"project"}, + Destination: extensibility.DestinationArea{ + ID: "runtime", + Path: "/", + }, + IconName: "PiHardDrives", + Menu: extensibility.Menu{ + ID: "extension-1", + LabelIntl: extensibility.IntlMessages{ + extensibility.En: "SomeLabel", + extensibility.It: "SomeLabelInItalian", }, + Order: &order, + }, + Category: &extensibility.Category{ + ID: "workloads", }, } diff --git a/internal/cmd/extensions/testdata/valid-extension.json b/internal/cmd/extensions/testdata/valid-extension.json index 61e1b040..63e12d9e 100644 --- a/internal/cmd/extensions/testdata/valid-extension.json +++ b/internal/cmd/extensions/testdata/valid-extension.json @@ -1,25 +1,24 @@ { "name": "Extension 1", - "description": "My extension 1", "entry": "https://example.com/", - "contexts": [ + "description": "My extension 1", + "activationContexts": [ "project" ], - "routes": [ - { - "id": "extension-1", - "parentId": "workloads", - "locationId": "runtime", - "renderType": "menu", - "labelIntl": { - "en": "SomeLabel", - "it": "SomeLabelInItalian" - }, - "destinationPath": "/", - "order": 200.0, - "icon": { - "name": "PiHardDrives" - } - } - ] + "iconName": "PiHardDrives", + "destination": { + "id": "runtime", + "path": "/" + }, + "menu": { + "id": "extension-1", + "labelIntl": { + "en": "SomeLabel", + "it": "SomeLabelInItalian" + }, + "order": 200.0 + }, + "category": { + "id": "workloads" + } } diff --git a/internal/cmd/extensions/testdata/valid-extension.yaml b/internal/cmd/extensions/testdata/valid-extension.yaml index 04a7fae6..c8461aaf 100644 --- a/internal/cmd/extensions/testdata/valid-extension.yaml +++ b/internal/cmd/extensions/testdata/valid-extension.yaml @@ -1,17 +1,17 @@ -name: "Extension 1" -description: "My extension 1" -entry: "https://example.com/" -contexts: +name: Extension 1 +entry: https://example.com/ +description: My extension 1 +activationContexts: - project -routes: - - id: "extension-1" - parentId: "workloads" - locationId: "runtime" - labelIntl: - en: "SomeLabel" - it: "SomeLabelInItalian" - destinationPath: "/" - renderType: "menu" - order: 200 - icon: - name: "PiHardDrives" +iconName: PiHardDrives +destination: + id: runtime + path: "/" +menu: + id: extension-1 + labelIntl: + en: SomeLabel + it: SomeLabelInItalian + order: 200 +category: + id: workloads diff --git a/internal/resources/extensibility/extensionInfo.go b/internal/resources/extensibility/extensionInfo.go index 9e187f21..f2fc189c 100644 --- a/internal/resources/extensibility/extensionInfo.go +++ b/internal/resources/extensibility/extensionInfo.go @@ -20,7 +20,8 @@ type Order float64 type Context string type DestinationArea struct { - ID string `json:"id" yaml:"id"` + ID string `yaml:"id" json:"id" ` + Path string `yaml:"path" json:"path"` } type Languages string @@ -33,32 +34,33 @@ const ( type IntlMessages map[Languages]string type Visibility struct { - ContextType Context `json:"contextType" yaml:"contextType"` - ContextID string `json:"contextId" yaml:"contextId"` + ContextType Context `yaml:"contextType" json:"contextType"` + ContextID string `yaml:"contextId" json:"contextId"` } type Category struct { - ID string `json:"id" yaml:"id"` - LabelIntl IntlMessages `json:"labelIntl,omitempty" yaml:"labelIntl,omitempty"` + ID string `yaml:"id" json:"id" ` + LabelIntl IntlMessages `yaml:"labelIntl,omitempty" json:"labelIntl,omitempty"` + Order *Order `yaml:"order,omitempty" json:"order,omitempty"` } type Menu struct { - ID string `json:"id" yaml:"id"` - LabelIntl IntlMessages `json:"labelIntl" yaml:"labelIntl"` - Order *Order `json:"order,omitempty" yaml:"order,omitempty"` + ID string `yaml:"id" json:"id"` + LabelIntl IntlMessages `yaml:"labelIntl" json:"labelIntl"` + Order *Order `yaml:"order,omitempty" json:"order,omitempty"` } type ExtensionInfo struct { - ExtensionID string `json:"extensionId" yaml:"extensionId"` - Name string `json:"name" yaml:"name"` - Entry string `json:"entry" yaml:"entry"` - Type string `json:"type" yaml:"type"` - Destination DestinationArea `json:"destination" yaml:"destination"` - Description string `json:"description,omitempty" yaml:"description,omitempty"` - IconName string `json:"iconName,omitempty" yaml:"iconName,omitempty"` - ActivationContexts []Context `json:"activationContexts" yaml:"activationContexts"` - Permissions []string `json:"permissions,omitempty" yaml:"permissions,omitempty"` - Visibilities []Visibility `json:"visibilities,omitempty" yaml:"visibilities,omitempty"` - Category *Category `json:"category,omitempty" yaml:"category,omitempty"` - Menu *Menu `json:"menu,omitempty" yaml:"menu"` + ExtensionID string `yaml:"extensionId" json:"extensionId"` + Name string `yaml:"name" json:"name"` + Entry string `yaml:"entry" json:"entry"` + Type string `yaml:"type" json:"type"` + Destination DestinationArea `yaml:"destination" json:"destination"` + Description string `yaml:"description,omitempty" json:"description,omitempty"` + IconName string `yaml:"iconName,omitempty" json:"iconName,omitempty"` + ActivationContexts []Context `yaml:"activationContexts" json:"activationContexts"` + Permissions []string `yaml:"permissions,omitempty" json:"permissions,omitempty"` + Visibilities []Visibility `yaml:"visibilities,omitempty" json:"visibilities,omitempty"` + Category *Category `yaml:"category,omitempty" json:"category,omitempty"` + Menu *Menu `yaml:"menu" json:"menu,omitempty"` } diff --git a/internal/resources/extensibility/extensions.go b/internal/resources/extensibility/extensions.go index 550aad76..d440c426 100644 --- a/internal/resources/extensibility/extensions.go +++ b/internal/resources/extensibility/extensions.go @@ -16,14 +16,17 @@ package extensibility type Extension struct { - ExtensionID string `yaml:"extensionId,omitempty" json:"extensionId,omitempty"` - ExtensionType string `yaml:"extensionType,omitempty" json:"extensionType,omitempty"` - Name string `yaml:"name" json:"name"` - Description string `yaml:"description" json:"description"` - Entry string `yaml:"entry" json:"entry"` - Contexts []string `yaml:"contexts" json:"contexts"` - Permissions []string `yaml:"permissions,omitempty" json:"permissions,omitempty"` - Routes []*ExtensionRoute `yaml:"routes,omitempty" json:"routes,omitempty"` + ExtensionID string `yaml:"extensionId,omitempty" json:"extensionId,omitempty"` + Name string `yaml:"name" json:"name"` + Entry string `yaml:"entry" json:"entry"` + Type string `yaml:"type" json:"type"` + Destination DestinationArea `yaml:"destination" json:"destination"` + Description string `yaml:"description,omitempty" json:"description,omitempty"` + IconName string `yaml:"iconName,omitempty" json:"iconName,omitempty"` + ActivationContexts []Context `yaml:"activationContexts" json:"activationContexts"` + Permissions []string `yaml:"permissions,omitempty" json:"permissions,omitempty"` + Category *Category `yaml:"category,omitempty" json:"category,omitempty"` + Menu Menu `yaml:"menu" json:"menu"` } type Icon struct {