Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
29a7f7f
feat(files_trashbin): migrate to vue
skjnldsv Jan 13, 2023
03c3277
feat(files): switch to pinia
skjnldsv Feb 4, 2023
638b3df
perf(files): update files store by chunks
skjnldsv Feb 4, 2023
2ff1c00
fix(files_trashbin): previews crop support
skjnldsv Feb 5, 2023
b761039
perf(files): fetch previews faster and cache properly
skjnldsv Mar 17, 2023
10010fc
feat(files): sorting
skjnldsv Mar 21, 2023
f330813
feat(files): custom columns
skjnldsv Mar 22, 2023
0db210a
chore(deps): cleanup unused deps and audit
skjnldsv Mar 22, 2023
0b4da61
feat(files): actions api
skjnldsv Mar 23, 2023
3c3050c
feat(files): implement sorting per view
skjnldsv Mar 24, 2023
0e764f7
fix(files): fix custom render components reactivity
skjnldsv Mar 24, 2023
0f717d4
feat(accessibility): add files table caption and summary
skjnldsv Mar 24, 2023
e85eb4c
fix(files): selection and render performance
skjnldsv Mar 24, 2023
f28944e
feat(files): propagate restore and delete events
skjnldsv Mar 25, 2023
bda286c
perf(files): less verbose
skjnldsv Mar 25, 2023
6358e97
fix(files): inline action styling
skjnldsv Mar 25, 2023
2b25199
fix(files): accessibility tab into recycled invisible files rows
skjnldsv Mar 25, 2023
7215a9a
fix(files): breadcrumbs accessibility title
skjnldsv Mar 28, 2023
4942747
fix(files): use inline NcActions
skjnldsv Mar 28, 2023
60b74e3
feat(files): batch actions
skjnldsv Mar 28, 2023
044e824
chore(deps): update lockfile
skjnldsv Mar 28, 2023
c7c9ee1
feat(files): move userconfig to dedicated store and fix crop previews
skjnldsv Mar 31, 2023
a66cae0
fix(deps): update webdav 5 usage
skjnldsv Mar 31, 2023
014a57e
fix: improved preview handling
skjnldsv Apr 4, 2023
bdbe477
feat(files): add FileAction service
skjnldsv Apr 4, 2023
904348b
chore(npm): build assets
skjnldsv Apr 4, 2023
1361182
chore(eslint): clean and fix
skjnldsv Apr 4, 2023
f060e5a
fix(tests): update jsunit tests after dep and files update
skjnldsv Apr 4, 2023
d432e0c
fix(cypress): component testing with pinia
skjnldsv Apr 5, 2023
8298bb4
fix:(files-checker): add cypress.d.ts and custom.d.ts
skjnldsv Apr 5, 2023
ea3e77d
fix(files): better wording and catch single action run
skjnldsv Apr 5, 2023
5b3900e
fix(tests): acceptance
skjnldsv Apr 6, 2023
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
Prev Previous commit
Next Next commit
fix(files_trashbin): previews crop support
Signed-off-by: John Molakvoæ <[email protected]>
  • Loading branch information
skjnldsv committed Apr 6, 2023
commit 2ff1c00f556633c9c36a9328d4eb77eba2dd25e7
20 changes: 18 additions & 2 deletions apps/files/src/components/BreadCrumbs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<NcBreadcrumb v-for="section in sections"
:key="section.dir"
:aria-label="t('files', `Go to the '{dir}' directory`, section)"
v-bind="section" />
v-bind="section"
@click="onClick(section.to)" />
</NcBreadcrumbs>
</template>

Expand Down Expand Up @@ -32,7 +33,9 @@ export default Vue.extend({
computed: {
dirs() {
const cumulativePath = (acc) => (value) => (acc += `${value}/`)
return ['/', ...this.path.split('/').filter(Boolean).map(cumulativePath('/'))]
const paths = this.path.split('/').filter(Boolean).map(cumulativePath('/'))
// Strip away trailing slash
return ['/', ...paths.map(path => path.replace(/^(.+)\/$/, '$1'))]
},

sections() {
Expand All @@ -46,6 +49,15 @@ export default Vue.extend({
})
},
},

methods: {
onClick(to) {
debugger
if (to?.query?.dir === this.$route.query.dir) {
alert('You are already here!')
}
},
},
})
</script>

Expand All @@ -54,6 +66,10 @@ export default Vue.extend({
// Take as much space as possible
flex: 1 1 100% !important;
width: 100%;

::v-deep a {
cursor: pointer !important;
}
}

</style>
48 changes: 48 additions & 0 deletions apps/files/src/components/FileEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
<!-- Icon or preview -->
<td class="files-list__row-icon">
<FolderIcon v-if="source.type === 'folder'" />
<!-- Decorative image, should not be aria documented -->
<span v-else-if="previewUrl"
:style="{ backgroundImage: `url('${previewUrl}')` }"
class="files-list__row-icon-preview" />
</td>

<!-- Link to file and -->
Expand All @@ -39,6 +43,20 @@
{{ displayName }}
</a>
</td>

<!-- Actions -->
<td class="files-list__row-actions">
<NcActions>
<NcActionButton>
{{ t('files', 'Rename') }}
<Pencil slot="icon" />
</NcActionButton>
<NcActionButton>
{{ t('files', 'Delete') }}
<TrashCan slot="icon" />
</NcActionButton>
</NcActions>
</td>
</Fragment>
</template>

Expand All @@ -48,20 +66,33 @@ import { Fragment } from 'vue-fragment'
import { join } from 'path'
import { translate } from '@nextcloud/l10n'
import FolderIcon from 'vue-material-design-icons/Folder.vue'
import TrashCan from 'vue-material-design-icons/TrashCan.vue'
import Pencil from 'vue-material-design-icons/Pencil.vue'
import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js'
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
import Vue from 'vue'

import logger from '../logger'
import { useSelectionStore } from '../store/selection'
import { useFilesStore } from '../store/files'
import { loadState } from '@nextcloud/initial-state'

// TODO: move to store
// TODO: watch 'files:config:updated' event
const userConfig = loadState('files', 'config', {})

export default Vue.extend({
name: 'FileEntry',

components: {
FolderIcon,
Fragment,
NcActionButton,
NcActions,
NcCheckboxRadioSwitch,
Pencil,
TrashCan,
},

props: {
Expand All @@ -84,6 +115,12 @@ export default Vue.extend({
}
},

data() {
return {
userConfig,
}
},

computed: {
dir() {
// Remove any trailing slash but leave root slash
Expand Down Expand Up @@ -123,6 +160,17 @@ export default Vue.extend({
this.selectionStore.set(selection)
},
},

previewUrl() {
try {
const url = new URL(window.location.origin + this.source.attributes.previewUrl)
const cropping = this.userConfig?.crop_image_previews === true
url.searchParams.set('a', cropping ? '1' : '0')
return url.href
} catch (e) {
return null
}
},
},

methods: {
Expand Down
3 changes: 3 additions & 0 deletions apps/files/src/components/FilesListHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
<th class="files-list__row-name">
{{ t('files', 'Name') }}
</th>

<!-- Actions -->
<th class="files-list__row-actions" />
</tr>
</template>

Expand Down
4 changes: 3 additions & 1 deletion apps/files/src/components/FilesListVirtual.vue
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ export default Vue.extend({
background-color: var(--color-main-background);
}

thead, .files-list__row {
tr {
display: flex;
align-items: center;
border-bottom: 1px solid var(--color-border);
}
}
Expand Down
44 changes: 33 additions & 11 deletions apps/files/src/mixins/fileslist-row.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,29 @@
*
*/
td, th {
display: flex;
align-items: center;
flex: 0 0 var(--row-height);
justify-content: center;
width: var(--row-height);
height: var(--row-height);
vertical-align: middle;
padding: 0px;
padding: 0;
border: none;
}

.files-list__row-checkbox {
width: var(--row-height);
&::v-deep .checkbox-radio-switch {
--icon-size: var(--checkbox-size);

display: flex;
justify-content: center;

--icon-size: var(--checkbox-size);

label.checkbox-radio-switch__label {
margin: 0;
height: var(--clickable-area);
width: var(--clickable-area);
padding: calc((var(--clickable-area) - var(--checkbox-size)) / 2)
height: var(--clickable-area);
margin: 0;
padding: calc((var(--clickable-area) - var(--checkbox-size)) / 2);
}

.checkbox-radio-switch__icon {
Expand All @@ -48,16 +52,34 @@ td, th {
}

.files-list__row-icon {
// Remove left padding to look nicer with the checkbox
// => ico preview size + one checkbox td padding
width: calc(var(--icon-preview-size) + var(--checkbox-padding));
padding-right: var(--checkbox-padding);
flex: 0 0 var(--icon-preview-size);
justify-content: left;
// Show same padding as the checkbox right padding for visual balance
margin-right: var(--checkbox-padding);
color: var(--color-primary-element);

& > span {
justify-content: flex-start;
}

&::v-deep svg {
width: var(--icon-preview-size);
height: var(--icon-preview-size);
}

&-preview {
width: var(--icon-preview-size);
height: var(--icon-preview-size);
// Center and contain the preview
background-position: center;
background-repeat: no-repeat;
background-size: contain;
border-radius: var(--border-radius);
overflow: hidden;
}
}

.files-list__row-name {
flex: 1 1 100%;
justify-content: left;
}
7 changes: 4 additions & 3 deletions apps/files_trashbin/lib/Controller/PreviewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ public function __construct(
*/
public function getPreview(
int $fileId = -1,
int $x = 128,
int $y = 128
int $x = 32,
int $y = 32,
bool $a = false,
) {
if ($fileId === -1 || $x === 0 || $y === 0) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
Expand Down Expand Up @@ -118,7 +119,7 @@ public function getPreview(
$mimeType = $this->mimeTypeDetector->detectPath($file->getName());
}

$f = $this->previewManager->getPreview($file, $x, $y, true, IPreview::MODE_FILL, $mimeType);
$f = $this->previewManager->getPreview($file, $x, $y, $a, IPreview::MODE_FILL, $mimeType);

Check notice

Code scanning / Psalm

ArgumentTypeCoercion

Argument 1 of OCP\IPreview::getPreview expects OCP\Files\File, but parent type OCP\Files\Node provided
$response = new Http\FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]);

// Cache previews for 24H
Expand Down
5 changes: 4 additions & 1 deletion apps/files_trashbin/src/services/trashbin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/* eslint-disable */
import { getCurrentUser } from '@nextcloud/auth'
import { File, Folder, parseWebdavPermissions } from '@nextcloud/files'
import { generateRemoteUrl } from '@nextcloud/router'
import { generateRemoteUrl, generateUrl } from '@nextcloud/router'

import type { FileStat, ResponseDataDetailed } from 'webdav'
import type { ContentsWithRoot } from '../../../files/src/services/Navigation'
Expand All @@ -49,9 +49,11 @@ const data = `<?xml version="1.0"?>
</d:prop>
</d:propfind>`


const resultToNode = function(node: FileStat): File | Folder {
const permissions = parseWebdavPermissions(node.props?.permissions)
const owner = getCurrentUser()?.uid as string
const previewUrl = generateUrl('/apps/files_trashbin/preview?fileId={fileid}', node.props)

const nodeData = {
id: node.props?.fileid as number || 0,
Expand All @@ -67,6 +69,7 @@ const resultToNode = function(node: FileStat): File | Folder {
...node.props,
// Override displayed name on the list
displayName: node.props?.['trashbin-filename'],
previewUrl,
},
}

Expand Down