@@ -13,11 +13,14 @@ import TextButton from '../UI/TextButton';
1313import RaisedButton from '../UI/RaisedButton' ;
1414import RaisedButtonWithSplitMenu from '../UI/RaisedButtonWithSplitMenu' ;
1515import { Column , Line } from '../UI/Grid' ;
16- import { installPublicAsset } from './InstallAsset' ;
16+ import {
17+ checkRequiredExtensionUpdate ,
18+ installRequiredExtensions ,
19+ installPublicAsset ,
20+ } from './InstallAsset' ;
1721import EventsFunctionsExtensionsContext from '../EventsFunctionsExtensionsLoader/EventsFunctionsExtensionsContext' ;
1822import { showErrorBox } from '../UI/Messages/MessageBox' ;
1923import LinearProgress from '../UI/LinearProgress' ;
20- import { AssetStoreContext } from './AssetStoreContext' ;
2124import PrivateAssetsAuthorizationContext from './PrivateAssets/PrivateAssetsAuthorizationContext' ;
2225import { type ResourceManagementProps } from '../ResourcesList/ResourceSource' ;
2326import PromisePool from '@supercharge/promise-pool' ;
@@ -27,6 +30,10 @@ import RadioGroup from '@material-ui/core/RadioGroup';
2730import { mapFor } from '../Utils/MapFor' ;
2831import FormControlLabel from '@material-ui/core/FormControlLabel' ;
2932import AlertMessage from '../UI/AlertMessage' ;
33+ import {
34+ useExtensionUpdateAlertDialog ,
35+ useFetchAssets ,
36+ } from './NewObjectDialog' ;
3037import { type InstallAssetOutput } from './InstallAsset' ;
3138
3239type Props = { |
@@ -37,7 +44,7 @@ type Props = {|
3744 onAssetsAdded : ( ) => void ,
3845 project : gdProject ,
3946 objectsContainer : ?gdObjectsContainer ,
40- onObjectAddedFromAsset : ( object : gdObject ) => void ,
47+ onObjectsAddedFromAssets : ( objects : Array < gdObject > ) => void ,
4148 resourceManagementProps : ResourceManagementProps ,
4249 canInstallPrivateAsset : ( ) => boolean ,
4350| } ;
@@ -50,7 +57,7 @@ const AssetPackInstallDialog = ({
5057 onAssetsAdded,
5158 project,
5259 objectsContainer,
53- onObjectAddedFromAsset ,
60+ onObjectsAddedFromAssets ,
5461 canInstallPrivateAsset,
5562 resourceManagementProps,
5663} : Props ) => {
@@ -85,7 +92,8 @@ const AssetPackInstallDialog = ({
8592 PrivateAssetsAuthorizationContext
8693 ) ;
8794
88- const { environment } = React . useContext ( AssetStoreContext ) ;
95+ const fetchAssets = useFetchAssets ( ) ;
96+ const showExtensionUpdateConfirmation = useExtensionUpdateAlertDialog ( ) ;
8997
9098 const [ selectedLayoutName , setSelectedLayoutName ] = React . useState < string > (
9199 ''
@@ -135,24 +143,39 @@ const AssetPackInstallDialog = ({
135143
136144 setAreAssetsBeingInstalled ( true ) ;
137145 try {
146+ const assets = await fetchAssets ( assetShortHeaders ) ;
147+ const requiredExtensionInstallation = await checkRequiredExtensionUpdate (
148+ {
149+ assets,
150+ project,
151+ }
152+ ) ;
153+ const shouldUpdateExtension =
154+ requiredExtensionInstallation . outOfDateExtensions . length > 0 &&
155+ ( await showExtensionUpdateConfirmation (
156+ requiredExtensionInstallation . outOfDateExtensions
157+ ) ) ;
158+ await installRequiredExtensions ( {
159+ requiredExtensionInstallation,
160+ shouldUpdateExtension,
161+ eventsFunctionsExtensionsState,
162+ project,
163+ } ) ;
164+
138165 // Use a pool to avoid installing an unbounded amount of assets at the same time.
139166 const { results, errors } = await PromisePool . withConcurrency ( 6 )
140- . for ( assetShortHeaders )
141- . process < InstallAssetOutput > ( async assetShortHeader => {
142- const installOutput = isPrivateAsset ( assetShortHeader )
167+ . for ( assets )
168+ . process < InstallAssetOutput > ( async asset => {
169+ const installOutput = isPrivateAsset ( asset )
143170 ? await installPrivateAsset ( {
144- assetShortHeader,
145- eventsFunctionsExtensionsState,
171+ asset,
146172 project,
147173 objectsContainer : targetObjectsContainer ,
148- environment,
149174 } )
150175 : await installPublicAsset ( {
151- assetShortHeader,
152- eventsFunctionsExtensionsState,
176+ asset,
153177 project,
154178 objectsContainer : targetObjectsContainer ,
155- environment,
156179 } ) ;
157180
158181 if ( ! installOutput ) {
@@ -169,11 +192,9 @@ const AssetPackInstallDialog = ({
169192 ) ;
170193 }
171194
172- results . forEach ( installOutput => {
173- installOutput . createdObjects . forEach ( object => {
174- onObjectAddedFromAsset ( object ) ;
175- } ) ;
176- } ) ;
195+ onObjectsAddedFromAssets (
196+ results . map ( installOutput => installOutput . createdObjects ) . flat ( )
197+ ) ;
177198
178199 await resourceManagementProps . onFetchNewlyAddedResources ( ) ;
179200
@@ -191,14 +212,15 @@ const AssetPackInstallDialog = ({
191212 }
192213 } ,
193214 [
194- eventsFunctionsExtensionsState ,
215+ fetchAssets ,
195216 project ,
196- targetObjectsContainer ,
197- onObjectAddedFromAsset ,
217+ showExtensionUpdateConfirmation ,
218+ eventsFunctionsExtensionsState ,
219+ onObjectsAddedFromAssets ,
220+ resourceManagementProps ,
198221 onAssetsAdded ,
199- environment ,
200222 installPrivateAsset ,
201- resourceManagementProps ,
223+ targetObjectsContainer ,
202224 ]
203225 ) ;
204226
0 commit comments