Skip to content

Commit f6c79c0

Browse files
authored
Merge pull request #58562 from nextcloud/feat/1699/recent-files-mark-recently-created
feat: set creation_time on file creation and render recently created icon
2 parents 2909821 + 3836eb6 commit f6c79c0

File tree

11 files changed

+119
-8
lines changed

11 files changed

+119
-8
lines changed

apps/dav/lib/Capabilities.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ public function getCapabilities() {
2727
'dav' => [
2828
'chunking' => '1.0',
2929
'public_shares_chunking' => true,
30+
'search_supports_creation_time' => true,
31+
'search_supports_upload_time' => true,
3032
]
3133
];
3234
if ($this->config->getSystemValueBool('bulkupload.enabled', true)) {

apps/dav/lib/Files/FileSearchBackend.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ public function getPropertyDefinitionsForScope(string $href, ?string $path): arr
8686
new SearchPropertyDefinition('{DAV:}displayname', true, true, true),
8787
new SearchPropertyDefinition('{DAV:}getcontenttype', true, true, true),
8888
new SearchPropertyDefinition('{DAV:}getlastmodified', true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME),
89+
new SearchPropertyDefinition('{DAV:}creationdate', true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME),
8990
new SearchPropertyDefinition('{http://nextcloud.org/ns}upload_time', true, true, true, SearchPropertyDefinition::DATATYPE_DATETIME),
9091
new SearchPropertyDefinition(FilesPlugin::SIZE_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_NONNEGATIVE_INTEGER),
9192
new SearchPropertyDefinition(TagsPlugin::FAVORITE_PROPERTYNAME, true, true, true, SearchPropertyDefinition::DATATYPE_BOOLEAN),
@@ -299,6 +300,8 @@ private function getSearchResultProperty(SearchResult $result, SearchPropertyDef
299300
return $node->getName();
300301
case '{DAV:}getlastmodified':
301302
return $node->getLastModified();
303+
case '{DAV:}creationdate':
304+
return $node->getNode()->getCreationTime();
302305
case '{http://nextcloud.org/ns}upload_time':
303306
return $node->getNode()->getUploadTime();
304307
case FilesPlugin::SIZE_PROPERTYNAME:
@@ -461,6 +464,8 @@ private function mapPropertyNameToColumn(SearchPropertyDefinition $property) {
461464
return 'mimetype';
462465
case '{DAV:}getlastmodified':
463466
return 'mtime';
467+
case '{DAV:}creationdate':
468+
return 'creation_time';
464469
case '{http://nextcloud.org/ns}upload_time':
465470
return 'upload_time';
466471
case FilesPlugin::SIZE_PROPERTYNAME:

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
<FavoriteIcon v-once />
4343
</span>
4444

45+
<!-- Recently created icon -->
46+
<span v-else-if="isRecentView && isRecentlyCreated" class="files-list__row-icon-recently-created">
47+
<RecentlyCreatedIcon v-once />
48+
</span>
49+
4550
<component
4651
:is="fileOverlay"
4752
v-if="fileOverlay"
@@ -71,6 +76,7 @@ import PlayCircleIcon from 'vue-material-design-icons/PlayCircle.vue'
7176
import TagIcon from 'vue-material-design-icons/Tag.vue'
7277
import CollectivesIcon from './CollectivesIcon.vue'
7378
import FavoriteIcon from './FavoriteIcon.vue'
79+
import RecentlyCreatedIcon from './RecentlyCreatedIcon.vue'
7480
import { usePreviewImage } from '../../composables/usePreviewImage.ts'
7581
import logger from '../../logger.ts'
7682
import { isLivePhoto } from '../../services/LivePhotos.ts'
@@ -91,6 +97,7 @@ export default defineComponent({
9197
LinkIcon,
9298
NetworkIcon,
9399
TagIcon,
100+
RecentlyCreatedIcon,
94101
},
95102
96103
props: {
@@ -138,6 +145,21 @@ export default defineComponent({
138145
return this.source.attributes.favorite === 1
139146
},
140147
148+
isRecentlyCreated(): boolean {
149+
if (!this.source.crtime) {
150+
return false
151+
}
152+
153+
const oneDayAgo = new Date()
154+
oneDayAgo.setDate(oneDayAgo.getDate() - 1)
155+
156+
return this.source.crtime > oneDayAgo
157+
},
158+
159+
isRecentView(): boolean {
160+
return this.$route?.params?.view === 'recent'
161+
},
162+
141163
userConfig(): UserConfig {
142164
return this.userConfigStore.userConfig
143165
},
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
@@ -743,7 +743,7 @@ export default defineComponent({
743743
& > span {
744744
justify-content: flex-start;
745745
746-
&:not(.files-list__row-icon-favorite) svg {
746+
&:not(.files-list__row-icon-favorite):not(.files-list__row-icon-recently-created) svg {
747747
width: var(--icon-preview-size);
748748
height: var(--icon-preview-size);
749749
}
@@ -791,7 +791,8 @@ export default defineComponent({
791791
}
792792
}
793793
794-
&-favorite {
794+
&-favorite,
795+
&-recently-created {
795796
position: absolute;
796797
top: 0px;
797798
inset-inline-end: -10px;
@@ -993,8 +994,9 @@ export default defineComponent({
993994
}
994995
}
995996
996-
// Star icon in the top right
997-
.files-list__row-icon-favorite {
997+
// Icon in the top right
998+
.files-list__row-icon-favorite,
999+
.files-list__row-icon-recently-created {
9981000
position: absolute;
9991001
top: 0;
10001002
inset-inline-end: 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.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.

lib/private/Files/Cache/Cache.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ public function getFolderContentsById(int $fileId, ?string $mimeTypeFilter = nul
250250
* @throws \RuntimeException
251251
*/
252252
public function put($file, array $data) {
253+
// do not carry over creation_time to file versions, as each new version would otherwise
254+
// create a filecache_extended entry with the same creation_time as the original file
255+
if (str_starts_with($file, 'files_versions/')) {
256+
unset($data['creation_time']);
257+
}
258+
253259
if (($id = $this->getId($file)) > -1) {
254260
$this->update($id, $data);
255261
return $id;

lib/private/Files/Cache/QuerySearchHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public function searchInCaches(ISearchQuery $searchQuery, array $caches): array
153153

154154
$requestedFields = $this->searchBuilder->extractRequestedFields($searchQuery->getSearchOperation());
155155

156-
$joinExtendedCache = in_array('upload_time', $requestedFields);
156+
$joinExtendedCache = in_array('creation_time', $requestedFields) || in_array('upload_time', $requestedFields);
157157

158158
$query = $builder->selectFileCache('file', $joinExtendedCache);
159159

lib/private/Files/Cache/SearchBuilder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class SearchBuilder {
6464
'share_with' => 'string',
6565
'share_type' => 'integer',
6666
'owner' => 'string',
67+
'creation_time' => 'integer',
6768
'upload_time' => 'integer',
6869
];
6970

@@ -258,6 +259,7 @@ private function validateComparison(ISearchComparison $operator) {
258259
'share_with' => ['eq'],
259260
'share_type' => ['eq'],
260261
'owner' => ['eq'],
262+
'creation_time' => ['eq', 'gt', 'lt', 'gte', 'lte'],
261263
'upload_time' => ['eq', 'gt', 'lt', 'gte', 'lte'],
262264
];
263265

0 commit comments

Comments
 (0)