-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move quick actions into injection context
- Loading branch information
1 parent
340ea48
commit 210db22
Showing
13 changed files
with
133 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './spaces' | ||
export * from './useQuickActions' |
54 changes: 54 additions & 0 deletions
54
packages/web-app-files/src/composables/actions/useQuickActions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Ref, computed } from 'vue' | ||
import { useGettext } from 'vue3-gettext' | ||
import { | ||
eventBus, | ||
SideBarEventTopics, | ||
copyQuicklink, | ||
FileAction, | ||
useStore, | ||
useAbility, | ||
usePasswordPolicyService, | ||
useClientService, | ||
useCanShare | ||
} from '@ownclouders/web-pkg' | ||
|
||
export const useQuickActions = (): Ref<Record<string, FileAction>> => { | ||
const store = useStore() | ||
const ability = useAbility() | ||
const passwordPolicyService = usePasswordPolicyService() | ||
const { canShare } = useCanShare() | ||
const clientService = useClientService() | ||
const language = useGettext() | ||
const { $gettext } = language | ||
|
||
return computed(() => ({ | ||
collaborators: { | ||
name: 'quick-action-collaborators', | ||
id: 'collaborators', | ||
componentType: 'button', | ||
label: () => $gettext('Add people'), | ||
icon: 'user-add', | ||
handler: () => eventBus.publish(SideBarEventTopics.openWithPanel, 'sharing#peopleShares'), | ||
isEnabled: ({ resources }) => canShare(resources[0]) | ||
}, | ||
quicklink: { | ||
name: 'quick-action-quicklink', | ||
id: 'quicklink', | ||
componentType: 'button', | ||
label: () => $gettext('Copy link'), | ||
icon: 'link', | ||
handler: async ({ resources }) => { | ||
console.log(22, passwordPolicyService) | ||
await copyQuicklink({ | ||
ability, | ||
passwordPolicyService, | ||
clientService, | ||
language, | ||
resource: resources[0], | ||
store | ||
}) | ||
}, | ||
isEnabled: ({ resources }) => canShare(resources[0]) | ||
} | ||
})) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './useCanShare' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Resource } from '@ownclouders/web-client' | ||
import { useStore } from '../store' | ||
import { useAbility } from '../ability' | ||
|
||
export const useCanShare = () => { | ||
const store = useStore() | ||
const ability = useAbility() | ||
|
||
const canShare = (item: Resource) => { | ||
const { capabilities } = store.state.user | ||
if (!capabilities.files_sharing || !capabilities.files_sharing.api_enabled) { | ||
return false | ||
} | ||
if (item.isReceivedShare() && !capabilities.files_sharing.resharing) { | ||
return false | ||
} | ||
return item.canShare({ ability }) | ||
} | ||
|
||
return { canShare } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.