Skip to content

Commit 6cf51f9

Browse files
authored
Merge pull request #43589 from nextcloud/feat/reminder-status
feat(files_reminders): Add reminder status indicator
2 parents ef319ab + cb68d4b commit 6cf51f9

File tree

18 files changed

+269
-111
lines changed

18 files changed

+269
-111
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
:key="action.id"
7878
:class="`files-list__row-action-${action.id}`"
7979
class="files-list__row-action--submenu"
80-
:close-after-click="false /* never close submenu, just go back */"
80+
close-after-click
8181
:data-cy-files-list-row-action="action.id"
8282
:title="action.title?.([source], currentView)"
8383
@click="onActionClick(action)">

apps/files_reminders/appinfo/info.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ Set file reminders.
1313
<author>Christopher Ng</author>
1414
<namespace>FilesReminders</namespace>
1515

16-
<types>
17-
<dav />
18-
</types>
19-
2016
<category>files</category>
2117

2218
<bugs>https://github.com/nextcloud/server/issues</bugs>
@@ -33,10 +29,4 @@ Set file reminders.
3329
<commands>
3430
<command>OCA\FilesReminders\Command\ListCommand</command>
3531
</commands>
36-
37-
<sabre>
38-
<plugins>
39-
<plugin>OCA\FilesReminders\Dav\PropFindPlugin</plugin>
40-
</plugins>
41-
</sabre>
4232
</info>

apps/files_reminders/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
'OCA\\FilesReminders\\Exception\\UserNotFoundException' => $baseDir . '/../lib/Exception/UserNotFoundException.php',
2020
'OCA\\FilesReminders\\Listener\\LoadAdditionalScriptsListener' => $baseDir . '/../lib/Listener/LoadAdditionalScriptsListener.php',
2121
'OCA\\FilesReminders\\Listener\\NodeDeletedListener' => $baseDir . '/../lib/Listener/NodeDeletedListener.php',
22+
'OCA\\FilesReminders\\Listener\\SabrePluginAddListener' => $baseDir . '/../lib/Listener/SabrePluginAddListener.php',
2223
'OCA\\FilesReminders\\Listener\\UserDeletedListener' => $baseDir . '/../lib/Listener/UserDeletedListener.php',
2324
'OCA\\FilesReminders\\Migration\\Version10000Date20230725162149' => $baseDir . '/../lib/Migration/Version10000Date20230725162149.php',
2425
'OCA\\FilesReminders\\Model\\RichReminder' => $baseDir . '/../lib/Model/RichReminder.php',

apps/files_reminders/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class ComposerStaticInitFilesReminders
3434
'OCA\\FilesReminders\\Exception\\UserNotFoundException' => __DIR__ . '/..' . '/../lib/Exception/UserNotFoundException.php',
3535
'OCA\\FilesReminders\\Listener\\LoadAdditionalScriptsListener' => __DIR__ . '/..' . '/../lib/Listener/LoadAdditionalScriptsListener.php',
3636
'OCA\\FilesReminders\\Listener\\NodeDeletedListener' => __DIR__ . '/..' . '/../lib/Listener/NodeDeletedListener.php',
37+
'OCA\\FilesReminders\\Listener\\SabrePluginAddListener' => __DIR__ . '/..' . '/../lib/Listener/SabrePluginAddListener.php',
3738
'OCA\\FilesReminders\\Listener\\UserDeletedListener' => __DIR__ . '/..' . '/../lib/Listener/UserDeletedListener.php',
3839
'OCA\\FilesReminders\\Migration\\Version10000Date20230725162149' => __DIR__ . '/..' . '/../lib/Migration/Version10000Date20230725162149.php',
3940
'OCA\\FilesReminders\\Model\\RichReminder' => __DIR__ . '/..' . '/../lib/Model/RichReminder.php',

apps/files_reminders/lib/AppInfo/Application.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@
2626

2727
namespace OCA\FilesReminders\AppInfo;
2828

29+
use OCA\DAV\Events\SabrePluginAddEvent;
2930
use OCA\Files\Event\LoadAdditionalScriptsEvent;
3031
use OCA\FilesReminders\Listener\LoadAdditionalScriptsListener;
3132
use OCA\FilesReminders\Listener\NodeDeletedListener;
33+
use OCA\FilesReminders\Listener\SabrePluginAddListener;
3234
use OCA\FilesReminders\Listener\UserDeletedListener;
3335
use OCA\FilesReminders\Notification\Notifier;
3436
use OCP\AppFramework\App;
@@ -51,6 +53,8 @@ public function boot(IBootContext $context): void {
5153
public function register(IRegistrationContext $context): void {
5254
$context->registerNotifierService(Notifier::class);
5355

56+
$context->registerEventListener(SabrePluginAddEvent::class, SabrePluginAddListener::class);
57+
5458
$context->registerEventListener(NodeDeletedEvent::class, NodeDeletedListener::class);
5559
$context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class);
5660

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* @copyright 2024 Christopher Ng <chrng8@gmail.com>
7+
*
8+
* @author Christopher Ng <chrng8@gmail.com>
9+
*
10+
* @license GNU AGPL version 3 or any later version
11+
*
12+
* This program is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU Affero General Public License as
14+
* published by the Free Software Foundation, either version 3 of the
15+
* License, or (at your option) any later version.
16+
*
17+
* This program is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU Affero General Public License for more details.
21+
*
22+
* You should have received a copy of the GNU Affero General Public License
23+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24+
*
25+
*/
26+
27+
namespace OCA\FilesReminders\Listener;
28+
29+
use OCA\DAV\Events\SabrePluginAddEvent;
30+
use OCA\FilesReminders\Dav\PropFindPlugin;
31+
use OCP\EventDispatcher\Event;
32+
use OCP\EventDispatcher\IEventListener;
33+
use Psr\Container\ContainerInterface;
34+
35+
/** @template-implements IEventListener<SabrePluginAddEvent> */
36+
class SabrePluginAddListener implements IEventListener {
37+
public function __construct(
38+
private ContainerInterface $container,
39+
) {
40+
}
41+
42+
public function handle(Event $event): void {
43+
if (!($event instanceof SabrePluginAddEvent)) {
44+
return;
45+
}
46+
47+
$server = $event->getServer();
48+
$plugin = $this->container->get(PropFindPlugin::class);
49+
$server->addPlugin($plugin);
50+
}
51+
}

apps/files_reminders/src/actions/clearReminderAction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ import { getVerboseDateString } from '../shared/utils.ts'
3333
export const action = new FileAction({
3434
id: 'clear-reminder',
3535

36-
displayName: () => t('files', 'Clear reminder'),
36+
displayName: () => t('files_reminders', 'Clear reminder'),
3737

3838
title: (nodes: Node[]) => {
3939
const node = nodes.at(0)!
4040
const dueDate = new Date(node.attributes['reminder-due-date'])
41-
return `${t('files', 'Clear reminder')}${getVerboseDateString(dueDate)}`
41+
return `${t('files_reminders', 'Clear reminder')}${getVerboseDateString(dueDate)}`
4242
},
4343

4444
iconSvgInline: () => AlarmOffSvg,
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* @copyright 2024 Christopher Ng <chrng8@gmail.com>
3+
*
4+
* @author Christopher Ng <chrng8@gmail.com>
5+
*
6+
* @license AGPL-3.0-or-later
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Affero General Public License as
10+
* published by the Free Software Foundation, either version 3 of the
11+
* License, or (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Affero General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Affero General Public License
19+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
23+
import { FileAction, type Node } from '@nextcloud/files'
24+
import { translate as t } from '@nextcloud/l10n'
25+
26+
import AlarmSvg from '@mdi/svg/svg/alarm.svg?raw'
27+
28+
import { pickCustomDate } from '../services/customPicker.ts'
29+
import { getVerboseDateString } from '../shared/utils.ts'
30+
31+
export const action = new FileAction({
32+
id: 'reminder-status',
33+
34+
inline: () => true,
35+
36+
displayName: () => '',
37+
38+
title: (nodes: Node[]) => {
39+
const node = nodes.at(0)!
40+
const dueDate = new Date(node.attributes['reminder-due-date'])
41+
return `${t('files_reminders', 'Reminder set')}${getVerboseDateString(dueDate)}`
42+
},
43+
44+
iconSvgInline: () => AlarmSvg,
45+
46+
enabled: (nodes: Node[]) => {
47+
// Only allow on a single node
48+
if (nodes.length !== 1) {
49+
return false
50+
}
51+
const node = nodes.at(0)!
52+
const dueDate = node.attributes['reminder-due-date']
53+
return Boolean(dueDate)
54+
},
55+
56+
async exec(node: Node) {
57+
pickCustomDate(node)
58+
return null
59+
},
60+
61+
order: -15,
62+
})

apps/files_reminders/src/actions/setReminderCustomAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { pickCustomDate } from '../services/customPicker'
2828

2929
export const action = new FileAction({
3030
id: 'set-reminder-custom',
31-
displayName: () => t('files', 'Set custom reminder'),
31+
displayName: () => t('files_reminders', 'Set custom reminder'),
3232
title: () => t('files_reminders', 'Set reminder at custom date & time'),
3333
iconSvgInline: () => CalendarClockSvg,
3434

apps/files_reminders/src/actions/setReminderMenuAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const SET_REMINDER_MENU_ID = 'set-reminder-menu'
2727

2828
export const action = new FileAction({
2929
id: SET_REMINDER_MENU_ID,
30-
displayName: () => t('files', 'Set reminder'),
30+
displayName: () => t('files_reminders', 'Set reminder'),
3131
iconSvgInline: () => AlarmSvg,
3232

3333
enabled: () => true,

0 commit comments

Comments
 (0)