-
Notifications
You must be signed in to change notification settings - Fork 900
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core): Convert AddEntityTagLinks to React (#9147)
* refactor(core): Convert AddEntityTagLinks to React * refactor(core): Import entityTags help into module
- Loading branch information
1 parent
03c684d
commit 39fa773
Showing
18 changed files
with
81 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 16 additions & 88 deletions
104
app/scripts/modules/core/src/entityTag/addEntityTagLinks.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,19 @@ | ||
import { IComponentOptions, IController, module } from 'angular'; | ||
import { Application } from 'core/application'; | ||
import { IEntityTag } from 'core/domain'; | ||
import { module } from 'angular'; | ||
import { react2angular } from 'react2angular'; | ||
import { withErrorBoundary } from 'core/presentation'; | ||
|
||
import { EntityTagEditor, IEntityTagEditorProps, IOwnerOption } from './EntityTagEditor'; | ||
import './entityTags.help'; | ||
|
||
class AddEntityTagLinksCtrl implements IController { | ||
public application: Application; | ||
public tagType: string; | ||
|
||
private component: any; | ||
private entityType: string; | ||
private onUpdate: () => any; | ||
private ownerOptions: IOwnerOption[]; | ||
|
||
public addTag(tagType: string): void { | ||
const tag: IEntityTag = { | ||
name: null, | ||
value: { | ||
message: null, | ||
type: tagType, | ||
}, | ||
}; | ||
|
||
const props: IEntityTagEditorProps = { | ||
tag, | ||
isNew: true, | ||
owner: this.component, | ||
entityType: this.entityType, | ||
application: this.application, | ||
entityRef: null, | ||
onUpdate: this.onUpdate, | ||
ownerOptions: this.ownerOptions, | ||
}; | ||
|
||
EntityTagEditor.show(props); | ||
} | ||
} | ||
|
||
const addEntityTagLinksComponent: IComponentOptions = { | ||
bindings: { | ||
component: '<', | ||
application: '<', | ||
entityType: '@', | ||
onUpdate: '&?', | ||
tagType: '@', | ||
ownerOptions: '<?', | ||
}, | ||
controller: AddEntityTagLinksCtrl, | ||
template: ` | ||
<li role="presentation" class="divider"></li> | ||
<li> | ||
<a href ng-click="$ctrl.addTag('notice')"> | ||
Add notice <help-field key="entityTags.{{$ctrl.entityType}}.notice"></help-field> | ||
</a> | ||
</li> | ||
<li> | ||
<a href ng-click="$ctrl.addTag('alert')"> | ||
Add alert <help-field key="entityTags.{{$ctrl.entityType}}.alert"></help-field> | ||
</a> | ||
</li> | ||
`, | ||
}; | ||
|
||
export const addEntityTagLinksWrapperComponent: IComponentOptions = { | ||
bindings: { | ||
component: '<', | ||
application: '<', | ||
entityType: '<', | ||
onUpdate: '<?', | ||
tagType: '<', | ||
ownerOptions: '<?', | ||
}, | ||
controller: AddEntityTagLinksCtrl, | ||
template: ` | ||
<add-entity-tag-links | ||
component="$ctrl.component" | ||
application="$ctrl.application" | ||
entity-type={{$ctrl.entityType}} | ||
on-update="$ctrl.onUpdate()" | ||
tag-type={{$ctrl.tagType}} | ||
owner-options="$ctrl.ownerOptions"> | ||
</add-entity-tag-links> | ||
`, | ||
}; | ||
import { AddEntityTagLinks } from './AddEntityTagLinks'; | ||
|
||
export const ADD_ENTITY_TAG_LINKS_COMPONENT = 'spinnaker.core.entityTag.details.component'; | ||
module(ADD_ENTITY_TAG_LINKS_COMPONENT, []) | ||
.component('addEntityTagLinks', addEntityTagLinksComponent) | ||
.component('addEntityTagLinksWrapper', addEntityTagLinksWrapperComponent); | ||
|
||
module(ADD_ENTITY_TAG_LINKS_COMPONENT, []).component( | ||
'addEntityTagLinks', | ||
react2angular(withErrorBoundary(AddEntityTagLinks, 'addEntityTagLinks'), [ | ||
'application', | ||
'component', | ||
'entityType', | ||
'onUpdate', | ||
'ownerOptions', | ||
'tagType', | ||
]), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters