Skip to content

Commit

Permalink
Fix SUSE Manager settings CTA not showing up (#2952)
Browse files Browse the repository at this point in the history
  • Loading branch information
dottorblaster authored Sep 9, 2024
1 parent 5efe4a1 commit f657323
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
8 changes: 4 additions & 4 deletions assets/js/state/sagas/softwareUpdates.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ export function* fetchSoftwareUpdates({ payload: hostID }) {
const errorCode = get(error, ['response', 'status']);
const errors = get(error, ['response', 'data', 'errors'], []);
const suma_unauthorized = errors.some(
({ detail }) => detail === 'SUSE Manager authentication error.'
({ detail }) => detail === 'SUSE Manager settings not configured.'
);

if (errorCode === 422 && suma_unauthorized) {
if (errorCode === 404 && suma_unauthorized) {
yield put(setSettingsNotConfigured());
} else {
yield put(setSettingsConfigured());
Expand Down Expand Up @@ -70,10 +70,10 @@ export function* fetchUpgradablePackagesPatches({
const errors = get(error, ['response', 'data', 'errors'], []);

const suma_unauthorized = errors.some(
({ detail }) => detail === 'SUSE Manager authentication error.'
({ detail }) => detail === 'SUSE Manager settings not configured.'
);

if (errorCode === 422 && suma_unauthorized) {
if (errorCode === 404 && suma_unauthorized) {
yield put(setSettingsNotConfigured());
} else {
yield put(setSettingsConfigured());
Expand Down
12 changes: 6 additions & 6 deletions assets/js/state/sagas/softwareUpdates.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ describe('Software Updates saga', () => {
const errorBody = {
errors: [
{
title: 'Unprocessable Entity',
detail: 'SUSE Manager authentication error.',
title: 'Not Found',
detail: 'SUSE Manager settings not configured.',
},
],
};

axiosMock
.onGet(`/api/v1/hosts/${hostID}/software_updates`)
.reply(422, errorBody);
.reply(404, errorBody);

const dispatched = await recordSaga(fetchSoftwareUpdates, {
payload: hostID,
Expand Down Expand Up @@ -206,15 +206,15 @@ describe('Software Updates saga', () => {
const errorBody = {
errors: [
{
title: 'Unprocessable Entity',
detail: 'SUSE Manager authentication error.',
title: 'Not Found',
detail: 'SUSE Manager settings not configured.',
},
],
};

axiosMock
.onGet(`/api/v1/hosts/${hostID}/software_updates`)
.reply(422, errorBody);
.reply(404, errorBody);

const dispatched = await recordSaga(fetchSoftwareUpdates, {
payload: hostID,
Expand Down
11 changes: 11 additions & 0 deletions lib/trento_web/views/error_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ defmodule TrentoWeb.ErrorView do
}
end

def render("404.json", %{reason: reason}) do
%{
errors: [
%{
title: "Not Found",
detail: reason
}
]
}
end

def render("404.json", _) do
%{
errors: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ defmodule TrentoWeb.V1.SettingsControllerTest do

assert %{
"errors" => [
%{"detail" => "The requested resource cannot be found.", "title" => "Not Found"}
%{"detail" => "SUSE Manager settings not configured.", "title" => "Not Found"}
]
} == resp
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ defmodule TrentoWeb.V1.SUSEManagerControllerTest do

assert %{
"errors" => [
%{"detail" => "The requested resource cannot be found.", "title" => "Not Found"}
%{"detail" => "SUSE Manager settings not configured.", "title" => "Not Found"}
]
} == resp
end
Expand Down

0 comments on commit f657323

Please sign in to comment.