11import { createSharedComposable } from '@vueuse/core'
22import { computed , ref } from 'vue'
33import type { useUi } from './useUi'
4- import { type UploadMediaParams , type CreateFileParams , type StudioHost , type StudioAction , type TreeItem , StudioItemActionId , type ActionHandlerParams , StudioFeature } from '../types'
4+ import {
5+ type StudioActionInProgress ,
6+ type UploadMediaParams ,
7+ type CreateFileParams ,
8+ type StudioHost ,
9+ type StudioAction ,
10+ type ActionHandlerParams ,
11+ StudioItemActionId ,
12+ StudioFeature ,
13+ } from '../types'
514import { oneStepActions , STUDIO_ITEM_ACTION_DEFINITIONS , twoStepActions } from '../utils/context'
615import type { useDraftDocuments } from './useDraftDocuments'
716import { useModal } from './useModal'
@@ -18,7 +27,7 @@ export const useContext = createSharedComposable((
1827) => {
1928 const modal = useModal ( )
2029
21- const actionInProgress = ref < StudioItemActionId | null > ( null )
30+ const actionInProgress = ref < StudioActionInProgress | null > ( null )
2231 const currentFeature = computed < keyof typeof ui . panels | null > ( ( ) =>
2332 Object . keys ( ui . panels ) . find ( key => ui . panels [ key as keyof typeof ui . panels ] ) as keyof typeof ui . panels ,
2433 )
@@ -28,7 +37,7 @@ export const useContext = createSharedComposable((
2837 return STUDIO_ITEM_ACTION_DEFINITIONS . map ( action => ( {
2938 ...action ,
3039 handler : async ( args ) => {
31- if ( actionInProgress . value === action . id ) {
40+ if ( actionInProgress . value ?. id === action . id ) {
3241 // Two steps actions need to be already in progress to be executed
3342 if ( twoStepActions . includes ( action . id ) ) {
3443 await itemActionHandler [ action . id ] ( args as never )
@@ -41,7 +50,7 @@ export const useContext = createSharedComposable((
4150 }
4251 }
4352
44- actionInProgress . value = action . id
53+ actionInProgress . value = { id : action . id , item : args . item }
4554
4655 // One step actions can be executed immediately
4756 if ( oneStepActions . includes ( action . id ) ) {
@@ -71,8 +80,8 @@ export const useContext = createSharedComposable((
7180 await draft . value . revert ( id )
7281 } )
7382 } ,
74- [ StudioItemActionId . RenameItem ] : async ( { path , file } : { path : string , file : TreeItem } ) => {
75- alert ( `rename file ${ path } ${ file . name } ` )
83+ [ StudioItemActionId . RenameItem ] : async ( { id , newNameWithExtension } : { id : string , newNameWithExtension : string } ) => {
84+ alert ( `rename file ${ id } ${ newNameWithExtension } ` )
7685 } ,
7786 [ StudioItemActionId . DeleteItem ] : async ( id : string ) => {
7887 modal . openConfirmActionModal ( id , StudioItemActionId . DeleteItem , async ( ) => {
0 commit comments