From c1fc0f30d091651e5e773076ebd5783926f342e8 Mon Sep 17 00:00:00 2001 From: Martin Hradil Date: Tue, 5 Nov 2019 14:39:04 +0100 Subject: [PATCH] Merge pull request #6352 from rvsia/17666276catalog-name Show name in success catalog form messages (cherry picked from commit aa9be0607736cdc2d6bacbe6619fa8558992f289) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1784187 --- app/controllers/catalog_controller.rb | 2 +- app/javascript/components/catalog-form/catalog-form.jsx | 4 ++-- app/javascript/spec/catalog-form/catalog-form.spec.js | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index 6908f0fe2c2..bddf3803f50 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -637,7 +637,7 @@ def st_catalog_edit @in_a_form = false replace_right_cell when "save", "add" - add_flash(_("Catalog was saved")) + add_flash(_("Catalog \"%{name}\" was saved") % {:name => params[:name]}) @changed = session[:changed] = false @in_a_form = false @edit = session[:edit] = nil diff --git a/app/javascript/components/catalog-form/catalog-form.jsx b/app/javascript/components/catalog-form/catalog-form.jsx index e7f9c303696..63fa9c4e117 100644 --- a/app/javascript/components/catalog-form/catalog-form.jsx +++ b/app/javascript/components/catalog-form/catalog-form.jsx @@ -68,7 +68,7 @@ class CatalogForm extends Component { }, { skipErrors: [400], }) - .then(() => miqAjaxButton('/catalog/st_catalog_edit?button=add')) + .then(() => miqAjaxButton('/catalog/st_catalog_edit?button=add', { name: values.name })) .catch(error => add_flash(this.handleError(error), 'error')); } @@ -104,7 +104,7 @@ class CatalogForm extends Component { } return Promise.all(promises) - .then(([{ id }]) => miqAjaxButton(`/catalog/st_catalog_edit/${id}?button=save`)) + .then(([{ id }]) => miqAjaxButton(`/catalog/st_catalog_edit/${id}?button=save`, { name: values.name })) .catch(error => add_flash(this.handleError(error), 'error')); }; diff --git a/app/javascript/spec/catalog-form/catalog-form.spec.js b/app/javascript/spec/catalog-form/catalog-form.spec.js index 20a432bd6c0..52847ff9f05 100644 --- a/app/javascript/spec/catalog-form/catalog-form.spec.js +++ b/app/javascript/spec/catalog-form/catalog-form.spec.js @@ -161,7 +161,7 @@ describe('Catalog form component', () => { }; wrapper.instance().submitValues(values).then(() => { expect(fetchMock.called(urlCreate)).toBe(true); - expect(spyMiqAjaxButton).toHaveBeenCalledWith('/catalog/st_catalog_edit?button=add'); + expect(spyMiqAjaxButton).toHaveBeenCalledWith('/catalog/st_catalog_edit?button=add', { name: 'Some name' }); done(); }); }); @@ -250,7 +250,7 @@ describe('Catalog form component', () => { wrapper.instance().submitValues(values).then(() => { expect(fetchMock.called(apiBase)).toBe(true); expect(fetchMock.called(`${apiBase}/service_templates`)).toBe(true); - expect(spyMiqAjaxButton).toHaveBeenCalledWith('/catalog/st_catalog_edit/1001?button=save'); + expect(spyMiqAjaxButton).toHaveBeenCalledWith('/catalog/st_catalog_edit/1001?button=save', { name: 'Some name' }); done(); }); }); @@ -275,7 +275,7 @@ describe('Catalog form component', () => { wrapper.instance().submitValues(values).then(() => { expect(fetchMock.called(apiBase)).toBe(true); expect(fetchMock.called(`${apiBase}/service_templates`)).toBe(false); - expect(spyMiqAjaxButton).toHaveBeenCalledWith('/catalog/st_catalog_edit/1001?button=save'); + expect(spyMiqAjaxButton).toHaveBeenCalledWith('/catalog/st_catalog_edit/1001?button=save', { name: 'Some name' }); done(); }); });