Skip to content

Commit

Permalink
refactor(core): reactify notification and manual execution modal (#7075)
Browse files Browse the repository at this point in the history
* Refactor Notifications from angular components to React components.

* Notifications now uses formik

* Refactoring Notifications to formik forced me to refactor Manual Execution Modal to React and formik

* Refactored Stages, Manual Judgment, Triggers and Application Config to use new Notifications

* Updated previously implemented manual execution components to no longer update the command in their props but to use a callback instead

* Leveraged the Registry Service to add Notifications types similar to triggers
  • Loading branch information
Jammy Louie committed Jul 25, 2019
1 parent bec74d9 commit 71a4d9e
Show file tree
Hide file tree
Showing 103 changed files with 2,154 additions and 1,834 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,12 @@ module.exports = angular
this.bannerConfigProps.saveError = true;
});
};

this.notifications = [];
this.updateNotifications = notifications => {
$scope.$applyAsync(() => {
this.notifications = notifications;
});
};
},
]);
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<application-notifications
application="config.application"
notifications="config.notifications"
update-notifications="config.updateNotifications"
></application-notifications>
</page-section>
<page-section key="features" label="Features">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<p>You can edit notification settings for this application</p>
<notification-list
application="vm.application"
notifications="vm.notifications"
level="application"
application="vm.application.name"
level="'application'"
update-notifications="vm.updateNotifications"
></notification-list>
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = angular
bindToController: {
application: '=',
notifications: '=',
updateNotifications: '=',
},
controllerAs: 'vm',
controller: angular.noop,
Expand Down
6 changes: 0 additions & 6 deletions app/scripts/modules/core/src/domain/IAppNotification.ts

This file was deleted.

8 changes: 8 additions & 0 deletions app/scripts/modules/core/src/domain/INotification.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ITemplateInheritable } from './IPipeline';

export interface INotification extends ITemplateInheritable {
level?: string;
type: string;
when: string[];
[key: string]: any;
}
13 changes: 13 additions & 0 deletions app/scripts/modules/core/src/domain/INotificationTypeConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as React from 'react';

export interface INotificationTypeConfig {
label: string;
key: string;
config?: INotificationTypeCustomConfig;
component?: React.ComponentType;
}

export interface INotificationTypeCustomConfig {
fieldName?: string;
botName?: string;
}
12 changes: 6 additions & 6 deletions app/scripts/modules/core/src/domain/IPipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ import { IStage } from './IStage';
import { ITrigger } from './ITrigger';
import { IExpectedArtifact } from 'core/domain/IExpectedArtifact';
import { IEntityTags } from './IEntityTags';

interface INotification extends ITemplateInheritable {
type: string;
address: string;
when: string[];
}
import { INotification } from './INotification';

export interface IPipeline {
application: string;
Expand Down Expand Up @@ -39,12 +34,15 @@ export interface IPipeline {

export interface IParameter extends ITemplateInheritable {
name: string;
conditional?: any;
constraint?: string;
description: string;
default: string;
hasOptions: boolean;
pinned: boolean;
options: IParameterOption[];
condition?: IParameterCondition;
required?: boolean;
}

export interface IParameterCondition {
Expand All @@ -58,12 +56,14 @@ export interface IParameterOption {
}

export interface IPipelineCommand {
dryRun?: boolean;
extraFields?: { [key: string]: any };
triggerInvalid?: boolean;
pipeline: IPipeline;
trigger: ITrigger;
notificationEnabled: boolean;
notification: INotification;
parameters?: { [key: string]: any };
pipelineName: string;
}

Expand Down
4 changes: 3 additions & 1 deletion app/scripts/modules/core/src/domain/ITrigger.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { IExecution, ITemplateInheritable } from 'core/domain';
import { IArtifact, IExecution, ITemplateInheritable } from 'core/domain';

export interface ITrigger extends ITemplateInheritable {
artifacts?: IArtifact[];
description?: string;
enabled: boolean;
rebake?: boolean;
user?: string;
Expand Down
4 changes: 3 additions & 1 deletion app/scripts/modules/core/src/domain/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './IAppNotification';
export * from './IArtifact';
export * from './IArtifactEditorProps';
export * from './IArtifactExtractor';
Expand Down Expand Up @@ -35,6 +34,9 @@ export * from './ILoadBalancer';

export * from './IManifest';

export * from './INotification';
export * from './INotificationTypeConfig';

export * from './IOrchestratedItem';

export * from './IPipeline';
Expand Down
2 changes: 2 additions & 0 deletions app/scripts/modules/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export * from './naming';
export * from './navigation';
export * from './network';

export * from './notification';

export * from './orchestratedItem';
export * from './overrideRegistry';

Expand Down
1 change: 0 additions & 1 deletion app/scripts/modules/core/src/modal/wizard/WizardModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ export class WizardModal<T = {}> extends React.Component<IWizardModalProps<T>, I
<div className="col-md-3 hidden-sm hidden-xs">
<ul className="steps-indicator wizard-navigation">{pageLabels}</ul>
</div>

<div className="col-md-9 col-sm-12">
<div className="steps" ref={this.stepsElement} onScroll={this.handleStepsScroll}>
{renderPageContents()}
Expand Down
10 changes: 6 additions & 4 deletions app/scripts/modules/core/src/modal/wizard/WizardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface IWizardPageRenderProps {
}

export interface IWizardPageProps {
label: string;
label?: string;
order: number;
note?: React.ReactNode;
render: (props: IWizardPageRenderProps) => JSX.Element;
Expand Down Expand Up @@ -98,9 +98,11 @@ export class WizardPage<T> extends React.Component<IWizardPageProps, IWizardPage

return (
<div className="modal-page" ref={this.ref}>
<div className="wizard-subheading sticky-header">
<h4 className={className}>{label}</h4>
</div>
{label && (
<div className="wizard-subheading sticky-header">
<h4 className={className}>{label}</h4>
</div>
)}
<div className="wizard-page-body">
{pageContents}
{note && <div className="row">{note}</div>}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { IPromise } from 'angular';

import { API } from 'core/api/ApiService';
import { IAppNotification } from 'core/domain';
import { INotification } from 'core/domain';

export interface IAppNotifications {
application: string;
[key: string]: IAppNotification[] | string; // "| string" is just for application field
[key: string]: INotification[] | string; // "| string" is just for application field
}

export class AppNotificationsService {
Expand Down
Loading

0 comments on commit 71a4d9e

Please sign in to comment.