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

feat: Add new Vue FilePicker from @nextcloud/dialogs and use it by default #39792

Merged
merged 8 commits into from
Aug 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/files/src/components/TransferOwnershipDialogue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ import logger from '../logger.js'

const picker = getFilePickerBuilder(t('files', 'Choose a file or folder to transfer'))
.setMultiSelect(false)
.setModal(true)
.setType(1)
.allowDirectories()
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export default {
const picker = getFilePickerBuilder(t('files', 'Choose a default folder for accepted shares'))
.startAt(this.readableDirectory)
.setMultiSelect(false)
.setModal(true)
.setType(1)
.setMimeTypeFilter(['httpd/unix-directory'])
.allowDirectories()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ const VALID_MIME_TYPES = ['image/png', 'image/jpeg']
const picker = getFilePickerBuilder(t('settings', 'Choose your profile picture'))
.setMultiSelect(false)
.setMimeTypeFilter(VALID_MIME_TYPES)
.setModal(true)
.setType(1)
.allowDirectories(false)
.build()
Expand Down
8 changes: 6 additions & 2 deletions apps/theming/src/admin-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

import { getRequestToken } from '@nextcloud/auth'
import Vue from 'vue'
import App from './AdminTheming.vue'

import { refreshStyles } from './helpers/refreshStyles.js'
import App from './AdminTheming.vue'

// eslint-disable-next-line camelcase
__webpack_nonce__ = btoa(getRequestToken())

Vue.prototype.OC = OC
Vue.prototype.t = t
Expand Down
45 changes: 31 additions & 14 deletions apps/theming/src/components/BackgroundSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,30 +91,25 @@

<script>
import { generateFilePath, generateRemoteUrl, generateUrl } from '@nextcloud/router'
import { getCurrentUser } from '@nextcloud/auth'
import { getFilePickerBuilder, showError } from '@nextcloud/dialogs'
import { loadState } from '@nextcloud/initial-state'
import { Palette } from 'node-vibrant/lib/color.js'
import axios from '@nextcloud/axios'
import Check from 'vue-material-design-icons/Check.vue'
import Close from 'vue-material-design-icons/Close.vue'
import ImageEdit from 'vue-material-design-icons/ImageEdit.vue'
import debounce from 'debounce'
import NcColorPicker from '@nextcloud/vue/dist/Components/NcColorPicker.js'
import Vibrant from 'node-vibrant'
import { Palette } from 'node-vibrant/lib/color.js'
import { getFilePickerBuilder } from '@nextcloud/dialogs'
import { getCurrentUser } from '@nextcloud/auth'

import Check from 'vue-material-design-icons/Check.vue'
import Close from 'vue-material-design-icons/Close.vue'
import ImageEdit from 'vue-material-design-icons/ImageEdit.vue'

const backgroundImage = loadState('theming', 'backgroundImage')
const shippedBackgroundList = loadState('theming', 'shippedBackgrounds')
const themingDefaultBackground = loadState('theming', 'themingDefaultBackground')
const defaultShippedBackground = loadState('theming', 'defaultShippedBackground')

const prefixWithBaseUrl = (url) => generateFilePath('theming', '', 'img/background/') + url
const picker = getFilePickerBuilder(t('theming', 'Select a background from your files'))
.setMultiSelect(false)
.setModal(true)
.setType(1)
.setMimeTypeFilter(['image/png', 'image/gif', 'image/jpeg', 'image/svg+xml', 'image/svg'])
.build()

export default {
name: 'BackgroundSettings',
Expand Down Expand Up @@ -256,8 +251,30 @@ export default {
this.pickColor(...args)
}, 200),

async pickFile() {
const path = await picker.pick()
pickFile() {
const picker = getFilePickerBuilder(t('theming', 'Select a background from your files'))
.allowDirectories(false)
.setMimeTypeFilter(['image/png', 'image/gif', 'image/jpeg', 'image/svg+xml', 'image/svg'])
.setMultiSelect(false)
.addButton({
id: 'select',
label: t('theming', 'Select background'),
callback: (nodes) => {
this.applyFile(nodes[0]?.path)
},
type: 'primary',
})
.build()
picker.pick()
},

async applyFile(path) {
if (!path || typeof path !== 'string' || path.trim().length === 0 || path === '/') {
console.error('No valid background have been selected', { path })
showError(t('theming', 'No background have been selected'))
return
}

this.loading = 'custom'

// Extract primary color from image
Expand Down
8 changes: 6 additions & 2 deletions apps/theming/src/personal-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

import { getRequestToken } from '@nextcloud/auth'
import Vue from 'vue'
import App from './UserThemes.vue'

import { refreshStyles } from './helpers/refreshStyles.js'
import App from './UserThemes.vue'

// eslint-disable-next-line camelcase
__webpack_nonce__ = btoa(getRequestToken())

Vue.prototype.OC = OC
Vue.prototype.t = t
Expand Down
2 changes: 1 addition & 1 deletion core/css/mobile.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/css/mobile.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 0 additions & 15 deletions core/css/mobile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,6 @@
min-width: variables.$breakpoint-mobile !important;
}

/* do not show dates in filepicker */
#oc-dialog-filepicker-content .filelist .column-size,
#oc-dialog-filepicker-content .filelist .column-mtime,
#oc-dialog-filepicker-content .filelist .filesize,
#oc-dialog-filepicker-content .filelist .date {
display: none;
}
#oc-dialog-filepicker-content .filelist .filename {
max-width: 100%;
}

.snapjs-left table.multiselect thead {
top: 44px;
}

/* end of media query */
}

Expand Down
2 changes: 1 addition & 1 deletion core/css/server.css

Large diffs are not rendered by default.

Loading
Loading