1
1
// Copyright (c) Cosmo Tech.
2
2
// Licensed under the MIT license.
3
3
4
- import React , { useState , useRef , useMemo , useEffect } from 'react' ;
4
+ import React , { useEffect , useMemo , useRef , useState } from 'react' ;
5
5
import PropTypes from 'prop-types' ;
6
6
import { TextField , Typography } from '@material-ui/core' ;
7
7
import '@nosferatu500/react-sortable-tree/style.css' ;
@@ -22,6 +22,7 @@ export const ScenarioManagerTreeList = (props) => {
22
22
buildDatasetInfo,
23
23
labels,
24
24
buildScenarioNameToDelete,
25
+ showDeleteIcon,
25
26
} = props ;
26
27
27
28
// Memoize the full scenarios tree in a ReactSortableTree-compatible format
@@ -40,7 +41,7 @@ export const ScenarioManagerTreeList = (props) => {
40
41
41
42
function formatScenariosToRSTList ( treeScenarios ) {
42
43
const rstScenarios = treeScenarios . map ( ( scenario ) => {
43
- const showDeleteIcon = scenario . ownerId === userId ;
44
+ const displayDeleteIcon = scenario . ownerId === userId && showDeleteIcon ;
44
45
labels . dataset = buildDatasetInfo ( scenario . datasetList ) ;
45
46
return {
46
47
expanded : expandedNodes . current [ scenario . id ] || false ,
@@ -51,7 +52,7 @@ export const ScenarioManagerTreeList = (props) => {
51
52
< ScenarioNode
52
53
datasets = { datasets }
53
54
scenario = { scenario }
54
- showDeleteIcon = { showDeleteIcon }
55
+ showDeleteIcon = { displayDeleteIcon }
55
56
deleteScenario = { deleteScenario }
56
57
labels = { labels }
57
58
buildScenarioNameToDelete = { buildScenarioNameToDelete }
@@ -162,6 +163,12 @@ ScenarioManagerTreeList.propTypes = {
162
163
* Function building scenario dataset label
163
164
*/
164
165
buildDatasetInfo : PropTypes . func . isRequired ,
166
+ /**
167
+ * Define ScenarioNode's delete buttons state (no matter who created scenario):
168
+ * - true : the button is shown
169
+ * - false : the button is hidden
170
+ */
171
+ showDeleteIcon : PropTypes . bool ,
165
172
/**
166
173
* Structure
167
174
* <pre>
@@ -183,6 +190,7 @@ ScenarioManagerTreeList.propTypes = {
183
190
} ;
184
191
185
192
ScenarioManagerTreeList . defaultProps = {
193
+ showDeleteIcon : true ,
186
194
labels : {
187
195
status : 'Run status' ,
188
196
successful : 'Successful' ,
0 commit comments