@spinnaker/core 0.15.1 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spinnaker/core",
3
3
  "license": "Apache-2.0",
4
- "version": "0.15.1",
4
+ "version": "0.16.0",
5
5
  "module": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "scripts": {
@@ -89,7 +89,7 @@
89
89
  "@graphql-codegen/typescript-operations": "^1.18.3",
90
90
  "@graphql-codegen/typescript-react-apollo": "^2.3.0",
91
91
  "@spinnaker/eslint-plugin": "^3.0.1",
92
- "@spinnaker/scripts": "^0.2.3",
92
+ "@spinnaker/scripts": "^0.2.4",
93
93
  "@types/angular": "1.6.26",
94
94
  "@types/angular-mocks": "1.5.10",
95
95
  "@types/angular-ui-bootstrap": "0.13.41",
@@ -120,5 +120,5 @@
120
120
  "shx": "0.3.3",
121
121
  "typescript": "4.3.5"
122
122
  },
123
- "gitHead": "187272ef1933753688fb8f7966e250a27104612a"
123
+ "gitHead": "59026ea6af7b81ffb8e8c59e18f43396906ddafb"
124
124
  }
@@ -13,7 +13,7 @@ module(APPLICATIONS_STATE_PROVIDER, [STATE_CONFIG_PROVIDER, APPLICATION_STATE_PR
13
13
  (stateConfigProvider: StateConfigProvider, applicationStateProvider: ApplicationStateProvider) => {
14
14
  const applicationsState: INestedState = {
15
15
  name: 'applications',
16
- url: '/applications',
16
+ url: '/applications?create',
17
17
  views: {
18
18
  'main@': {
19
19
  component: Applications,
@@ -30,7 +30,8 @@ module(CORE_APPLICATION_MODAL_CREATEAPPLICATION_MODAL_CONTROLLER, [
30
30
  '$state',
31
31
  '$uibModalInstance',
32
32
  '$timeout',
33
- function ($scope, $q, $log, $state, $uibModalInstance, $timeout) {
33
+ 'name',
34
+ function ($scope, $q, $log, $state, $uibModalInstance, $timeout, name) {
34
35
  const applicationLoader = ApplicationReader.listApplications();
35
36
  applicationLoader.then((applications) => (this.data.appNameList = _.map(applications, 'name')));
36
37
 
@@ -59,6 +60,10 @@ module(CORE_APPLICATION_MODAL_CREATEAPPLICATION_MODAL_CONTROLLER, [
59
60
  instancePort: SETTINGS.defaultInstancePort || null,
60
61
  };
61
62
 
63
+ if (name) {
64
+ this.application.name = name;
65
+ }
66
+
62
67
  const submitting = () => {
63
68
  this.state.errorMessages = [];
64
69
  this.state.submitting = true;
@@ -71,11 +76,7 @@ module(CORE_APPLICATION_MODAL_CREATEAPPLICATION_MODAL_CONTROLLER, [
71
76
  let navigateTimeout = null;
72
77
 
73
78
  const routeToApplication = () => {
74
- navigateTimeout = $timeout(() => {
75
- $state.go('home.applications.application', {
76
- application: this.application.name,
77
- });
78
- }, 1000);
79
+ $uibModalInstance.close(this.application);
79
80
  };
80
81
 
81
82
  $scope.$on('$destroy', () => $timeout.cancel(navigateTimeout));
@@ -14,6 +14,7 @@ describe('Controller: CreateApplicationModalCtrl', function () {
14
14
  controller = $controller('CreateApplicationModalCtrl', {
15
15
  $scope: scope,
16
16
  $uibModalInstance: {},
17
+ name: 'deck',
17
18
  });
18
19
  }),
19
20
  );
@@ -8,9 +8,11 @@ import { distinctUntilChanged, map, takeUntil } from 'rxjs/operators';
8
8
  import { ApplicationTable } from './ApplicationsTable';
9
9
  import { PaginationControls } from './PaginationControls';
10
10
  import type { IAccount } from '../../account';
11
+ import type { Application } from '../../application';
11
12
  import type { ICache } from '../../cache';
12
13
  import { ViewStateCache } from '../../cache';
13
14
  import { InsightMenu } from '../../insight/InsightMenu';
15
+ import { ModalInjector, ReactInjector } from '../../reactShims';
14
16
  import type { IApplicationSummary } from '../service/ApplicationReader';
15
17
  import { ApplicationReader } from '../service/ApplicationReader';
16
18
  import { Spinner } from '../../widgets';
@@ -22,6 +24,10 @@ interface IViewState {
22
24
  sort: string;
23
25
  }
24
26
 
27
+ interface IApplicationsStateParams {
28
+ create?: string;
29
+ }
30
+
25
31
  export interface IApplicationPagination {
26
32
  currentPage: number;
27
33
  itemsPerPage: number;
@@ -113,6 +119,48 @@ export class Applications extends React.Component<{}, IApplicationsState> {
113
119
  throw error;
114
120
  },
115
121
  );
122
+
123
+ const { $stateParams, $state, $rootScope, overrideRegistry } = ReactInjector;
124
+ const { create } = $stateParams as IApplicationsStateParams;
125
+ applicationSummaries$.subscribe((applications: IApplicationSummary[]) => {
126
+ if (create) {
127
+ const found = applications.find((app) => app.name === create);
128
+ if (found) {
129
+ if (found.email) {
130
+ // Application already exists - redirect to app
131
+ $state.go('home.applications.application', { application: create, create: null });
132
+ } else {
133
+ // Inferred application - redirect to config
134
+ $state.go('home.applications.application.config', { application: create, create: null });
135
+ }
136
+ } else {
137
+ // Nonexistant application - open create modal
138
+ ModalInjector.modalService
139
+ .open({
140
+ scope: $rootScope.$new(),
141
+ templateUrl: overrideRegistry.getTemplate(
142
+ 'createApplicationModal',
143
+ require('../modal/newapplication.html'),
144
+ ),
145
+ resolve: {
146
+ name: () => create,
147
+ },
148
+ controller: overrideRegistry.getController('CreateApplicationModalCtrl'),
149
+ controllerAs: 'newAppModal',
150
+ })
151
+ .result.then(
152
+ (app: Application) => {
153
+ $state.go('home.applications.application', { application: app.name, create: null });
154
+ },
155
+ () => {
156
+ // Clear out the query parameter if the dialog is dismissed
157
+ $state.go('home.applications', { create: null });
158
+ },
159
+ )
160
+ .catch(() => {});
161
+ }
162
+ }
163
+ });
116
164
  }
117
165
 
118
166
  private toggleSort(column: string): void {
@@ -56,6 +56,9 @@ export class InsightMenu extends React.Component<IInsightMenuProps, IInsightMenu
56
56
  'createApplicationModal',
57
57
  require('../application/modal/newapplication.html'),
58
58
  ),
59
+ resolve: {
60
+ name: () => '',
61
+ },
59
62
  controller: this.overrideRegistry.getController('CreateApplicationModalCtrl'),
60
63
  controllerAs: 'newAppModal',
61
64
  })
@@ -136,6 +136,9 @@ angular
136
136
  'createApplicationModal',
137
137
  require('../../application/modal/newapplication.html'),
138
138
  ),
139
+ resolve: {
140
+ name: () => '',
141
+ },
139
142
  controller: overrideRegistry.getController('CreateApplicationModalCtrl'),
140
143
  controllerAs: 'newAppModal',
141
144
  })