Skip to content
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

Merged
merged 1 commit into from
Sep 19, 2016

Conversation

icfantv
Copy link
Contributor

@icfantv icfantv commented Sep 16, 2016

  • add days-of-week selector widget to pipeline execution restriction window

@icfantv
Copy link
Contributor Author

icfantv commented Sep 16, 2016

@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 require everywhere and switch to a more modern code design.

Copy link
Contributor

@anotherchrisberry anotherchrisberry left a 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:

  1. We will want to include something in the executionWindowDetails.html to indicate to the user which days are restricted, if any.
  2. 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 the days 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');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove console statement

Copy link
Contributor Author

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 = [{
Copy link
Contributor

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',
Copy link
Contributor

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;
Copy link
Contributor

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">
Copy link
Contributor

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';
Copy link
Contributor

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', () => {
Copy link
Contributor

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

Copy link
Contributor Author

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'
Copy link
Contributor

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);
}
Copy link
Contributor

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]);

Copy link
Contributor Author

@icfantv icfantv Sep 16, 2016

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;
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@icfantv
Copy link
Contributor Author

icfantv commented Sep 16, 2016

@anotherchrisberry @zanthrash updated per comments/discussions. PTAL. Thanks.

@anotherchrisberry
Copy link
Contributor

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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove git st

Copy link
Contributor Author

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.

Copy link
Contributor Author

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....

@icfantv
Copy link
Contributor Author

icfantv commented Sep 17, 2016

@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 $onChanges only being fired when a reference to a collection changes, rather than the contents due to the performance ramifications of doing a deep watch on the collections as reported here.

@icfantv
Copy link
Contributor Author

icfantv commented Sep 17, 2016

The huge advantage that this exposed (the $onChanges not being fired, was that we now effectively bind the days model directly to the UI and we no longer are using the UIBS checkbox buttons.

@icfantv icfantv force-pushed the execution_window branch 3 times, most recently from fd3a89c to 1b28a1a Compare September 19, 2016 18:51
@icfantv
Copy link
Contributor Author

icfantv commented Sep 19, 2016

New Execution Window View:
screen shot 2016-09-19 at 11 52 09 am

Details View:
screen shot 2016-09-19 at 11 51 46 am

@icfantv
Copy link
Contributor Author

icfantv commented Sep 19, 2016

@anotherchrisberry @zanthrash i think we're done here, PTAL.

@icfantv icfantv force-pushed the execution_window branch 2 times, most recently from 4844b07 to 67dfa59 Compare September 19, 2016 18:57
Copy link
Contributor

@anotherchrisberry anotherchrisberry left a 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, ', ');
Copy link
Contributor

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 Sets.

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

* add days-of-week selector widget to pipeline execution restriction window
@icfantv icfantv merged commit 74fc68c into spinnaker:master Sep 19, 2016
@icfantv icfantv deleted the execution_window branch September 19, 2016 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants