Commit 1a278b5e authored by Tyler Amos's avatar Tyler Amos Committed by Markus Koller

Adjust sync_seat_link action to respond with JSON

This allows the FE to leverage async actions instead of a full page
refresh.
parent 69bd1adf
...@@ -59,15 +59,15 @@ class Admin::LicensesController < Admin::ApplicationController ...@@ -59,15 +59,15 @@ class Admin::LicensesController < Admin::ApplicationController
end end
def sync_seat_link def sync_seat_link
sync_result = Gitlab::SeatLinkData.new.sync respond_to do |format|
format.json do
if sync_result if Gitlab::SeatLinkData.new.sync
flash[:notice] = _('Your license was successfully synced.') render json: { success: true }
else else
flash[:error] = _('There was an error when trying to sync your license. Please verify that your instance is using an active license key.') render json: { success: false }, status: :unprocessable_entity
end
end
end end
redirect_to admin_license_path
end end
private private
......
...@@ -115,22 +115,22 @@ RSpec.describe Admin::LicensesController do ...@@ -115,22 +115,22 @@ RSpec.describe Admin::LicensesController do
context 'with seat link enabled' do context 'with seat link enabled' do
let(:seat_link_enabled) { true } let(:seat_link_enabled) { true }
it 'redirects with a successful message' do it 'returns a success response' do
post :sync_seat_link post :sync_seat_link, format: :json
expect(response).to redirect_to(admin_license_path) expect(response).to have_gitlab_http_status(:ok)
expect(flash[:notice]).to eq('Your license was successfully synced.') expect(json_response).to eq({ 'success' => true })
end end
end end
context 'with seat link disabled' do context 'with seat link disabled' do
let(:seat_link_enabled) { false } let(:seat_link_enabled) { false }
it 'redirects with an error message' do it 'returns a failure response' do
post :sync_seat_link post :sync_seat_link, format: :json
expect(response).to redirect_to(admin_license_path) expect(response).to have_gitlab_http_status(:unprocessable_entity)
expect(flash[:error]).to match('There was an error when trying to sync your license.') expect(json_response).to eq({ 'success' => false })
end end
end end
end end
......
...@@ -31914,9 +31914,6 @@ msgstr "" ...@@ -31914,9 +31914,6 @@ msgstr ""
msgid "There was an error when subscribing to this label." msgid "There was an error when subscribing to this label."
msgstr "" msgstr ""
msgid "There was an error when trying to sync your license. Please verify that your instance is using an active license key."
msgstr ""
msgid "There was an error when unsubscribing from this label." msgid "There was an error when unsubscribing from this label."
msgstr "" msgstr ""
...@@ -36549,9 +36546,6 @@ msgstr "" ...@@ -36549,9 +36546,6 @@ msgstr ""
msgid "Your license is valid from" msgid "Your license is valid from"
msgstr "" msgstr ""
msgid "Your license was successfully synced."
msgstr ""
msgid "Your license will be included in your GitLab backup and will survive upgrades, so in normal usage you should never need to re-upload your %{code_open}.gitlab-license%{code_close} file." msgid "Your license will be included in your GitLab backup and will survive upgrades, so in normal usage you should never need to re-upload your %{code_open}.gitlab-license%{code_close} file."
msgstr "" msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment