Skip to content

Commit

Permalink
Adds a [fix all] button
Browse files Browse the repository at this point in the history
  • Loading branch information
rauhryan committed Sep 29, 2015
1 parent 637bbe5 commit 8ff177b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/health_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def board
def treat_board
exam = HealthChecking::BoardExam.new({
board: huboard.board(params[:user], params[:repo]),
name: params[:name],
names: params[:names],
authorization: authorization_level,
logged_in: logged_in? })
payload = HealthChecking::Doctor.new(exam).treat
Expand Down
25 changes: 24 additions & 1 deletion ember-app/app/components/settings/hb-health.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,29 @@ var SettingsHbHealthComponent = Ember.Component.extend({
}
}),
actions: {
treatAll() {
const controller = this;
this.set('isProcessing', true);
return ajax({
url: `/api/${this.get('repo.data.repo.full_name')}/health/board`,
dataType: 'json',
type: 'POST',
data: {
names: controller.get('checks').mapBy('name')
}
}).then((response) => {

response.data.forEach((c) => {
var update = controller.get('checks').findBy('name', c.name);
if(update) {
Ember.setProperties(update, c);
}
});

controller.get('model.content').saveData();
this.set('isProcessing', false);
});
},
treat(check, repo) {
const controller = this;
this.set('isProcessing', true);
Expand All @@ -23,7 +46,7 @@ var SettingsHbHealthComponent = Ember.Component.extend({
dataType: 'json',
type: 'POST',
data: {
name: check.name
names: [check.name]
}
}).then((response) => {

Expand Down
2 changes: 1 addition & 1 deletion ember-app/app/models/new/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var Repo = Model.extend({
});
}
}),
unhealthy: Ember.computed('health.isFulfilled', 'health.content.hasErrors' {
unhealthy: Ember.computed('health.isFulfilled', 'health.content.hasErrors', {
get: function(){
var health = this.get('health');
if(health.get('isFulfilled')){
Expand Down
1 change: 1 addition & 0 deletions ember-app/app/templates/components/settings/hb-health.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<div class="hb-health__group {{if model.content.hasErrors 'hb-health--error' 'hb-error--success'}}">
<div class="hb-health__group--header">
{{#if model.content.hasErrors}}
<button {{action "treatAll" }} disabled={{isProcessing}} class="hb-button hb-button-grey small pull-right">Fix all</button>
<div class="hb-health__indicator hb-health__indicator--error">
<i class="ui-icon ui-icon-12 ui-icon-x-thin"/>
</div>
Expand Down
8 changes: 6 additions & 2 deletions lib/health_checking/board_exam.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ def checks
# doesn't make sense to fix an unhealth webhook
# if it doesn't exist
def treatments
treatment_class = "HealthChecking::HealthChecks::Board::#{@deps[:name].classify}".safe_constantize
treatment_class.nil? ? [] : [treatment_class]
treatments = []
@deps[:names].each do |name|
treatment_class = "HealthChecking::HealthChecks::Board::#{name.classify}".safe_constantize
treatments << treatment_class unless treatment_class.nil?
end
return treatments
end

@@checks = [
Expand Down

0 comments on commit 8ff177b

Please sign in to comment.