Introduce gr-error-dialog

This is a new dialog intended to display top-level errors in PG, e.g.
major server errors.

It will be utilized in a follow-up change.

Bug: Issue 8457
Change-Id: I9046c56622268b6b0cdb21b787b826496efd2323
This commit is contained in:
Kasper Nilsson
2018-08-23 13:17:19 -07:00
parent c38fa27170
commit 4c9d5aca65
4 changed files with 135 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
<!--
@license
Copyright (C) 2018 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<link rel="import" href="../../../bower_components/polymer/polymer.html">
<link rel="import" href="../../shared/gr-dialog/gr-dialog.html">
<link rel="import" href="../../../styles/shared-styles.html">
<dom-module id="gr-error-dialog">
<template>
<style include="shared-styles">
.main {
max-height: 40em;
max-width: 60em;
overflow-y: auto;
white-space: pre-wrap;
}
@media screen and (max-width: 50em) {
.main {
max-height: none;
max-width: 50em;
}
}
</style>
<gr-dialog
id="dialog"
cancel-label=""
on-confirm="_handleConfirm"
confirm-label="Dismiss"
confirm-on-enter>
<div class="header" slot="header">An error occurred</div>
<div class="main" slot="main">[[text]]</div>
</gr-dialog>
</template>
<script src="gr-error-dialog.js"></script>
</dom-module>

View File

@@ -0,0 +1,37 @@
/**
* @license
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function() {
'use strict';
Polymer({
is: 'gr-error-dialog',
/**
* Fired when the dismiss button is pressed.
*
* @event dismiss
*/
properties: {
text: String,
},
_handleConfirm() {
this.dispatchEvent(new CustomEvent('dismiss'));
},
});
})();

View File

@@ -0,0 +1,48 @@
<!DOCTYPE html>
<!--
@license
Copyright (C) 2018 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>gr-error-dialog</title>
<script src="../../../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
<script src="../../../bower_components/web-component-tester/browser.js"></script>
<link rel="import" href="../../../test/common-test-setup.html"/>
<link rel="import" href="gr-error-dialog.html">
<script>void(0);</script>
<test-fixture id="basic">
<template>
<gr-error-dialog></gr-error-dialog>
</template>
</test-fixture>
<script>
suite('gr-error-dialog tests', () => {
let element;
setup(() => {
element = fixture('basic');
});
test('dismiss tap fires event', done => {
element.addEventListener('dismiss', () => { done(); });
MockInteractions.tap(element.$.dialog.$.confirm);
});
});
</script>

View File

@@ -87,6 +87,7 @@ limitations under the License.
'change/gr-reviewer-list/gr-reviewer-list_test.html',
'change/gr-thread-list/gr-thread-list_test.html',
'core/gr-account-dropdown/gr-account-dropdown_test.html',
'core/gr-error-dialog/gr-error-dialog_test.html',
'core/gr-error-manager/gr-error-manager_test.html',
'core/gr-main-header/gr-main-header_test.html',
'core/gr-navigation/gr-navigation_test.html',