mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 11:31:13 -05:00
Fix rollback system
This commit is contained in:
@@ -10,6 +10,7 @@ import { ScrollArea } from '@/components/ui/scroll-area';
|
||||
import { VersionComparisonDialog } from './VersionComparisonDialog';
|
||||
import { RollbackDialog } from './RollbackDialog';
|
||||
import { useEntityVersions } from '@/hooks/useEntityVersions';
|
||||
import { useUserRole } from '@/hooks/useUserRole';
|
||||
import type { EntityType } from '@/types/versioning';
|
||||
|
||||
interface EntityVersionHistoryProps {
|
||||
@@ -28,6 +29,7 @@ const changeTypeColors = {
|
||||
|
||||
export function EntityVersionHistory({ entityType, entityId, entityName }: EntityVersionHistoryProps) {
|
||||
const { versions, loading, rollbackToVersion } = useEntityVersions(entityType, entityId);
|
||||
const { isModerator } = useUserRole();
|
||||
const [selectedVersions, setSelectedVersions] = useState<string[]>([]);
|
||||
const [compareDialogOpen, setCompareDialogOpen] = useState(false);
|
||||
const [rollbackDialogOpen, setRollbackDialogOpen] = useState(false);
|
||||
@@ -128,7 +130,7 @@ export function EntityVersionHistory({ entityType, entityId, entityName }: Entit
|
||||
)}
|
||||
</div>
|
||||
|
||||
{!version.is_current && (
|
||||
{!version.is_current && isModerator() && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
@@ -136,6 +138,7 @@ export function EntityVersionHistory({ entityType, entityId, entityName }: Entit
|
||||
e.stopPropagation();
|
||||
handleRollback(version.version_id);
|
||||
}}
|
||||
title="Moderator only: Restore this version"
|
||||
>
|
||||
<RotateCcw className="h-4 w-4 mr-1" />
|
||||
Restore
|
||||
|
||||
@@ -43,9 +43,9 @@ export function RollbackDialog({
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Restore Previous Version</DialogTitle>
|
||||
<DialogTitle>Restore Previous Version (Moderator Action)</DialogTitle>
|
||||
<DialogDescription>
|
||||
You are about to restore "{entityName}" to a previous version. This will create a new version with the restored data.
|
||||
You are about to restore "{entityName}" to a previous version. This will create a new version with the restored data. This action will be logged in the audit trail.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user