Skip to content

Commit

Permalink
fix: messages not showing on popups
Browse files Browse the repository at this point in the history
  • Loading branch information
moshloop committed Apr 8, 2022
1 parent de33f0b commit 0f2e352
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
18 changes: 10 additions & 8 deletions src/api/axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ export const IncidentCommander = axios.create({
}
});

IncidentCommander.interceptors.response.use(
(response) => response,
(error) => {
toastError(error.response.data.message);
return Promise.reject(error);
}
);

export const Logs = axios.create({
baseURL: "/apm/search",
headers: {
Expand All @@ -45,3 +37,13 @@ export const Config = axios.create({
"Content-Type": "application/json"
}
});

for (const client of [IncidentCommander, Logs, CanaryChecker, Config]) {
client.interceptors.response.use(
(response) => response,
(error) => {
toastError(error.response.data.message);
return Promise.reject(error);
}
);
}
5 changes: 4 additions & 1 deletion src/api/services/topology.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,7 @@ export const getTopology = async (params) => {
});
};

export const getCanaries = async () => resolve(CanaryChecker.get("/api"));
export const getCanaries = async (params) => {
const query = stringify(params);
return CanaryChecker.get(`/api?${query}`);
};
8 changes: 7 additions & 1 deletion src/components/Canary/minimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { CanaryCards } from "./card";
import { CanaryTable } from "./table";
import mixins from "../../utils/mixins.module.css";
import { getParamsFromURL } from "./utils";
import { getCanaries } from "../../api/services/topology";

export function MinimalCanary({
checks,
Expand All @@ -28,7 +29,12 @@ export function MinimalCanary({
const [selectedCheck, setSelectedCheck] = useState(null);

const handleCheckSelect = (check) => {
setSelectedCheck(check);
getCanaries({ check: check.id, includeMessages: true }).then((results) => {
if (results == null || results.data.checks.length === 0) {
return;
}
setSelectedCheck(results.data.checks[0]);
});
};

return (
Expand Down

0 comments on commit 0f2e352

Please sign in to comment.