@spinnaker/core 0.15.1 → 0.18.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.
@@ -0,0 +1,43 @@
1
+ import { REST } from '../../api';
2
+ import { useLatestPromise } from '../../presentation';
3
+
4
+ // Shape from back end
5
+ interface IQuietPeriodConfig {
6
+ startTime: number;
7
+ endTime: number;
8
+ enabled: boolean;
9
+ // Do not use in UI -- point-in-time data from back-end
10
+ inQuietPeriod: boolean;
11
+ }
12
+
13
+ class QuietPeriodService {
14
+ private static _quietPeriodConfig: PromiseLike<IQuietPeriodConfig>;
15
+ static async quietPeriodConfig(): Promise<IQuietPeriodConfig> {
16
+ this._quietPeriodConfig = this._quietPeriodConfig ?? REST('/capabilities/quietPeriod').get<IQuietPeriodConfig>();
17
+ return await this._quietPeriodConfig;
18
+ }
19
+ }
20
+
21
+ interface IQuietPeriod {
22
+ currentStatus: 'UNKNOWN' | 'BEFORE_QUIET_PERIOD' | 'DURING_QUIET_PERIOD' | 'AFTER_QUIET_PERIOD' | 'NO_QUIET_PERIOD';
23
+ startTime: number;
24
+ endTime: number;
25
+ }
26
+
27
+ export function useQuietPeriod(): IQuietPeriod {
28
+ const result = useLatestPromise(() => QuietPeriodService.quietPeriodConfig(), []);
29
+ if (result.status !== 'RESOLVED') {
30
+ return { currentStatus: 'UNKNOWN', startTime: undefined, endTime: undefined };
31
+ }
32
+
33
+ const { startTime, endTime, enabled } = result.result;
34
+ if (!enabled || !startTime || startTime < 0 || !endTime || endTime < 0) {
35
+ return { currentStatus: 'NO_QUIET_PERIOD', startTime: undefined, endTime: undefined };
36
+ }
37
+
38
+ const now = Date.now();
39
+ const currentStatus =
40
+ now < startTime ? 'BEFORE_QUIET_PERIOD' : now > endTime ? 'AFTER_QUIET_PERIOD' : 'DURING_QUIET_PERIOD';
41
+
42
+ return { currentStatus, startTime, endTime };
43
+ }
@@ -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
  })