@@ -13,12 +13,58 @@ import ErrorDialog from "./ErrorDialog";
1313import TestEditForm from "./TestEditForm" ;
1414import TestAddForm from "./TestAddForm" ;
1515import Theme from "./theme" ;
16+ import WarningBox from "./WarningBox" ;
1617import {
1718 copyToClipboard ,
1819 formatTimeStampToLongString ,
1920 showNotification ,
2021} from "./utils" ;
2122
23+
24+ function EditButton ( props ) {
25+ if ( props . canEdit ) {
26+ return (
27+ < Tooltip placement = "top" title = "Edit Test" >
28+ < IconButton
29+ aria-label = "edit test"
30+ onClick = { ( ) => props . handleEditClick ( ) }
31+ style = { {
32+ backgroundColor : Theme . buttonPrimary ,
33+ marginLeft : 10 ,
34+ } }
35+ >
36+ < EditIcon />
37+ </ IconButton >
38+ </ Tooltip >
39+ ) ;
40+ } else {
41+ return "" ;
42+ }
43+ }
44+
45+
46+ function DuplicateButton ( props ) {
47+ if ( props . canDuplicate ) {
48+ return (
49+ < Tooltip placement = "top" title = "Duplicate Test" >
50+ < IconButton
51+ aria-label = "duplicate test"
52+ onClick = { ( ) => props . handleDuplicateClick ( ) }
53+ style = { {
54+ backgroundColor : Theme . buttonPrimary ,
55+ marginLeft : 10 ,
56+ } }
57+ >
58+ < FileCopyIcon />
59+ </ IconButton >
60+ </ Tooltip >
61+ ) ;
62+ } else {
63+ return "" ;
64+ }
65+ }
66+
67+
2268function CompareIcon ( props ) {
2369 if ( props . compareFlag === null ) {
2470 return (
@@ -189,8 +235,11 @@ class TestDetailHeader extends React.Component {
189235 ) ;
190236 }
191237
238+ const [ status ] = this . context . status ;
239+
192240 return (
193241 < React . Fragment >
242+ < WarningBox message = { status } />
194243 < Grid item >
195244 < Typography variant = "h4" gutterBottom >
196245 < span
@@ -207,30 +256,14 @@ class TestDetailHeader extends React.Component {
207256 { " " }
208257 { this . props . name }
209258 </ span >
210- < Tooltip placement = "top" title = "Edit Test" >
211- < IconButton
212- aria-label = "edit test"
213- onClick = { ( ) => this . handleEditClick ( ) }
214- style = { {
215- backgroundColor : Theme . buttonPrimary ,
216- marginLeft : 10 ,
217- } }
218- >
219- < EditIcon />
220- </ IconButton >
221- </ Tooltip >
222- < Tooltip placement = "top" title = "Duplicate Test" >
223- < IconButton
224- aria-label = "duplicate test"
225- onClick = { ( ) => this . handleDuplicateClick ( ) }
226- style = { {
227- backgroundColor : Theme . buttonPrimary ,
228- marginLeft : 10 ,
229- } }
230- >
231- < FileCopyIcon />
232- </ IconButton >
233- </ Tooltip >
259+ < EditButton
260+ canEdit = { status . includes ( "read-only" ) ? false : true }
261+ handleEditClick = { this . handleEditClick }
262+ />
263+ < DuplicateButton
264+ canDuplicate = { status . includes ( "read-only" ) ? false : true }
265+ handleDuplicateClick = { this . handleDuplicateClick }
266+ />
234267 < CompareIcon
235268 compareFlag = { this . props . compareFlag }
236269 addTestCompare = { this . props . addTestCompare }
0 commit comments