-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43589 from nextcloud/feat/reminder-status
feat(files_reminders): Add reminder status indicator
- Loading branch information
Showing
18 changed files
with
269 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
apps/files_reminders/lib/Listener/SabrePluginAddListener.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* @copyright 2024 Christopher Ng <chrng8@gmail.com> | ||
* | ||
* @author Christopher Ng <chrng8@gmail.com> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
namespace OCA\FilesReminders\Listener; | ||
|
||
use OCA\DAV\Events\SabrePluginAddEvent; | ||
use OCA\FilesReminders\Dav\PropFindPlugin; | ||
use OCP\EventDispatcher\Event; | ||
use OCP\EventDispatcher\IEventListener; | ||
use Psr\Container\ContainerInterface; | ||
|
||
/** @template-implements IEventListener<SabrePluginAddEvent> */ | ||
class SabrePluginAddListener implements IEventListener { | ||
public function __construct( | ||
private ContainerInterface $container, | ||
) { | ||
} | ||
|
||
public function handle(Event $event): void { | ||
if (!($event instanceof SabrePluginAddEvent)) { | ||
return; | ||
} | ||
|
||
$server = $event->getServer(); | ||
$plugin = $this->container->get(PropFindPlugin::class); | ||
$server->addPlugin($plugin); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* @copyright 2024 Christopher Ng <chrng8@gmail.com> | ||
* | ||
* @author Christopher Ng <chrng8@gmail.com> | ||
* | ||
* @license AGPL-3.0-or-later | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
import { FileAction, type Node } from '@nextcloud/files' | ||
import { translate as t } from '@nextcloud/l10n' | ||
|
||
import AlarmSvg from '@mdi/svg/svg/alarm.svg?raw' | ||
|
||
import { pickCustomDate } from '../services/customPicker.ts' | ||
import { getVerboseDateString } from '../shared/utils.ts' | ||
|
||
export const action = new FileAction({ | ||
id: 'reminder-status', | ||
|
||
inline: () => true, | ||
|
||
displayName: () => '', | ||
|
||
title: (nodes: Node[]) => { | ||
const node = nodes.at(0)! | ||
const dueDate = new Date(node.attributes['reminder-due-date']) | ||
return `${t('files_reminders', 'Reminder set')} – ${getVerboseDateString(dueDate)}` | ||
}, | ||
|
||
iconSvgInline: () => AlarmSvg, | ||
|
||
enabled: (nodes: Node[]) => { | ||
// Only allow on a single node | ||
if (nodes.length !== 1) { | ||
return false | ||
} | ||
const node = nodes.at(0)! | ||
const dueDate = node.attributes['reminder-due-date'] | ||
return Boolean(dueDate) | ||
}, | ||
|
||
async exec(node: Node) { | ||
pickCustomDate(node) | ||
return null | ||
}, | ||
|
||
order: -15, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.