mirror of
https://github.com/portainer/portainer.git
synced 2025-07-19 05:19:39 +02:00
feat(helm): rollback helm chart [r8s-287] (#660)
This commit is contained in:
parent
61d6ac035d
commit
c91c8a6467
13 changed files with 701 additions and 32 deletions
|
@ -0,0 +1,71 @@
|
|||
import { RotateCcw } from 'lucide-react';
|
||||
|
||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||
import { notifySuccess } from '@/portainer/services/notifications';
|
||||
|
||||
import { LoadingButton } from '@@/buttons';
|
||||
import { buildConfirmButton } from '@@/modals/utils';
|
||||
import { confirm } from '@@/modals/confirm';
|
||||
import { ModalType } from '@@/modals';
|
||||
|
||||
import { useHelmRollbackMutation } from '../queries/useHelmRollbackMutation';
|
||||
|
||||
type Props = {
|
||||
latestRevision: number;
|
||||
environmentId: EnvironmentId;
|
||||
releaseName: string;
|
||||
namespace?: string;
|
||||
};
|
||||
|
||||
export function RollbackButton({
|
||||
latestRevision,
|
||||
environmentId,
|
||||
releaseName,
|
||||
namespace,
|
||||
}: Props) {
|
||||
// the selectedRevision can be a prop when selecting a revision is implemented
|
||||
const selectedRevision = latestRevision ? latestRevision - 1 : undefined;
|
||||
|
||||
const rollbackMutation = useHelmRollbackMutation(environmentId);
|
||||
|
||||
return (
|
||||
<LoadingButton
|
||||
onClick={handleClick}
|
||||
isLoading={rollbackMutation.isLoading}
|
||||
loadingText="Rolling back..."
|
||||
data-cy="rollback-button"
|
||||
icon={RotateCcw}
|
||||
color="default"
|
||||
size="medium"
|
||||
>
|
||||
Rollback to #{selectedRevision}
|
||||
</LoadingButton>
|
||||
);
|
||||
|
||||
async function handleClick() {
|
||||
const confirmed = await confirm({
|
||||
title: 'Are you sure?',
|
||||
modalType: ModalType.Warn,
|
||||
confirmButton: buildConfirmButton('Rollback'),
|
||||
message: `Rolling back will restore the application to revision #${selectedRevision}, which will cause service interruption. Do you wish to continue?`,
|
||||
});
|
||||
if (!confirmed) {
|
||||
return;
|
||||
}
|
||||
|
||||
rollbackMutation.mutate(
|
||||
{
|
||||
releaseName,
|
||||
params: { namespace, revision: selectedRevision },
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
notifySuccess(
|
||||
'Success',
|
||||
`Application rolled back to revision #${selectedRevision} successfully.`
|
||||
);
|
||||
},
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue