diff --git a/resources/celerity/map.php b/resources/celerity/map.php --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -10,7 +10,7 @@ 'conpherence.pkg.css' => '76ed87e3', 'conpherence.pkg.js' => '020aebcf', 'core.pkg.css' => '3c4918b0', - 'core.pkg.js' => '2eeda9e0', + 'core.pkg.js' => '5fd2c85d', 'dark-console.pkg.js' => '187792c2', 'differential.pkg.css' => '2431def2', 'differential.pkg.js' => '46fcb3af', @@ -472,7 +472,7 @@ 'rsrc/js/core/behavior-bulk-editor.js' => 'aa6d2308', 'rsrc/js/core/behavior-choose-control.js' => '04f8a1e3', 'rsrc/js/core/behavior-copy.js' => 'cf32921f', - 'rsrc/js/core/behavior-detect-timezone.js' => '78bc5d94', + 'rsrc/js/core/behavior-detect-timezone.js' => 'a1fd777f', 'rsrc/js/core/behavior-device.js' => 'ac2b1e01', 'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '6bc7ccf7', 'rsrc/js/core/behavior-fancy-datepicker.js' => 'b545d0a0', @@ -482,6 +482,7 @@ 'rsrc/js/core/behavior-high-security-warning.js' => 'dae2d55b', 'rsrc/js/core/behavior-history-install.js' => '6a1583a8', 'rsrc/js/core/behavior-hovercard.js' => '183738e6', + 'rsrc/js/core/behavior-ignore-timezone.js' => '8bff6901', 'rsrc/js/core/behavior-keyboard-pager.js' => '1325b731', 'rsrc/js/core/behavior-keyboard-shortcuts.js' => '42c44e8b', 'rsrc/js/core/behavior-lightbox-attachments.js' => '14c7ab36', @@ -614,7 +615,7 @@ 'javelin-behavior-dashboard-tab-panel' => '0116d3e8', 'javelin-behavior-day-view' => '727a5a61', 'javelin-behavior-desktop-notifications-control' => '070679fe', - 'javelin-behavior-detect-timezone' => '78bc5d94', + 'javelin-behavior-detect-timezone' => 'a1fd777f', 'javelin-behavior-device' => 'ac2b1e01', 'javelin-behavior-differential-diff-radios' => '925fe8cd', 'javelin-behavior-differential-populate' => 'b86ef6c2', @@ -636,6 +637,7 @@ 'javelin-behavior-high-security-warning' => 'dae2d55b', 'javelin-behavior-history-install' => '6a1583a8', 'javelin-behavior-icon-composer' => '38a6cedb', + 'javelin-behavior-ignore-timezone' => '8bff6901', 'javelin-behavior-launch-icon-composer' => 'a17b84f1', 'javelin-behavior-lightbox-attachments' => '14c7ab36', 'javelin-behavior-line-chart' => 'ad258e28', @@ -1616,11 +1618,6 @@ 'phabricator-drag-and-drop-file-upload', 'javelin-workboard-board', ), - '78bc5d94' => array( - 'javelin-behavior', - 'javelin-uri', - 'phabricator-notification', - ), '78f811c9' => array( 'javelin-install', ), @@ -1711,6 +1708,10 @@ 'javelin-dom', 'javelin-typeahead-normalizer', ), + '8bff6901' => array( + 'javelin-behavior', + 'phabricator-notification', + ), '8c2ed2bf' => array( 'javelin-behavior', 'javelin-dom', @@ -1813,6 +1814,11 @@ 'javelin-dom', 'javelin-workflow', ), + 'a1fd777f' => array( + 'javelin-behavior', + 'javelin-uri', + 'phabricator-notification', + ), 'a241536a' => array( 'javelin-install', ), diff --git a/src/view/page/PhabricatorStandardPageView.php b/src/view/page/PhabricatorStandardPageView.php --- a/src/view/page/PhabricatorStandardPageView.php +++ b/src/view/page/PhabricatorStandardPageView.php @@ -250,6 +250,16 @@ $ignore_key = PhabricatorTimezoneIgnoreOffsetSetting::SETTINGKEY; $ignore = $user->getUserSetting($ignore_key); + Javelin::initBehavior( + 'ignore-timezone', + array( + 'offset' => $offset, + 'message' => pht( + 'Click to ignore timezone conflicts'), + 'ignoreKey' => $ignore_key, + 'ignore' => $ignore, + )); + Javelin::initBehavior( 'detect-timezone', array( @@ -262,6 +272,7 @@ 'ignore' => $ignore, )); + if ($user->getIsAdmin()) { $server_https = $request->isHTTPS(); $server_protocol = $server_https ? 'HTTPS' : 'HTTP'; diff --git a/webroot/rsrc/js/core/behavior-detect-timezone.js b/webroot/rsrc/js/core/behavior-detect-timezone.js --- a/webroot/rsrc/js/core/behavior-detect-timezone.js +++ b/webroot/rsrc/js/core/behavior-detect-timezone.js @@ -35,7 +35,7 @@ } var notification = new JX.Notification() - .alterClassName('jx-notification-alert', true) + .alterClassName('jx-notification-alert jx-timezone-conflict-notification', true) .setContent(config.message) .setDuration(0); diff --git a/webroot/rsrc/js/core/behavior-ignore-timezone.js b/webroot/rsrc/js/core/behavior-ignore-timezone.js new file mode 100644 --- /dev/null +++ b/webroot/rsrc/js/core/behavior-ignore-timezone.js @@ -0,0 +1,38 @@ +/** + * @provides javelin-behavior-ignore-timezone + * @requires javelin-behavior + * phabricator-notification + */ + +JX.behavior('ignore-timezone', function(config) { + + var offset = new Date().getTimezoneOffset(); + let ignore = config.ignore; + + if (ignore === '-120' || offset === ignore || config.offset===offset) { + return; + } + + var notification = new JX.Notification() + .alterClassName('jx-notification-message jx-timezone-ignore-conflict-notification', true) + .setContent(config.message) + .setDuration(0); + + // Set the time.offset.ignore (ignoreKey) to -120 on notification click + notification.listen('activate', function() { + new JX.Request('/settings/adjust/', JX.bag) + .setData({key: config.ignoreKey, value: '-120'}) + .send(); + + const timezone_conflict_notification = document.getElementsByClassName('jx-timezone-conflict-notification')[0]; + notification.hide(); + if(timezone_conflict_notification != null) + { + timezone_conflict_notification.remove(); + } + + }); + + notification.show(); + +});