[PATCH aeolus-conductor] Enable or disable launch button on deployables show page
Imre Farkas
ifarkas at redhat.com
Wed Feb 22 15:55:58 UTC 2012
On 02/22/2012 02:53 PM, Petr Blaho wrote:
> via ajax update according to build results
>
> https://bugzilla.redhat.com/show_bug.cgi?id=788719
> ---
> src/app/views/deployables/show.html.haml | 5 +++--
> src/public/javascripts/backbone/views.js | 16 ++++++++++++++++
> 2 files changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/src/app/views/deployables/show.html.haml b/src/app/views/deployables/show.html.haml
> index 083fcc0..e7abee2 100644
> --- a/src/app/views/deployables/show.html.haml
> +++ b/src/app/views/deployables/show.html.haml
> @@ -8,10 +8,11 @@
> = link_to t('.edit'), edit_polymorphic_path([@catalog, @deployable]), :class => 'button', :id => 'edit_button'
> = link_to t('.edit_xml'), edit_polymorphic_path([@catalog, @deployable], :edit_xml => true), :class => 'button', :id => 'edit_xml_button'
>
> + - launch_deployment_button_path = launch_time_params_deployments_path(:deployable_id => @deployable.id, :deployment => { :name => @deployable.name, :pool_id => @catalog.pool })
> - if @catalog.present?&& @deployable_errors.empty?&& @pushed_count> 0
> - = link_to t('.launch'), launch_time_params_deployments_path(:deployable_id => @deployable.id, :deployment => { :name => @deployable.name, :pool_id => @catalog.pool }), :id => :launch_deployment_button
> + = link_to t('.launch'), launch_deployment_button_path, :id => :launch_deployment_button, :'data-path' => launch_deployment_button_path
> -else
> - %a{:id => :launch_deployment_button, :class => 'disabled'}= t('.launch')
> + %a{:id => :launch_deployment_button, :class => 'disabled', :'data-path' => launch_deployment_button_path}= t('.launch')
>
>
> %section.admin-content-section
> diff --git a/src/public/javascripts/backbone/views.js b/src/public/javascripts/backbone/views.js
> index 55c0fe0..983a46c 100644
> --- a/src/public/javascripts/backbone/views.js
> +++ b/src/public/javascripts/backbone/views.js
> @@ -149,6 +149,22 @@ Conductor.Views.DeployablesShow = Backbone.View.extend({
>
> $builds.empty();
> $('#deployableBuildsTemplate').tmpl(this.model.toJSON()).appendTo($builds);
> +
> + // get values of all build results
> + var build_results_values = _.flatten(_.values(this.model.get("build_results")));
> + var enable_launch_button = _.any(build_results_values, function(build_results){
> + return build_results.status === "pushed";
> + });
> +
> + // toggle "disabled" class
> + $("#launch_deployment_button").toggleClass("disabled", !enable_launch_button);
> + // create or remove href attribute with value from data-path
> + if(enable_launch_button) {
> + $("#launch_deployment_button").attr("href", $("#launch_deployment_button").attr("data-path"));
A more convenient way to access the data-path would be:
$("#launch_deployment_button").data("path")
> + }
> + else{
> + $("#launch_deployment_button").removeAttr("href");
> + }
> }
> });
>
ACK with 1 inline note
More information about the aeolus-devel
mailing list