mirror of
https://github.com/portainer/portainer.git
synced 2025-08-09 15:55:23 +02:00
feat(system): path to upgrade swarm to BE [EE-4624] (#8124)
This commit is contained in:
parent
b59a0ba823
commit
db9d87c918
8 changed files with 54 additions and 21 deletions
|
@ -74,3 +74,9 @@ function defaultErrorParser(axiosError: AxiosError) {
|
|||
const error = new Error(message);
|
||||
return { error, details };
|
||||
}
|
||||
|
||||
export function isAxiosError<
|
||||
ResponseType = { message: string; details: string }
|
||||
>(error: unknown): error is AxiosError<ResponseType> {
|
||||
return axiosOrigin.isAxiosError(error);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ export function useSystemStatus<T = StatusResponse>({
|
|||
select,
|
||||
enabled,
|
||||
retry,
|
||||
retryDelay: 1000,
|
||||
onSuccess,
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import { useMutation } from 'react-query';
|
||||
|
||||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
||||
import axios, {
|
||||
isAxiosError,
|
||||
parseAxiosError,
|
||||
} from '@/portainer/services/axios';
|
||||
import { withError } from '@/react-tools/react-query';
|
||||
|
||||
import { buildUrl } from './build-url';
|
||||
|
@ -15,6 +18,15 @@ async function upgradeEdition({ license }: { license: string }) {
|
|||
try {
|
||||
await axios.post(buildUrl('upgrade'), { license });
|
||||
} catch (error) {
|
||||
throw parseAxiosError(error as Error);
|
||||
if (!isAxiosError(error)) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
// if error is because the server disconnected, then everything went well
|
||||
if (!error.response || !error.response.status) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw parseAxiosError(error);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,10 @@ export const UpgradeBEBannerWrapper = withHideOnExtension(
|
|||
withEdition(UpgradeBEBanner, 'CE')
|
||||
);
|
||||
|
||||
const enabledPlatforms: Array<ContainerPlatform> = ['Docker Standalone'];
|
||||
const enabledPlatforms: Array<ContainerPlatform> = [
|
||||
'Docker Standalone',
|
||||
'Docker Swarm',
|
||||
];
|
||||
|
||||
function UpgradeBEBanner() {
|
||||
const { isAdmin } = useUser();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue