-
Notifications
You must be signed in to change notification settings - Fork 903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(core) add day selector to execution window #2701
Conversation
icfantv
commented
Sep 16, 2016
- add days-of-week selector widget to pipeline execution restriction window
@spinnaker/netflix-reviewers @spinnaker/google-reviewers, PTAL, this is a first attempt at switching to ES6 module loading and class syntax for items which will, amongst other things, allow us to move away from using |
69cd361
to
f72f75d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of things:
- We will want to include something in the
executionWindowDetails.html
to indicate to the user which days are restricted, if any. - This has to work with existing pipelines, where
days
will not be defined. Did you test it against an existing stage with an execution window? You can do that by creating a pipeline with a stage in prestaging, then adding an execution window, then checking it locally to verify thedays
field is correctly populated on the stage when toggling things.
Also, can you include a screenshot to show what the component looks like on the screen?
} | ||
|
||
$onInit() { | ||
console.log('executing onInit'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove console
statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack!
class ExecutionWindowDayPickerController { | ||
|
||
constructor() { | ||
this.DAYS = [{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a little confusing the have both DAYS
and days
on the controller. Maybe change this to dayOptions
?
days: '=' | ||
}, | ||
controller: ExecutionWindowDayPickerController, | ||
controllerAs: 'dayPicker', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not using controllerAs
syntax in components - better to stick with the default ($ctrl
).
const MODULE_NAME = 'spinnaker.core.pipeline.stage.executionWindows.dayPicker'; | ||
angular.module(MODULE_NAME, []) | ||
.component('executionWindowDayPicker', EXECUTION_WINDOW_DAY_PICKER_COMPONENT); | ||
export default MODULE_NAME; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be consistent with the rest of the code base, it's probably better to rewrite this block (L76-88) as:
module.exports = angular.module('spinnaker.core.pipeline.stage.executionWindows.dayPicker', [])
.component('executionWindowDayPicker', {
bindings: {
days: '='
},
controller: ExecutionWindowDayController,
templateUrl: require('./executionWindowDayPicker.component.html')
});
@@ -0,0 +1,13 @@ | |||
<div class="btn-group"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File should be named executionWindowDayPicker.component.html
to be consistent with other components.
@@ -0,0 +1,89 @@ | |||
import angular from 'angular'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be renamed executionWindowDayPicker.component.js
to be consistent with other components.
@@ -0,0 +1,87 @@ | |||
import dayPickerComponent from './ExecutionWindowDayPickerComponent'; | |||
|
|||
fdescribe('Component: Execution Window Day Picker', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fdescribe
should just be describe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack!
constructor() { | ||
this.DAYS = [{ | ||
dow: 'sunday', | ||
abbr: 'Sun' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be consistent with the rest of the codebase, these should probably be key
and label
const days = new Set(ctrl.days); | ||
for (let i = 2; i < 7; i++) { | ||
expect(days.has(i)).toBe(true); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These four lines read better as:
expect(ctrl.days).toEqual([2,3,4,5,6]);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anotherchrisberry Aside from being cleaner, this would imply that order matters for the days
property, which, on the client-side, it does not. Can you confirm that days is order-dependent on the server side? In fact, I'm wondering if this should be a Set
... thoughts?
updated.push(index + 1); | ||
} | ||
}); | ||
this.days = updated; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this get applied to the underlying stage? Seems like, by reassigning the value on the controller here, it won't end up on the stage, and the stage's days
field will remain unchanged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anotherchrisberry yes, this works and i've confirmed across page reloads that saved values are re-retrieved and set correctly.
f72f75d
to
5bf333a
Compare
@anotherchrisberry @zanthrash updated per comments/discussions. PTAL. Thanks. |
Looking better - can you add something to the execution details view around https://github.com/spinnaker/deck/blob/master/app/scripts/modules/core/pipeline/config/stages/executionWindows/executionWindowsDetails.html#L7 to show which days (if any) the window is restricted to? |
</div> | ||
</div> | ||
|
||
</div> | ||
git st</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove git st
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, i caught this afterwards...not sure what happend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, well....i KNOW what happened....
@anotherchrisberry this isn't quite ready yet - i found an issue with the revert button that required completely changing how we initially render the buttons, set the states, and manage the internal model due to |
5bf333a
to
f6e8505
Compare
The huge advantage that this exposed (the |
fd3a89c
to
1b28a1a
Compare
@anotherchrisberry @zanthrash i think we're done here, PTAL. |
4844b07
to
67dfa59
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
const days = $scope.stage.context.restrictedExecutionWindow.days; | ||
if (days && (days.length > 0)) { | ||
const daysAsText = replaceDays(days); | ||
dayText = daysAsText.toString().replace(/,/g, ', '); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you weren't using a Set
above, you could just do days.join(', ')
here. But this works, too, and I know how much you really like your Set
s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll fix. I'd forgotten about join
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
67dfa59
to
6818334
Compare
* add days-of-week selector widget to pipeline execution restriction window
6818334
to
f2c828b
Compare