Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get files app config and use it for the file picker #973

Merged
merged 4 commits into from
Oct 17, 2023
Merged

Conversation

susnux
Copy link
Contributor

@susnux susnux commented Aug 28, 2023

Done:

  • Get config
  • sort favorites first
  • show hidden files if configured
  • crop previews
  • sort by files app order
  • unit tests

@susnux susnux added the enhancement New feature or request label Aug 28, 2023
@susnux susnux added this to the 5.0.0 milestone Sep 12, 2023
Comment on lines 54 to 75
export const useFilesSettings = () => {
const filesUserState = loadState<OCAFilesUserConfig|null>('files', 'config', null)

const showHiddenFiles = ref(filesUserState?.show_hidden ?? false)
const sortFavoritesFirst = ref(filesUserState?.sort_favorites_first ?? true)
const cropImagePreviews = ref(filesUserState?.crop_image_previews ?? true)

if (filesUserState === null) {
axios.get(generateUrl('/apps/files/api/v1/configs')).then((respose) => {
showHiddenFiles.value = respose.data?.data?.show_hidden ?? false
sortFavoritesFirst.value = respose.data?.data?.sort_favorites_first ?? true
cropImagePreviews.value = respose.data?.data?.crop_image_previews ?? true
})
}

return {
showHiddenFiles,
sortFavoritesFirst,
cropImagePreviews,
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should have this in @nextcloud/files?
I feel like adding more config on server will make the upgrade/implementation process much more complicated 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean any function to access the config or the composable?
Generally I would say it would make sense to provide a common way to access the configuration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but maybe we could have a way to not have those configs hardcoded somehow. So if we add a new one in the server backend, we don't have to update 20 other locations? 🤔
No idea how to pull that off 🙈

@susnux susnux force-pushed the feat/files-settings branch 2 times, most recently from 8391571 to 4114aad Compare October 3, 2023 00:48
@susnux susnux marked this pull request as ready for review October 3, 2023 00:57
@susnux susnux force-pushed the feat/files-settings branch 3 times, most recently from eaa8d0e to 46b7572 Compare October 6, 2023 14:53
@susnux susnux requested review from skjnldsv and ShGKme October 6, 2023 14:53
@susnux susnux force-pushed the feat/files-settings branch 2 times, most recently from 93fbdcf to 05dee3a Compare October 6, 2023 15:51
@codecov
Copy link

codecov bot commented Oct 6, 2023

Codecov Report

Merging #973 (b6d95c6) into main (85f070e) will increase coverage by 6.13%.
Report is 1 commits behind head on main.
The diff coverage is 80.91%.

❗ Current head b6d95c6 differs from pull request most recent head 82d6637. Consider uploading reports for the commit 82d6637 to get more accurate results

@@            Coverage Diff             @@
##             main     #973      +/-   ##
==========================================
+ Coverage   25.02%   31.15%   +6.13%     
==========================================
  Files          14       15       +1     
  Lines        1063     1194     +131     
  Branches       34       60      +26     
==========================================
+ Hits          266      372     +106     
  Misses        764      764              
- Partials       33       58      +25     
Files Coverage Δ
lib/composables/dav.ts 90.99% <ø> (ø)
lib/composables/mime.ts 88.88% <ø> (ø)
lib/composables/preview.ts 91.57% <100.00%> (ø)
lib/composables/filesSettings.ts 80.46% <80.46%> (ø)

* Sort favorties first if configured
* Use sorting order like the files app does
* Show hidden files if configured
* Crop file previews if configured

Signed-off-by: Ferdinand Thiessen <[email protected]>
@susnux susnux enabled auto-merge October 17, 2023 10:45
@susnux susnux merged commit 9324082 into main Oct 17, 2023
9 checks passed
@susnux susnux deleted the feat/files-settings branch October 17, 2023 10:47
@susnux susnux mentioned this pull request Oct 17, 2023
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review enhancement New feature or request
Projects
None yet
3 participants