[PATCH conductor] BZ790830: "Disable" upload button after it has been pressed on images#show (rebased)

Jirka Tomasek jtomasek at redhat.com
Wed Feb 22 13:04:49 UTC 2012


On 02/22/2012 10:50 AM, ifarkas at redhat.com wrote:
> From: Imre Farkas<ifarkas at redhat.com>
>
> https://bugzilla.redhat.com/show_bug.cgi?id=790830
>
> In some cases when a user pushes an image and the page reload happens even before
> imagefactory would start the pushing operation and the Upload button displayed
> incorrectly. This patch solves this issue by displaying a label for notification.
> ---
>   src/app/controllers/images_controller.rb          |    3 +++
>   src/app/controllers/provider_images_controller.rb |    4 +++-
>   src/app/views/images/show.html.haml               |   12 ++++++++----
>   src/config/locales/en.yml                         |    1 +
>   4 files changed, 15 insertions(+), 5 deletions(-)
>
> diff --git a/src/app/controllers/images_controller.rb b/src/app/controllers/images_controller.rb
> index f37d117..0c6b350 100644
> --- a/src/app/controllers/images_controller.rb
> +++ b/src/app/controllers/images_controller.rb
> @@ -38,6 +38,9 @@ class ImagesController<  ApplicationController
>     def show
>       @image = Aeolus::Image::Warehouse::Image.find(params[:id])
>       @environment = PoolFamily.where('name' =>  @image.environment).first
> +    @push_started = params[:push_started] == 'true'
> +    @pushed_target_image_id = params[:pushed_target_image_id]
> +
>       if @image.imported?
>         begin
>           # For an imported image, we only want to show the actual provider account
> diff --git a/src/app/controllers/provider_images_controller.rb b/src/app/controllers/provider_images_controller.rb
> index 54094dc..60fabe5 100644
> --- a/src/app/controllers/provider_images_controller.rb
> +++ b/src/app/controllers/provider_images_controller.rb
> @@ -29,6 +29,7 @@ class ProviderImagesController<  ApplicationController
>       begin
>         if @provider_image.save
>           flash[:notice] = t('provider_images.flash.notice.upload_start')
> +        @push_started = true
>         else
>           flash[:warning] = t('provider_images.flash.warning.upload_failed')
>         end
> @@ -36,7 +37,8 @@ class ProviderImagesController<  ApplicationController
>         logger.error "Caught exception importing image: #{e.message}"
>         flash[:warning] = t('provider_images.flash.warning.upload_failed')
>       end
> -    redirect_to image_path(params[:image_id], :build =>  params[:build_id])
> +    redirect_to image_path(params[:image_id], :build =>  params[:build_id], :push_started =>  @push_started,
> +                           :pushed_target_image_id =>  @push_started ? @provider_image.target_image_id : nil)
>     end
>
>     def destroy
> diff --git a/src/app/views/images/show.html.haml b/src/app/views/images/show.html.haml
> index 82c00f5..c462772 100644
> --- a/src/app/views/images/show.html.haml
> +++ b/src/app/views/images/show.html.haml
> @@ -85,10 +85,14 @@
>                               - if timg and b = @builder.find_active_push(timg.id, account.provider.name, account.credentials_hash['username'])
>                                 = label_tag b.status
>                               - elsif timg and not pimg and @build and @build.id == @latest_build
> -                              = button_to t('.push'), image_provider_images_path(@image.id, :build_id =>  @build.id, :target_image_id =>  timg.id, :account_id =>  account.id), :method =>  :post, :class =>  'upload_image'
> -                              - failed_push_count = @builder.failed_push_count(timg.id, account.provider.name, account.credentials_hash['username'])
> -                              - if failed_push_count>  0
> -                                = t('images.show.failed_push_attempts', :count =>  failed_push_count )
> +                              - if @push_started&&  @pushed_target_image_id == timg.id
> +                                .light
> +                                  = t('images.show.push_started')
> +                              - else
> +                                = button_to t('.upload'), image_provider_images_path(@image.id, :build_id =>  @build.id, :target_image_id =>  timg.id, :account_id =>  account.id), :method =>  :post, :class =>  'upload_image'
> +                                - failed_push_count = @builder.failed_push_count(timg.id, account.provider.name, account.credentials_hash['username'])
> +                                - if failed_push_count>  0
> +                                  = t('images.show.failed_push_attempts', :count =>  failed_push_count)
>                               - elsif pimg
>                                 = button_to "", image_provider_image_path(@image.id, pimg.id), :method =>  :delete, :class =>  'delete_image'
>                               - else
> diff --git a/src/config/locales/en.yml b/src/config/locales/en.yml
> index addb68e..fdbb2aa 100644
> --- a/src/config/locales/en.yml
> +++ b/src/config/locales/en.yml
> @@ -773,6 +773,7 @@ en:
>         failed_push_attempts:
>           one: '1 failed push attempt'
>           other: '%{count} failed push attempts'
> +      push_started: 'Push is about to start'
>       flash:
>         notice:
>           deleted: Image Deleted
ACK



More information about the aeolus-devel mailing list