enzostvs HF Staff commited on
Commit
25f348d
·
1 Parent(s): d157265

allow history changes only if not private

Browse files
Files changed (1) hide show
  1. components/editor/history/index.tsx +25 -15
components/editor/history/index.tsx CHANGED
@@ -12,7 +12,7 @@ import { useEditor } from "@/hooks/useEditor";
12
  import classNames from "classnames";
13
 
14
  export function History() {
15
- const { commits, currentCommit, setCurrentCommit } = useEditor();
16
  const [open, setOpen] = useState(false);
17
 
18
  if (commits.length === 0) return null;
@@ -37,6 +37,14 @@ export function History() {
37
  History
38
  </header>
39
  <main className="space-y-3">
 
 
 
 
 
 
 
 
40
  <ul className="max-h-[250px] overflow-y-auto">
41
  {commits?.map((item: Commit, index: number) => (
42
  <li
@@ -72,20 +80,22 @@ export function History() {
72
  Current version
73
  </span>
74
  ) : (
75
- <Button
76
- variant="link"
77
- size="xss"
78
- className="text-gray-400 hover:text-gray-200"
79
- onClick={() => {
80
- if (index === 0) {
81
- setCurrentCommit(null);
82
- } else {
83
- setCurrentCommit(item.oid);
84
- }
85
- }}
86
- >
87
- See version
88
- </Button>
 
 
89
  )}
90
  </div>
91
  </li>
 
12
  import classNames from "classnames";
13
 
14
  export function History() {
15
+ const { commits, currentCommit, setCurrentCommit, project } = useEditor();
16
  const [open, setOpen] = useState(false);
17
 
18
  if (commits.length === 0) return null;
 
37
  History
38
  </header>
39
  <main className="space-y-3">
40
+ {project?.private && (
41
+ <div className="px-4 pt-3">
42
+ <p className="text-amber-500 text-xs px-2 py-1 bg-amber-500/10 border border-amber-500/20 rounded-md">
43
+ As this project is private, you can't see the history of
44
+ changes.
45
+ </p>
46
+ </div>
47
+ )}
48
  <ul className="max-h-[250px] overflow-y-auto">
49
  {commits?.map((item: Commit, index: number) => (
50
  <li
 
80
  Current version
81
  </span>
82
  ) : (
83
+ !project?.private && (
84
+ <Button
85
+ variant="link"
86
+ size="xss"
87
+ className="text-gray-400 hover:text-gray-200"
88
+ onClick={() => {
89
+ if (index === 0) {
90
+ setCurrentCommit(null);
91
+ } else {
92
+ setCurrentCommit(item.oid);
93
+ }
94
+ }}
95
+ >
96
+ See version
97
+ </Button>
98
+ )
99
  )}
100
  </div>
101
  </li>