mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: add latestVersion information to update data
This commit is contained in:
@@ -20,16 +20,16 @@ export const UpdateServer = () => {
|
||||
const [isUpdateAvailable, setIsUpdateAvailable] = useState<null | boolean>(
|
||||
null,
|
||||
);
|
||||
const { mutateAsync: checkForUpdate, isLoading } =
|
||||
api.settings.checkForUpdate.useMutation();
|
||||
const { mutateAsync: getUpdateData, isLoading } =
|
||||
api.settings.getUpdateData.useMutation();
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
|
||||
const handleCheckUpdates = async () => {
|
||||
try {
|
||||
const updateAvailable = await checkForUpdate();
|
||||
const { updateAvailable, latestVersion } = await getUpdateData();
|
||||
setIsUpdateAvailable(updateAvailable);
|
||||
if (updateAvailable) {
|
||||
toast.success("Update is available!");
|
||||
toast.success(`${latestVersion} update is available!`);
|
||||
} else {
|
||||
toast.info("No updates available");
|
||||
}
|
||||
|
||||
@@ -34,8 +34,8 @@ export const Navbar = () => {
|
||||
},
|
||||
);
|
||||
const { mutateAsync } = api.auth.logout.useMutation();
|
||||
const { mutateAsync: checkForUpdate } =
|
||||
api.settings.checkForUpdate.useMutation();
|
||||
const { mutateAsync: getUpdateData } =
|
||||
api.settings.getUpdateData.useMutation();
|
||||
|
||||
const checkUpdatesIntervalRef = useRef<null | NodeJS.Timeout>(null);
|
||||
|
||||
@@ -58,7 +58,7 @@ export const Navbar = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
const updateAvailable = await checkForUpdate();
|
||||
const { updateAvailable } = await getUpdateData();
|
||||
|
||||
if (updateAvailable) {
|
||||
// Stop interval when update is available
|
||||
|
||||
@@ -45,7 +45,7 @@ import {
|
||||
stopService,
|
||||
stopServiceRemote,
|
||||
updateAdmin,
|
||||
checkIsUpdateAvailable,
|
||||
getUpdateData,
|
||||
updateLetsEncryptEmail,
|
||||
updateServerById,
|
||||
updateServerTraefik,
|
||||
@@ -343,12 +343,12 @@ export const settingsRouter = createTRPCRouter({
|
||||
writeConfig("middlewares", input.traefikConfig);
|
||||
return true;
|
||||
}),
|
||||
checkForUpdate: adminProcedure.mutation(async () => {
|
||||
getUpdateData: adminProcedure.mutation(async () => {
|
||||
if (IS_CLOUD) {
|
||||
return true;
|
||||
return { latestVersion: null, updateAvailable: false };
|
||||
}
|
||||
|
||||
return await checkIsUpdateAvailable();
|
||||
return await getUpdateData();
|
||||
}),
|
||||
updateServer: adminProcedure.mutation(async () => {
|
||||
if (IS_CLOUD) {
|
||||
|
||||
Reference in New Issue
Block a user