diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html index 18ba163d97..f2ed33acfb 100644 --- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html +++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.html @@ -74,9 +74,12 @@ limitations under the License. margin: .5em; text-align: center; } + #mainContent.mobileOverlayOpened { + display: none; + } } -
+
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js index 4691836932..3bccdd87fc 100644 --- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js +++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js @@ -291,6 +291,11 @@ '_actionsChanged(actions.*, revisionActions.*, _additionalActions.*)', ], + listeners: { + 'fullscreen-overlay-opened': '_handleHideBackgroundContent', + 'fullscreen-overlay-closed': '_handleShowBackgroundContent', + }, + ready() { this.$.jsAPI.addElement(this.$.jsAPI.Element.CHANGE_ACTIONS, this); this._loading = false; @@ -939,6 +944,14 @@ this._fireAction('/wip', this.actions.wip, false); }, + _handleHideBackgroundContent() { + this.$.mainContent.classList.add('overlayOpen'); + }, + + _handleShowBackgroundContent() { + this.$.mainContent.classList.remove('overlayOpen'); + }, + /** * Merge sources of change actions into a single ordered array of action * values. diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html index 2390c217a7..55cd9829eb 100644 --- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html +++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html @@ -346,6 +346,20 @@ limitations under the License. }); }); + test('fullscreen-overlay-opened hides content', () => { + sandbox.spy(element, '_handleHideBackgroundContent'); + element.$.overlay.fire('fullscreen-overlay-opened'); + assert.isTrue(element._handleHideBackgroundContent.called); + assert.isTrue(element.$.mainContent.classList.contains('overlayOpen')); + }); + + test('fullscreen-overlay-closed shows content', () => { + sandbox.spy(element, '_handleShowBackgroundContent'); + element.$.overlay.fire('fullscreen-overlay-closed'); + assert.isTrue(element._handleShowBackgroundContent.called); + assert.isFalse(element.$.mainContent.classList.contains('overlayOpen')); + }); + suite('cherry-pick', () => { let fireActionStub; diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html index 0290cb1d2e..700f835a33 100644 --- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html +++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.html @@ -326,13 +326,19 @@ limitations under the License. .scrollable { overflow: auto; } + /* Change actions are the only thing thant need to remain visible due + to the fact that they may have the currently visible overlay open. */ + #mainContent.overlayOpen .hideOnMobileOverlay { + display: none; + } }
Loading...
-
+
-
-
@@ -537,6 +543,7 @@ limitations under the License. file-list-increment="{{_numFilesShown}}">
{ + element._loggedIn = true; + element._loading = false; + element._change = { + owner: {_account_id: 1}, + labels: {}, + actions: { + abandon: { + enabled: true, + label: 'Abandon', + method: 'POST', + title: 'Abandon', + }, + }, + }; + sandbox.spy(element, '_handleHideBackgroundContent'); + element.$.replyDialog.fire('fullscreen-overlay-opened'); + assert.isTrue(element._handleHideBackgroundContent.called); + assert.isTrue(element.$.mainContent.classList.contains('overlayOpen')); + assert.equal(getComputedStyle(element.$.actions).display, 'block'); + }); + + test('fullscreen-overlay-closed shows content', () => { + element._loggedIn = true; + element._loading = false; + element._change = { + owner: {_account_id: 1}, + labels: {}, + actions: { + abandon: { + enabled: true, + label: 'Abandon', + method: 'POST', + title: 'Abandon', + }, + }, + }; + sandbox.spy(element, '_handleShowBackgroundContent'); + element.$.replyDialog.fire('fullscreen-overlay-closed'); + assert.isTrue(element._handleShowBackgroundContent.called); + assert.isFalse(element.$.mainContent.classList.contains('overlayOpen')); + }); + test('X should expand all messages', () => { const handleExpand = sandbox.stub(element.$.messageList, 'handleExpandCollapse'); diff --git a/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.html b/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.html index 419d2f7e4e..1b59d355da 100644 --- a/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.html +++ b/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.html @@ -25,6 +25,16 @@ limitations under the License. background: #fff; box-shadow: rgba(0, 0, 0, 0.3) 0 1px 3px; } + + @media screen and (max-width: 50em) { + :host { + height: 100%; + left: 0; + position: fixed; + right: 0; + top: 0; + } + } diff --git a/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.js b/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.js index 8db800464d..ebf2f027c1 100644 --- a/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.js +++ b/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.js @@ -16,21 +16,61 @@ const AWAIT_MAX_ITERS = 10; const AWAIT_STEP = 5; + const BREAKPOINT_FULLSCREEN_OVERLAY = '50em'; Polymer({ is: 'gr-overlay', + /** + * Fired when a fullscreen overlay is closed + * + * @event fullscreen-overlay-closed + */ + + /** + * Fired when an overlay is opened in full screen mode + * + * @event fullscreen-overlay-opened + */ + + properties: { + _fullScreenOpen: { + type: Boolean, + value: false, + }, + }, + behaviors: [ Polymer.IronOverlayBehavior, ], + listeners: { + 'iron-overlay-closed': '_close', + 'iron-overlay-cancelled': '_close', + }, + open(...args) { return new Promise(resolve => { Polymer.IronOverlayBehaviorImpl.open.apply(this, args); + if (this._isMobile()) { + this.fire('fullscreen-overlay-opened'); + this._fullScreenOpen = true; + } this._awaitOpen(resolve); }); }, + _isMobile() { + return window.matchMedia(`(max-width: ${BREAKPOINT_FULLSCREEN_OVERLAY})`); + }, + + _close() { + if (this._fullScreenOpen) { + this.fire('fullscreen-overlay-closed'); + this._fullScreenOpen = false; + } + }, + /** * Override the focus stops that iron-overlay-behavior tries to find. */ diff --git a/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay_test.html b/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay_test.html new file mode 100644 index 0000000000..3f427ca211 --- /dev/null +++ b/polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay_test.html @@ -0,0 +1,91 @@ + + + + +gr-overlay + + + + + + + + + + + + + + + +