2026-10-05 18:10:18 -04:00
|
|
|
import { useCurrentServerUuid } from '@/api/server/queries';
|
|
|
|
|
import { rotateServerDatabasePasswordInput, useRotateDatabasePassword } from '@/api/server/databases/queries';
|
2019-07-27 15:17:50 -07:00
|
|
|
import Button from '@/components/elements/Button';
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
type Props = {
|
|
|
|
|
databaseId: string;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const RotatePasswordButton = ({ databaseId }: Props) => {
|
|
|
|
|
const uuid = useCurrentServerUuid()!;
|
|
|
|
|
const rotatePassword = useRotateDatabasePassword();
|
2019-07-27 15:17:50 -07:00
|
|
|
|
|
|
|
|
if (!databaseId) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const rotate = () => {
|
2026-10-05 18:10:18 -04:00
|
|
|
rotatePassword.mutate(rotateServerDatabasePasswordInput(uuid, databaseId));
|
2019-07-27 15:17:50 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
2026-10-05 18:10:18 -04:00
|
|
|
<Button isSecondary color={'primary'} className={'mr-2'} onClick={rotate} isLoading={rotatePassword.isPending}>
|
2019-07-27 15:17:50 -07:00
|
|
|
Rotate Password
|
|
|
|
|
</Button>
|
|
|
|
|
);
|
|
|
|
|
};
|
2026-10-05 18:10:18 -04:00
|
|
|
|
|
|
|
|
export default RotatePasswordButton;
|