Add instructions for switching to old UI for admin view

Previously, if you attempted to view an admin/* URL in PolyGerrit, it
rendered a blank page. This change adds the building blocks for an admin
section (router, element), but simply renders a message and link to
switch to the old UI (for whatever the URL entered was).

Bug: Issue 5406
Change-Id: I3fce0d0521122e317838f8d757895e4da6818b95
This commit is contained in:
Becky Siegel
2017-02-02 09:09:45 -08:00
parent 455c91c88b
commit 3f887851c8
5 changed files with 93 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
<!--
Copyright (C) 2017 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">
<dom-module id="gr-admin-view">
<template>
<style>
main {
margin: 2em auto;
max-width: 46em;
}
h1 {
margin-bottom: .1em;
}
@media only screen and (max-width: 67em) {
main {
margin: 2em 0 2em 15em;
}
}
@media only screen and (max-width: 53em) {
.loading {
padding: 0 var(--default-horizontal-margin);
}
main {
margin: 2em 1em;
}
</style>
<main>
<h1>Admin</h1>
<section>
This page is not yet implemented in PolyGerrit. View it in the
<a id="gwtLink" href$="/?polygerrit=0#[[path]]" rel="external">
Old UI</a>
</section>
</main>
</template>
<script src="gr-admin-view.js"></script>
</dom-module>

View File

@@ -0,0 +1,24 @@
// Copyright (C) 2017 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-admin-view',
properties: {
path: String,
},
});
})();

View File

@@ -91,6 +91,17 @@
});
});
page('/admin/(.*)', loadUser, function(data) {
restAPI.getLoggedIn().then(function(loggedIn) {
if (loggedIn) {
data.params.view = 'gr-admin-view';
app.params = data.params;
} else {
page.redirect('/login/' + encodeURIComponent(data.canonicalPath));
}
});
});
function queryHandler(data) {
data.params.view = 'gr-change-list-view';
app.params = data.params;

View File

@@ -18,6 +18,8 @@ limitations under the License.
<link rel="import" href="../behaviors/keyboard-shortcut-behavior/keyboard-shortcut-behavior.html">
<link rel="import" href="../styles/app-theme.html">
<link rel="import" href="./admin/gr-admin-view/gr-admin-view.html">
<link rel="import" href="./core/gr-error-manager/gr-error-manager.html">
<link rel="import" href="./core/gr-keyboard-shortcuts-dialog/gr-keyboard-shortcuts-dialog.html">
<link rel="import" href="./core/gr-main-header/gr-main-header.html">
@@ -123,6 +125,9 @@ limitations under the License.
on-account-detail-update="_handleAccountDetailUpdate">
</gr-settings-view>
</template>
<template is="dom-if" if="[[_showAdminView]]" restamp="true">
<gr-admin-view path="[[_path]]"></gr-admin-view>
</template>
<div id="errorView" class="errorView" hidden>
<div class="errorEmoji">[[_lastError.emoji]]</div>
<div class="errorText">[[_lastError.text]]</div>

View File

@@ -112,6 +112,7 @@
this.set('_showChangeView', view === 'gr-change-view');
this.set('_showDiffView', view === 'gr-diff-view');
this.set('_showSettingsView', view === 'gr-settings-view');
this.set('_showAdminView', view === 'gr-admin-view');
if (this.params.justRegistered) {
this.$.registration.open();
}