blob: 0dc18ae36eaf27b0ece7ddf45dc70ff26e38e5a4 [file] [log] [blame]
<!--
Copyright (C) 2015 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="../../../bower_components/iron-dropdown/iron-dropdown.html">
<link rel="import" href="../../../behaviors/keyboard-shortcut-behavior.html">
<link rel="import" href="../../../behaviors/rest-client-behavior.html">
<link rel="import" href="../../shared/gr-ajax/gr-ajax.html">
<link rel="import" href="../../shared/gr-button/gr-button.html">
<link rel="import" href="../../shared/gr-request/gr-request.html">
<link rel="import" href="../gr-diff/gr-diff.html">
<dom-module id="gr-diff-view">
<template>
<style>
:host {
background-color: var(--view-background-color);
display: block;
}
h3 {
margin-top: 1em;
padding: .75em var(--default-horizontal-margin);
}
.reviewed {
display: inline-block;
margin: 0 .25em;
vertical-align: .15em;
}
.jumpToFileContainer {
display: inline-block;
}
.mobileJumpToFileContainer {
display: none;
}
.downArrow {
display: inline-block;
font-size: .6em;
vertical-align: middle;
}
.dropdown-trigger {
color: #00e;
cursor: pointer;
padding: 0;
}
.dropdown-content {
background-color: #fff;
box-shadow: 0 1px 5px rgba(0, 0, 0, .3);
}
.dropdown-content a {
cursor: pointer;
display: block;
font-weight: normal;
padding: .3em .5em;
}
.dropdown-content a:before {
color: #ccc;
content: attr(data-key-nav);
display: inline-block;
margin-right: .5em;
width: .3em;
}
.dropdown-content a:hover {
background-color: #00e;
color: #fff;
}
.dropdown-content a[selected] {
color: #000;
font-weight: bold;
pointer-events: none;
text-decoration: none;
}
.dropdown-content a[selected]:hover {
background-color: #fff;
color: #000;
}
gr-button {
font: inherit;
padding: .3em 0;
text-decoration: none;
}
@media screen and (max-width: 50em) {
.dash {
display: none;
}
.reviewed {
vertical-align: -.1em;
}
.jumpToFileContainer {
display: none;
}
.mobileJumpToFileContainer {
display: block;
width: 100%;
}
}
</style>
<gr-ajax id="changeDetailXHR"
auto
url="[[_computeChangeDetailPath(_changeNum)]]"
params="[[_computeChangeDetailQueryParams()]]"
last-response="{{_change}}"></gr-ajax>
<gr-ajax id="filesXHR"
auto
url="[[_computeFilesPath(_changeNum, _patchRange.patchNum)]]"
on-response="_handleFilesResponse"></gr-ajax>
<gr-ajax id="configXHR"
auto
url="[[_computeProjectConfigPath(_change.project)]]"
last-response="{{_projectConfig}}"></gr-ajax>
<h3>
<a href$="[[_computeChangePath(_changeNum, _patchRange.patchNum, _change.revisions)]]">
[[_changeNum]]</a><span>:</span>
<span>[[_change.subject]]</span>
<span class="dash"></span>
<input id="reviewed"
class="reviewed"
type="checkbox"
on-change="_handleReviewedChange"
hidden$="[[!_loggedIn]]" hidden>
<div class="jumpToFileContainer">
<gr-button link class="dropdown-trigger" id="trigger" on-tap="_showDropdownTapHandler">
<span>[[_computeFileDisplayName(_path)]]</span>
<span class="downArrow">&#9660;</span>
</gr-button>
<iron-dropdown id="dropdown" vertical-align="top" vertical-offset="25">
<div class="dropdown-content">
<template is="dom-repeat" items="[[_fileList]]" as="path">
<a href$="[[_computeDiffURL(_changeNum, _patchRange, path)]]"
selected$="[[_computeFileSelected(path, _path)]]"
data-key-nav$="[[_computeKeyNav(path, _path, _fileList)]]"
on-tap="_handleFileTap">
[[_computeFileDisplayName(path)]]
</a>
</template>
</div>
</iron-dropdown>
</div>
<div class="mobileJumpToFileContainer">
<select on-change="_handleMobileSelectChange">
<template is="dom-repeat" items="[[_fileList]]" as="path">
<option
value$="[[path]]"
selected$="[[_computeFileSelected(path, _path)]]">
[[_computeFileDisplayName(path)]]
</option>
</template>
</select>
</div>
</h3>
<gr-diff id="diff"
change-num="[[_changeNum]]"
prefs="{{prefs}}"
patch-range="[[_patchRange]]"
path="[[_path]]"
project-config="[[_projectConfig]]"
available-patches="[[_computeAvailablePatches(_change.revisions)]]"
on-render="_handleDiffRender">
</gr-diff>
</template>
<script src="gr-diff-view.js"></script>
</dom-module>