Skip to content

Commit 6e2a9e3

Browse files
authored
Merge pull request #58691 from nextcloud/backport/58562/stable30
[stable30] feat: set creation_time on file creation and render recently created icon
2 parents 85d5e5c + 6a3f8f8 commit 6e2a9e3

14 files changed

Lines changed: 137 additions & 10 deletions

File tree

apps/dav/lib/Capabilities.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ public function __construct(IConfig $config, IAvailabilityCoordinator $coordinat
2020
}
2121

2222
/**
23-
* @return array{dav: array{chunking: string, bulkupload?: string, absence-supported?: bool, absence-replacement?: bool}}
23+
* @return array{dav: array{chunking: string, search_supports_creation_time: bool, search_supports_upload_time: bool, bulkupload?: string, absence-supported?: bool, absence-replacement?: bool}}
2424
*/
2525
public function getCapabilities() {
2626
$capabilities = [
2727
'dav' => [
2828
'chunking' => '1.0',
29+
'search_supports_creation_time' => true,
2930
'search_supports_upload_time' => true,
3031
]
3132
];

apps/dav/lib/Files/FileSearchBackend.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public function getPropertyDefinitionsForScope(string $href, ?string $path): arr
8585
new SearchPropertyDefinition('{DAV:}displayname', true, true, true),
8686
new SearchPropertyDefinition('{DAV:}getcontenttype', true, true, true),
8787
new SearchPropertyDefinition('{DAV:}getlastmodified', true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME),
88+
new SearchPropertyDefinition('{DAV:}creationdate', true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME),
8889
new SearchPropertyDefinition('{http://nextcloud.org/ns}upload_time', true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME),
8990
new SearchPropertyDefinition(FilesPlugin::SIZE_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER),
9091
new SearchPropertyDefinition(TagsPlugin::FAVORITE_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_BOOLEAN),
@@ -298,6 +299,8 @@ private function getSearchResultProperty(SearchResult $result, SearchPropertyDef
298299
return $node->getName();
299300
case '{DAV:}getlastmodified':
300301
return $node->getLastModified();
302+
case '{DAV:}creationdate':
303+
return $node->getNode()->getCreationTime();
301304
case '{http://nextcloud.org/ns}upload_time':
302305
return $node->getNode()->getUploadTime();
303306
case FilesPlugin::SIZE_PROPERTYNAME:
@@ -454,6 +457,8 @@ private function mapPropertyNameToColumn(SearchPropertyDefinition $property) {
454457
return 'mimetype';
455458
case '{DAV:}getlastmodified':
456459
return 'mtime';
460+
case '{DAV:}creationdate':
461+
return 'creation_time';
457462
case '{http://nextcloud.org/ns}upload_time':
458463
return 'upload_time';
459464
case FilesPlugin::SIZE_PROPERTYNAME:

apps/dav/openapi.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,20 @@
2929
"dav": {
3030
"type": "object",
3131
"required": [
32-
"chunking"
32+
"chunking",
33+
"search_supports_creation_time",
34+
"search_supports_upload_time"
3335
],
3436
"properties": {
3537
"chunking": {
3638
"type": "string"
3739
},
40+
"search_supports_creation_time": {
41+
"type": "boolean"
42+
},
43+
"search_supports_upload_time": {
44+
"type": "boolean"
45+
},
3846
"bulkupload": {
3947
"type": "string"
4048
},

apps/dav/tests/unit/CapabilitiesTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public function testGetCapabilities(): void {
2929
$expected = [
3030
'dav' => [
3131
'chunking' => '1.0',
32+
'search_supports_creation_time' => true,
33+
'search_supports_upload_time' => true,
3234
],
3335
];
3436
$this->assertSame($expected, $capabilities->getCapabilities());
@@ -48,6 +50,8 @@ public function testGetCapabilitiesWithBulkUpload(): void {
4850
$expected = [
4951
'dav' => [
5052
'chunking' => '1.0',
53+
'search_supports_creation_time' => true,
54+
'search_supports_upload_time' => true,
5155
'bulkupload' => '1.0',
5256
],
5357
];
@@ -68,6 +72,8 @@ public function testGetCapabilitiesWithAbsence(): void {
6872
$expected = [
6973
'dav' => [
7074
'chunking' => '1.0',
75+
'search_supports_creation_time' => true,
76+
'search_supports_upload_time' => true,
7177
'absence-supported' => true,
7278
'absence-replacement' => true,
7379
],

apps/files/src/components/FileEntry/FileEntryPreview.vue

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
<FavoriteIcon v-once />
3333
</span>
3434

35+
<!-- Recently created icon -->
36+
<span v-else-if="isRecentView && isRecentlyCreated" class="files-list__row-icon-recently-created">
37+
<RecentlyCreatedIcon v-once />
38+
</span>
39+
3540
<OverlayIcon :is="fileOverlay"
3641
v-if="fileOverlay"
3742
class="files-list__row-icon-overlay files-list__row-icon-overlay--file" />
@@ -61,6 +66,7 @@ import PlayCircleIcon from 'vue-material-design-icons/PlayCircle.vue'
6166
6267
import CollectivesIcon from './CollectivesIcon.vue'
6368
import FavoriteIcon from './FavoriteIcon.vue'
69+
import RecentlyCreatedIcon from './RecentlyCreatedIcon.vue'
6470
6571
import { isLivePhoto } from '../../services/LivePhotos'
6672
import { useUserConfigStore } from '../../store/userconfig.ts'
@@ -80,6 +86,7 @@ export default Vue.extend({
8086
LinkIcon,
8187
NetworkIcon,
8288
TagIcon,
89+
RecentlyCreatedIcon,
8390
},
8491
8592
props: {
@@ -118,6 +125,21 @@ export default Vue.extend({
118125
return this.source.attributes.favorite === 1
119126
},
120127
128+
isRecentlyCreated(): boolean {
129+
if (!this.source.crtime) {
130+
return false
131+
}
132+
133+
const oneDayAgo = new Date()
134+
oneDayAgo.setDate(oneDayAgo.getDate() - 1)
135+
136+
return this.source.crtime > oneDayAgo
137+
},
138+
139+
isRecentView(): boolean {
140+
return this.$route?.params?.view === 'recent'
141+
},
142+
121143
userConfig(): UserConfig {
122144
return this.userConfigStore.userConfig
123145
},
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<!--
2+
- SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
3+
- SPDX-License-Identifier: AGPL-3.0-or-later
4+
-->
5+
<template>
6+
<NcIconSvgWrapper class="recently-created-marker-icon" :name="t('files', 'Recently created')" :path="mdiPlus" />
7+
</template>
8+
9+
<script lang="ts">
10+
import { mdiPlus } from '@mdi/js'
11+
import { t } from '@nextcloud/l10n'
12+
import { defineComponent } from 'vue'
13+
import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper'
14+
15+
/**
16+
* A recently created icon to be used for overlaying recently created entries like the file preview / icon
17+
* It has a stroke around the icon to ensure enough contrast for accessibility.
18+
*
19+
* If the background has a hover state you might want to also apply it to the stroke like this:
20+
* ```scss
21+
* .parent:hover :deep(.recently-created-marker-icon svg path) {
22+
* stroke: var(--color-background-hover);
23+
* }
24+
* ```
25+
*/
26+
export default defineComponent({
27+
name: 'RecentlyCreatedIcon',
28+
components: {
29+
NcIconSvgWrapper,
30+
},
31+
32+
setup() {
33+
return {
34+
mdiPlus,
35+
}
36+
},
37+
38+
methods: {
39+
t,
40+
},
41+
})
42+
</script>
43+
44+
<style lang="scss" scoped>
45+
.recently-created-marker-icon {
46+
color: var(--color-element-success);
47+
// Override NcIconSvgWrapper defaults (clickable area)
48+
min-width: unset !important;
49+
min-height: unset !important;
50+
51+
:deep() {
52+
svg {
53+
// We added a stroke for a11y so we must increase the size to include the stroke
54+
width: 20px !important;
55+
height: 20px !important;
56+
57+
// Override NcIconSvgWrapper defaults of 20px
58+
max-width: unset !important;
59+
max-height: unset !important;
60+
61+
// Show a border around the icon for better contrast
62+
path {
63+
stroke: var(--color-main-background);
64+
stroke-width: 8px;
65+
stroke-linejoin: round;
66+
paint-order: stroke;
67+
}
68+
}
69+
}
70+
}
71+
</style>

apps/files/src/components/FilesListVirtual.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ export default defineComponent({
584584
& > span {
585585
justify-content: flex-start;
586586
587-
&:not(.files-list__row-icon-favorite) svg {
587+
&:not(.files-list__row-icon-favorite):not(.files-list__row-icon-recently-created) svg {
588588
width: var(--icon-preview-size);
589589
height: var(--icon-preview-size);
590590
}
@@ -616,7 +616,8 @@ export default defineComponent({
616616
}
617617
}
618618
619-
&-favorite {
619+
&-favorite,
620+
&-recently-created {
620621
position: absolute;
621622
top: 0px;
622623
right: -10px;
@@ -813,8 +814,9 @@ export default defineComponent({
813814
}
814815
}
815816
816-
// Star icon in the top right
817-
.files-list__row-icon-favorite {
817+
// Icon in the top right
818+
.files-list__row-icon-favorite,
819+
.files-list__row-icon-recently-created {
818820
position: absolute;
819821
top: 0;
820822
right: 0;

dist/files-main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-main.js.license

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ This file is generated from multiple sources. Included packages:
5151
- @linusborg/vue-simple-portal
5252
- version: 0.1.5
5353
- license: Apache-2.0
54+
- @mdi/js
55+
- version: 7.4.47
56+
- license: Apache-2.0
5457
- @mdi/svg
5558
- version: 7.4.47
5659
- license: Apache-2.0

dist/files-main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)