Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(other): add All Snoozed button and Icon to left menu #1375

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ DEFAULT_SETTING_SENT_PER_SOURCE=20
DEFAULT_SETTING_SENT_SINCE='-1 week'
DEFAULT_SETTING_JUNK_PER_SOURCE=20
DEFAULT_SETTING_JUNK_SINCE='-1 week'
DEFAULT_SETTING_SNOOZED_PER_SOURCE=20
DEFAULT_SETTING_SNOOZED_SINCE='-1 week'
DEFAULT_SETTING_TAGS_PER_SOURCE=20
DEFAULT_SETTING_TAGS_SINCE='-1 week'
DEFAULT_SETTING_TRASH_PER_SOURCE=20
Expand Down
14 changes: 14 additions & 0 deletions config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,20 @@
*/
'default_setting_junk_per_source' => env('DEFAULT_SETTING_JUNK_PER_SOURCE', 20),

/*
|
| Per source time limit for snoozed page
| Defaults to 1 week
*/
'default_setting_snoozed_since' => env('DEFAULT_SETTING_SNOOZED_SINCE', '-1 week'),

/*
|
| Per source number limit for snoozed page
| Defaults 20
*/
'default_setting_snoozed_per_source' => env('DEFAULT_SETTING_SNOOZED_PER_SOURCE', 20),

/*
|
| Per source time limit for tags page
Expand Down
2 changes: 2 additions & 0 deletions lib/environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public function define_default_constants($config) {
define('DEFAULT_IMAP_PER_PAGE', $config->get('default_setting_imap_per_page', 20));
define('DEFAULT_JUNK_SINCE', $config->get('default_setting_junk_since', '-1 week'));
define('DEFAULT_JUNK_PER_SOURCE', $config->get('default_setting_junk_per_source', 20));
define('DEFAULT_SNOOZED_SINCE', $config->get('default_setting_snoozed_since', '-1 week'));
define('DEFAULT_SNOOZED_PER_SOURCE', $config->get('default_setting_snoozed_per_source', 20));
define('DEFAULT_TAGS_SINCE', $config->get('default_setting_tags_since', '-1 week'));
define('DEFAULT_TAGS_PER_SOURCE', $config->get('default_setting_tags_per_source', 20));
define('DEFAULT_TRASH_SINCE', $config->get('default_setting_trash_since', '-1 week'));
Expand Down
26 changes: 26 additions & 0 deletions modules/core/handler_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,32 @@ public function process() {
}
}

/**
* Process input from the max per source setting for the Snoozed page in the settings page
* @subpackage core/handler
*/
class Hm_Handler_process_snoozed_source_max_setting extends Hm_Handler_Module {
/**
* Allowed values are greater than zero and less than MAX_PER_SOURCE
*/
public function process() {
process_site_setting('snoozed_per_source', $this, 'max_source_setting_callback', DEFAULT_SNOOZED_PER_SOURCE);
}
}

/**
* Process "since" setting for the Snoozed page in the settings page
* @subpackage core/handler
*/
class Hm_Handler_process_snoozed_since_setting extends Hm_Handler_Module {
/**
* valid values are defined in the process_since_argument function
*/
public function process() {
process_site_setting('snoozed_since', $this, 'since_setting_callback', DEFAULT_SNOOZED_SINCE);
}
}

/**
* Process "since" setting for the Everything page in the settings page
* @subpackage core/handler
Expand Down
6 changes: 6 additions & 0 deletions modules/core/message_list_functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ function get_message_list_settings($path, $handler) {
$per_source_limit = $handler->user_config->get('junk_per_source_setting', DEFAULT_JUNK_PER_SOURCE);
$mailbox_list_title = array('Junk');
}
elseif ($path == 'snoozed') {
$list_path = 'snoozed';
$message_list_since = $handler->user_config->get('snoozed_since_setting', DEFAULT_SNOOZED_SINCE);
$per_source_limit = $handler->user_config->get('snoozed_per_source_setting', DEFAULT_SNOOZED_PER_SOURCE);
$mailbox_list_title = array('Snoozed');
}
elseif ($path == 'trash') {
$list_path = 'trash';
$message_list_since = $handler->user_config->get('trash_since_setting', DEFAULT_TRASH_SINCE);
Expand Down
62 changes: 61 additions & 1 deletion modules/core/output_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1384,6 +1384,11 @@ protected function output() {
$res .= '<i class="bi bi-pencil-square menu-icon"></i>';
}
$res .= '<span class="nav-label">'.$this->trans('Drafts').'</span></a></li>';
$res .= '<li class="menu_snoozed"><a class="unread_link" href="?page=message_list&amp;list_path=snoozed">';
if (!$this->get('hide_folder_icons')) {
$res .= '<i class="bi bi-clock-fill menu-icon"></i>';
}
$res .= '<span class="nav-label">'.$this->trans('Snoozed').'</span></a></li>';

if ($this->format == 'HTML5') {
return $res;
Expand Down Expand Up @@ -2136,7 +2141,62 @@ protected function output() {
'<td>'.message_since_dropdown($since, 'trash_since', $this, DEFAULT_TRASH_SINCE).'</td></tr>';
}
}

/**
* Starts the Snoozed section on the settings page
* @subpackage core/output
*/
class Hm_Output_start_snoozed_settings extends Hm_Output_Module {
/**
* Settings in this section control the snoozed messages view
*/
protected function output() {
return '<tr><td data-target=".snoozed_setting" colspan="2" class="settings_subtitle cursor-pointer border-bottom p-2">'.
'<i class="bi bi-clock-fill fs-5 me-2"></i>'.
$this->trans('Snoozed').'</td></tr>';
}
}
/**
* Option for the maximum number of messages per source for the Snoozed page
* @subpackage core/output
*/
class Hm_Output_snoozed_source_max_setting extends Hm_Output_Module {
/**
* Processed by Hm_Handler_process_snoozed_source_max_setting
*/
protected function output() {
$sources = DEFAULT_SNOOZED_PER_SOURCE;
$settings = $this->get('user_settings', array());
$reset = '';
if (array_key_exists('snoozed_per_source', $settings)) {
$sources = $settings['snoozed_per_source'];
}
if ($sources != DEFAULT_SNOOZED_PER_SOURCE) {
$reset = '<span class="tooltip_restore" restore_aria_label="Restore default value"><i class="bi bi-arrow-repeat refresh_list reset_default_value_input"></i></span>';
}
return '<tr class="snoozed_setting"><td><label for="snoozed_per_source">'.
$this->trans('Max messages per source for Snoozed').'</label></td>' .
'<td class="d-flex"><input class="form-control form-control-sm w-auto" type="text" size="2" id="snoozed_per_source" name="snoozed_per_source" value="'.$this->html_safe($sources).'" data-default-value="'.DEFAULT_SNOOZED_PER_SOURCE.'" />'.$reset.'</td></tr>';
}
}
/**
* Option for the snoozed messages date range
* @subpackage core/output
*/
class Hm_Output_snoozed_since_setting extends Hm_Output_Module {
/**
* Processed by Hm_Handler_process_snoozed_since_setting
*/
protected function output() {
$since = DEFAULT_SNOOZED_SINCE;
$settings = $this->get('user_settings', array());
if (array_key_exists('snoozed_since', $settings) && $settings['snoozed_since']) {
$since = $settings['snoozed_since'];
}
return '<tr class="snoozed_setting"><td><label for="snoozed_since">'.
$this->trans('Show snoozed messages since').'</label></td>'.
'<td>'.message_since_dropdown($since, 'snoozed_since', $this, DEFAULT_SNOOZED_SINCE).'</td></tr>';
}
}
/**
* Starts the Draft section on the settings page
* @subpackage core/output
Expand Down
9 changes: 8 additions & 1 deletion modules/core/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
add_handler('settings', 'process_all_email_source_max_setting', true, 'core', 'date', 'after');
add_handler('settings', 'process_junk_since_setting', true, 'core', 'date', 'after');
add_handler('settings', 'process_junk_source_max_setting', true, 'core', 'date', 'after');
add_handler('settings', 'process_snoozed_since_setting', true, 'core', 'date', 'after');
add_handler('settings', 'process_snoozed_source_max_setting', true, 'core', 'date', 'after');
add_handler('settings', 'process_trash_since_setting', true, 'core', 'date', 'after');
add_handler('settings', 'process_trash_source_max_setting', true, 'core', 'date', 'after');
add_handler('settings', 'process_drafts_since_setting', true, 'core', 'date', 'after');
Expand Down Expand Up @@ -89,7 +91,10 @@
add_output('settings', 'start_junk_settings', true, 'core', 'flagged_source_max_setting', 'after');
add_output('settings', 'junk_since_setting', true, 'core', 'start_junk_settings', 'after');
add_output('settings', 'junk_source_max_setting', true, 'core', 'junk_since_setting', 'after');
add_output('settings', 'start_trash_settings', true, 'core', 'junk_source_max_setting', 'after');
add_output('settings', 'start_snoozed_settings', true, 'core', 'junk_source_max_setting', 'after');
add_output('settings', 'snoozed_since_setting', true, 'core', 'start_snoozed_settings', 'after');
add_output('settings', 'snoozed_source_max_setting', true, 'core', 'snoozed_since_setting', 'after');
add_output('settings', 'start_trash_settings', true, 'core', 'snoozed_source_max_setting', 'after');
add_output('settings', 'trash_since_setting', true, 'core', 'start_trash_settings', 'after');
add_output('settings', 'trash_source_max_setting', true, 'core', 'trash_since_setting', 'after');
add_output('settings', 'start_drafts_settings', true, 'core', 'trash_source_max_setting', 'after');
Expand Down Expand Up @@ -319,6 +324,8 @@
'stay_logged_in' => FILTER_VALIDATE_BOOLEAN,
'junk_per_source' => FILTER_VALIDATE_INT,
'junk_since' => FILTER_DEFAULT,
'snoozed_per_source' => FILTER_VALIDATE_INT,
'snoozed_since' => FILTER_DEFAULT,
'trash_per_source' => FILTER_VALIDATE_INT,
'trash_since' => FILTER_DEFAULT,
'drafts_per_source' => FILTER_DEFAULT,
Expand Down
1 change: 1 addition & 0 deletions modules/core/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,7 @@ button {
.flagged_setting,
.general_setting,
.junk_setting,
.snoozed_setting,
.trash_setting,
.drafts_setting,
.privacy_setting {
Expand Down
5 changes: 5 additions & 0 deletions modules/core/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ function Message_List() {
'unread': 'formatted_unread_data',
'flagged': 'formatted_flagged_data',
'junk': 'formatted_junk_data',
'snoozed': 'formatted_snoozed_data',
'trash': 'formatted_trash_data',
'sent': 'formatted_sent_data',
'drafts': 'formatted_drafts_data',
Expand Down Expand Up @@ -617,6 +618,9 @@ function Message_List() {
if (action_type == 'unflag' && getListPathParam() == 'flagged') {
remove = true;
}
if (action_type == 'unsnooze' && getListPathParam() == 'snoozed') {
remove = true;
}
else if (action_type == 'delete' || action_type == 'archive') {
remove = true;
}
Expand Down Expand Up @@ -1056,6 +1060,7 @@ function Message_List() {
this.set_unread_state = function() { self.set_message_list_state('formatted_unread_data'); };
this.set_search_state = function() { self.set_message_list_state('formatted_search_data'); };
this.set_junk_state = function() { self.set_message_list_state('formatted_junk_data'); };
this.set_snoozed_state = function() { self.set_message_list_state('formatted_snoozed_data'); };
this.set_trash_state = function() { self.set_message_list_state('formatted_trash_data'); };
this.set_draft_state = function() { self.set_message_list_state('formatted_drafts_data'); };
this.set_tag_state = function() { self.set_message_list_state('formatted_tag_data'); };
Expand Down
3 changes: 3 additions & 0 deletions modules/imap/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ function imap_sources($mod, $folder = 'sent') {
elseif ($inbox) {
$sources[] = array('folder' => bin2hex('INBOX'), 'type' => 'imap', 'name' => $vals['name'], 'id' => $index);
}
elseif ($folder=="snoozed"){
$sources[] = array('callback' => $callback, 'folder' => bin2hex('Snoozed'), 'type' => 'imap', 'name' => $vals['name'], 'id' => $index);
}
else {
$sources[] = array('folder' => bin2hex('SPECIAL_USE_CHECK'), 'nodisplay' => true, 'type' => 'imap', 'name' => $vals['name'], 'id' => $index);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/imap/handler_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1650,7 +1650,7 @@ public function process() {
else {
$path = '';
}
if (in_array($path, ['sent', 'junk', 'trash', 'drafts'])) {
if (in_array($path, ['sent', 'junk', 'snoozed','trash', 'drafts'])) {
foreach (imap_sources($this, $path) as $vals) {
$this->append('data_sources', $vals);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/imap/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ var add_auto_folder = function(folder) {
};

var cache_folder_data = function() {
if (['sent', 'drafts', 'junk', 'trash','tag'].includes(getListPathParam())) {
if (['sent', 'drafts', 'junk','snoozed', 'trash','tag'].includes(getListPathParam())) {
Hm_Message_List.set_message_list_state('formatted_'+getListPathParam()+'_data');
}
};
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit/modules/core/output_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -865,10 +865,10 @@ public function test_main_menu_content() {
$test = new Output_Test('main_menu_content', 'core');
$test->handler_response = array('folder_sources' => array(array('email_folders', 'baz')));
$res = $test->run();
$this->assertEquals(array('<li class="menu_unread d-flex align-items-center"><a class="unread_link d-flex align-items-center" href="?page=message_list&amp;list_path=unread"><i class="bi bi-envelope-fill menu-icon"></i><span class="nav-label">Unread</span></a><span class="total_unread_count badge rounded-pill text-bg-info ms-2 px-1"></span></li><li class="menu_flagged"><a class="unread_link" href="?page=message_list&amp;list_path=flagged"><i class="bi bi-flag-fill menu-icon"></i><span class="nav-label">Flagged</span></a> <span class="flagged_count"></span></li><li class="menu_junk"><a class="unread_link" href="?page=message_list&amp;list_path=junk"><i class="bi bi-envelope-x-fill menu-icon"></i><span class="nav-label">Junk</span></a></li><li class="menu_trash"><a class="unread_link" href="?page=message_list&amp;list_path=trash"><i class="bi bi-trash3-fill menu-icon"></i><span class="nav-label">Trash</span></a></li><li class="menu_drafts"><a class="unread_link" href="?page=message_list&amp;list_path=drafts"><i class="bi bi-pencil-square menu-icon"></i><span class="nav-label">Drafts</span></a></li>'), $res->output_response);
$this->assertEquals(array('<li class="menu_unread d-flex align-items-center"><a class="unread_link d-flex align-items-center" href="?page=message_list&amp;list_path=unread"><i class="bi bi-envelope-fill menu-icon"></i><span class="nav-label">Unread</span></a><span class="total_unread_count badge rounded-pill text-bg-info ms-2 px-1"></span></li><li class="menu_flagged"><a class="unread_link" href="?page=message_list&amp;list_path=flagged"><i class="bi bi-flag-fill menu-icon"></i><span class="nav-label">Flagged</span></a> <span class="flagged_count"></span></li><li class="menu_junk"><a class="unread_link" href="?page=message_list&amp;list_path=junk"><i class="bi bi-envelope-x-fill menu-icon"></i><span class="nav-label">Junk</span></a></li><li class="menu_trash"><a class="unread_link" href="?page=message_list&amp;list_path=trash"><i class="bi bi-trash3-fill menu-icon"></i><span class="nav-label">Trash</span></a></li><li class="menu_drafts"><a class="unread_link" href="?page=message_list&amp;list_path=drafts"><i class="bi bi-pencil-square menu-icon"></i><span class="nav-label">Drafts</span></a></li><li class="menu_snoozed"><a class="unread_link" href="?page=message_list&amp;list_path=snoozed"><i class="bi bi-clock-fill menu-icon"></i><span class="nav-label">Snoozed</span></a></li>'), $res->output_response);
$test->rtype = 'AJAX';
$res = $test->run();
$this->assertEquals(array('folder_sources' => array(array('email_folders', 'baz')), 'formatted_folder_list' => '<li class="menu_unread d-flex align-items-center"><a class="unread_link d-flex align-items-center" href="?page=message_list&amp;list_path=unread"><i class="bi bi-envelope-fill menu-icon"></i><span class="nav-label">Unread</span></a><span class="total_unread_count badge rounded-pill text-bg-info ms-2 px-1"></span></li><li class="menu_flagged"><a class="unread_link" href="?page=message_list&amp;list_path=flagged"><i class="bi bi-flag-fill menu-icon"></i><span class="nav-label">Flagged</span></a> <span class="flagged_count"></span></li><li class="menu_junk"><a class="unread_link" href="?page=message_list&amp;list_path=junk"><i class="bi bi-envelope-x-fill menu-icon"></i><span class="nav-label">Junk</span></a></li><li class="menu_trash"><a class="unread_link" href="?page=message_list&amp;list_path=trash"><i class="bi bi-trash3-fill menu-icon"></i><span class="nav-label">Trash</span></a></li><li class="menu_drafts"><a class="unread_link" href="?page=message_list&amp;list_path=drafts"><i class="bi bi-pencil-square menu-icon"></i><span class="nav-label">Drafts</span></a></li>'), $res->output_response);
$this->assertEquals(array('folder_sources' => array(array('email_folders', 'baz')), 'formatted_folder_list' => '<li class="menu_unread d-flex align-items-center"><a class="unread_link d-flex align-items-center" href="?page=message_list&amp;list_path=unread"><i class="bi bi-envelope-fill menu-icon"></i><span class="nav-label">Unread</span></a><span class="total_unread_count badge rounded-pill text-bg-info ms-2 px-1"></span></li><li class="menu_flagged"><a class="unread_link" href="?page=message_list&amp;list_path=flagged"><i class="bi bi-flag-fill menu-icon"></i><span class="nav-label">Flagged</span></a> <span class="flagged_count"></span></li><li class="menu_junk"><a class="unread_link" href="?page=message_list&amp;list_path=junk"><i class="bi bi-envelope-x-fill menu-icon"></i><span class="nav-label">Junk</span></a></li><li class="menu_trash"><a class="unread_link" href="?page=message_list&amp;list_path=trash"><i class="bi bi-trash3-fill menu-icon"></i><span class="nav-label">Trash</span></a></li><li class="menu_drafts"><a class="unread_link" href="?page=message_list&amp;list_path=drafts"><i class="bi bi-pencil-square menu-icon"></i><span class="nav-label">Drafts</span></a></li><li class="menu_snoozed"><a class="unread_link" href="?page=message_list&amp;list_path=snoozed"><i class="bi bi-clock-fill menu-icon"></i><span class="nav-label">Snoozed</span></a></li>'), $res->output_response);
}

/**
Expand Down
Loading