-
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.
- Loading branch information
1 parent
0ddf0d0
commit ae84c52
Showing
5 changed files
with
89 additions
and
46 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
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 './useFolderLink' |
65 changes: 65 additions & 0 deletions
65
packages/web-pkg/src/composables/folderLink/useFolderLink.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,65 @@ | ||
import { Resource } from '@ownclouders/web-client' | ||
import { | ||
extractParentFolderName, | ||
isProjectSpaceResource, | ||
isShareRoot, | ||
isShareSpaceResource | ||
} from '@ownclouders/web-client/src/helpers' | ||
import { useGettext } from 'vue3-gettext' | ||
import { unref } from 'vue' | ||
import { computed } from 'vue/dist/vue' | ||
import { useCapabilityShareJailEnabled } from '../capability' | ||
import { useGetMatchingSpace } from '../spaces' | ||
|
||
export const useFolderLink = () => { | ||
const { $gettext } = useGettext() | ||
const hasShareJail = useCapabilityShareJailEnabled() | ||
const { getInternalSpace, getMatchingSpace } = useGetMatchingSpace() | ||
|
||
const getParentFolderName = (resource: Resource) => { | ||
if (isShareRoot(resource)) { | ||
return $gettext('Shared with me') | ||
} | ||
|
||
const parentFolder = extractParentFolderName(resource) | ||
if (parentFolder) { | ||
return parentFolder | ||
} | ||
|
||
if (!unref(hasShareJail)) { | ||
return $gettext('All files and folders') | ||
} | ||
|
||
if (isProjectSpaceResource(resource)) { | ||
return $gettext('Spaces') | ||
} | ||
|
||
const matchingSpace = unref(getMatchingSpace(resource)) | ||
if (isProjectSpaceResource(matchingSpace) || isShareSpaceResource(matchingSpace)) { | ||
return matchingSpace.name | ||
} | ||
|
||
return $gettext('Personal') | ||
} | ||
|
||
const getParentFolderLinkIconAdditionalAttributes = (resource: Resource) => { | ||
// Identify if resource is project space or is part of a project space and the resource is located in its root | ||
if ( | ||
isProjectSpaceResource(resource) || | ||
(isProjectSpaceResource(getInternalSpace(resource.storageId) || ({} as Resource)) && | ||
resource.path.split('/').length === 2) | ||
) { | ||
return { | ||
name: 'layout-grid', | ||
'fill-type': 'fill' | ||
} | ||
} | ||
|
||
return {} | ||
} | ||
|
||
return { | ||
getParentFolderName, | ||
getParentFolderLinkIconAdditionalAttributes | ||
} | ||
} |
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