@@ -21,6 +21,7 @@ import {
2121} from './DomainPropertiesPanelCollapse' ;
2222
2323interface OwnProps {
24+ dataTypeCopyId ?: number ; // RowId for the data type being copied, if applicable
2425 dataTypeName ?: string ;
2526 dataTypeRowId ?: number ;
2627 entityDataType : EntityDataType ;
@@ -30,11 +31,12 @@ interface OwnProps {
3031}
3132
3233// export for jest testing
33- export const DataTypeFoldersPanelImpl : FC < OwnProps & InjectedDomainPropertiesPanelCollapseProps > = memo ( props => {
34+ export const DataTypeFoldersPanelImpl : FC < InjectedDomainPropertiesPanelCollapseProps & OwnProps > = memo ( props => {
3435 const {
3536 collapsed,
3637 togglePanel,
3738 controlledCollapse,
39+ dataTypeCopyId,
3840 dataTypeRowId,
3941 dataTypeName,
4042 onUpdateExcludedFolders,
@@ -53,6 +55,8 @@ export const DataTypeFoldersPanelImpl: FC<OwnProps & InjectedDomainPropertiesPan
5355 const [ excludedContainerIdsDB , setExcludedContainerIdsDB ] = useState < string [ ] > ( ) ;
5456 const [ excludedContainerIds , setExcludedContainerIds ] = useState < string [ ] > ( ) ;
5557 const [ relatedExcludedContainerIdsDB , setRelatedExcludedContainerIdsDB ] = useState < string [ ] > ( ) ;
58+ const copy = ! ! dataTypeCopyId && ! dataTypeRowId ;
59+ const isNewEntity = ! dataTypeRowId && ! copy ;
5660
5761 useEffect (
5862 ( ) => {
@@ -62,6 +66,7 @@ export const DataTypeFoldersPanelImpl: FC<OwnProps & InjectedDomainPropertiesPan
6266
6367 try {
6468 const containers = await api . folder . getContainers ( container , moduleContext , true , true , true ) ;
69+ const dataTypeRowId_ = copy ? dataTypeCopyId : dataTypeRowId ;
6570
6671 const allContainers_ = containers . map ( container_ => {
6772 return {
@@ -77,10 +82,13 @@ export const DataTypeFoldersPanelImpl: FC<OwnProps & InjectedDomainPropertiesPan
7782
7883 const excludedContainerIds_ = await api . folder . getDataTypeExcludedContainers (
7984 entityDataType . folderConfigurableDataType ,
80- dataTypeRowId
85+ dataTypeRowId_
8186 ) ;
8287 setExcludedContainerIdsDB ( excludedContainerIds_ ) ;
8388 setExcludedContainerIds ( excludedContainerIds_ ) ;
89+ if ( copy ) {
90+ onUpdateExcludedFolders ( entityDataType . folderConfigurableDataType , excludedContainerIds_ ) ;
91+ }
8492
8593 const allDataCounts_ = await api . query . getDataTypeFolderDataCount (
8694 entityDataType ,
@@ -138,19 +146,19 @@ export const DataTypeFoldersPanelImpl: FC<OwnProps & InjectedDomainPropertiesPan
138146
139147 return (
140148 < BasePropertiesPanel
141- headerId = "domain-folders-hdr"
142- title = "Folders"
143149 collapsed = { collapsed }
144150 controlledCollapse = { controlledCollapse }
151+ headerId = "domain-folders-hdr"
145152 isValid
146153 panelStatus = { collapsed && isValid ? 'COMPLETE' : isValid ? 'INPROGRESS' : 'TODO' }
147- updateValidStatus = { updateValidStatus }
154+ title = "Folders"
148155 todoIconHelpMsg = {
149156 'This section defines which folders use this ' +
150157 entityDataType . typeNounSingular . toLowerCase ( ) +
151158 '. You may want to review.'
152159 }
153160 togglePanel = { togglePanel }
161+ updateValidStatus = { updateValidStatus }
154162 >
155163 < div className = "bottom-padding" >
156164 Select which folders can use this { entityDataType . typeNounSingular . toLowerCase ( ) } .
@@ -169,47 +177,47 @@ export const DataTypeFoldersPanelImpl: FC<OwnProps & InjectedDomainPropertiesPan
169177 { ! relatedFolderConfigurableDataType && (
170178 < div className = "col-xs-12 bottom-padding" >
171179 < DataTypeSelector
172- entityDataType = { entityDataType }
173180 allDataCounts = { allDataCounts }
174181 allDataTypes = { childFolders }
175- updateUncheckedTypes = { updateExcludedFolders }
176- uncheckedEntitiesDB = { excludedContainerIdsDB }
177- dataTypeLabel = "folders"
178- noHeader
179182 columns = { 2 }
183+ dataTypeLabel = "folders"
184+ entityDataType = { entityDataType }
180185 inactiveSectionLabel = "Archived Folders"
181- isNewEntity = { ! dataTypeRowId }
186+ isNewEntity = { isNewEntity }
187+ noHeader
182188 showUncheckedWarning = { ! ! dataTypeRowId }
189+ uncheckedEntitiesDB = { excludedContainerIdsDB }
190+ updateUncheckedTypes = { updateExcludedFolders }
183191 />
184192 </ div >
185193 ) }
186194 { ! ! relatedFolderConfigurableDataType && (
187195 < >
188196 < div className = "col-xs-6 bottom-padding" >
189197 < DataTypeSelector
190- entityDataType = { entityDataType }
191198 allDataCounts = { allDataCounts }
192199 allDataTypes = { childFolders }
193- updateUncheckedTypes = { updateExcludedFolders }
194- uncheckedEntitiesDB = { excludedContainerIdsDB }
195200 dataTypeLabel = "Include in Folders"
201+ entityDataType = { entityDataType }
196202 inactiveSectionLabel = "Archived Folders"
197- isNewEntity = { ! dataTypeRowId }
203+ isNewEntity = { isNewEntity }
198204 showUncheckedWarning = { ! ! dataTypeRowId }
205+ uncheckedEntitiesDB = { excludedContainerIdsDB }
206+ updateUncheckedTypes = { updateExcludedFolders }
199207 />
200208 </ div >
201209 < div className = "col-xs-6 bottom-padding" >
202210 < DataTypeSelector
211+ allDataTypes = { allContainers }
212+ dataTypeLabel = { relatedDataTypeLabel }
203213 dataTypePrefix = "Dashboard"
204214 entityDataType = { entityDataType }
205- allDataTypes = { allContainers }
206- updateUncheckedTypes = { updateRelatedExcludedFolders }
207- uncheckedEntitiesDB = { relatedExcludedContainerIdsDB }
208215 hiddenEntities = { excludedContainerIds }
209- dataTypeLabel = { relatedDataTypeLabel }
210216 inactiveSectionLabel = "Archived Folders"
211- isNewEntity = { ! dataTypeRowId }
217+ isNewEntity = { isNewEntity }
212218 showUncheckedWarning = { false }
219+ uncheckedEntitiesDB = { relatedExcludedContainerIdsDB }
220+ updateUncheckedTypes = { updateRelatedExcludedFolders }
213221 />
214222 </ div >
215223 </ >
0 commit comments