summaryrefslogtreecommitdiffstats
path: root/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.html
blob: 0866849d375f50b6b80957225b78b0d46c8d60da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
<!--
@license
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="../../../behaviors/gr-patch-set-behavior/gr-patch-set-behavior.html">
<link rel="import" href="../../../behaviors/gr-path-list-behavior/gr-path-list-behavior.html">
<link rel="import" href="../../../behaviors/keyboard-shortcut-behavior/keyboard-shortcut-behavior.html">
<link rel="import" href="../../../behaviors/rest-client-behavior/rest-client-behavior.html">
<link rel="import" href="../../../bower_components/iron-dropdown/iron-dropdown.html">
<link rel="import" href="../../../styles/shared-styles.html">
<link rel="import" href="../../core/gr-navigation/gr-navigation.html">
<link rel="import" href="../../core/gr-reporting/gr-reporting.html">
<link rel="import" href="../../shared/gr-button/gr-button.html">
<link rel="import" href="../../shared/gr-count-string-formatter/gr-count-string-formatter.html">
<link rel="import" href="../../shared/gr-dropdown-list/gr-dropdown-list.html">
<link rel="import" href="../../shared/gr-fixed-panel/gr-fixed-panel.html">
<link rel="import" href="../../shared/gr-icons/gr-icons.html">
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
<link rel="import" href="../../shared/gr-select/gr-select.html">
<link rel="import" href="../../shared/revision-info/revision-info.html">
<link rel="import" href="../gr-comment-api/gr-comment-api.html">
<link rel="import" href="../gr-diff-cursor/gr-diff-cursor.html">
<link rel="import" href="../gr-diff-mode-selector/gr-diff-mode-selector.html">
<link rel="import" href="../gr-diff-preferences/gr-diff-preferences.html">
<link rel="import" href="../gr-diff-host/gr-diff-host.html">
<link rel="import" href="../gr-patch-range-select/gr-patch-range-select.html">

<dom-module id="gr-diff-view">
  <template>
    <style include="shared-styles">
      :host {
        background-color: var(--view-background-color);
      }
      .hidden {
        display: none;
      }
      gr-patch-range-select {
        display: block;
      }
      gr-diff {
        border: none;
        --diff-container-styles: {
          border-bottom: 1px solid var(--border-color);
        }
      }
      gr-fixed-panel {
        background-color: var(--view-background-color);
        border-bottom: 1px solid var(--border-color);
        z-index: 1;
      }
      header,
      .subHeader {
        align-items: center;
        display: flex;
        justify-content: space-between;
      }
      header {
        padding: .75em var(--default-horizontal-margin);
      }
      .patchRangeLeft {
        align-items: center;
        display: flex;
      }
      .navLink:not([href]),
      .downloadLink:not([href]) {
        color: var(--deemphasized-text-color);
      }
      .navLinks {
        align-items: center;
        display: flex;
        white-space: nowrap;
      }
      .navLink {
        padding: 0 .25em;
      }
      .reviewed {
        display: inline-block;
        margin: 0 .25em;
        vertical-align: .15em;
      }
      .jumpToFileContainer {
        display: inline-block;
      }
      .mobile {
        display: none;
      }
      gr-button {
        padding: .3em 0;
        text-decoration: none;
      }
      .loading {
        color: var(--deemphasized-text-color);
        font-size: 2rem;
        height: 100%;
        padding: 1em var(--default-horizontal-margin);
        text-align: center;
      }
      .subHeader {
        flex-wrap: wrap;
        margin: 0 var(--default-horizontal-margin) .75em;
      }
      .subHeader > div {
        margin-top: .25em;
      }
      .prefsButton {
        text-align: right;
      }
      .noOverflow {
        display: block;
        overflow: auto;
      }
      .editMode .hideOnEdit {
        display: none;
      }
      .blameLoader,
      .fileNum {
        display: none;
      }
      .blameLoader.show,
      .fileNum.show ,
      .download,
      .preferences,
      .rightControls {
        align-items: center;
        display: flex;
      }
      .diffModeSelector {
        align-items: center;
        display: flex;
      }
      .diffModeSelector span {
        margin-right: .2rem;
      }
      .diffModeSelector.hide,
      .separator.hide {
        display: none;
      }
      gr-dropdown-list {
        --trigger-style: {
          text-transform: none;
        }
      }
      @media screen and (max-width: 50em) {
        header {
          padding: .5em var(--default-horizontal-margin);
        }
        .dash {
          display: none;
        }
        .desktop {
          display: none;
        }
        .fileNav {
          align-items: flex-start;
          display: flex;
          margin: 0 .25em;
        }
        .fullFileName {
          display: block;
          font-style: italic;
          min-width: 50%;
          padding: 0 .1em;
          text-align: center;
          width: 100%;
          word-wrap: break-word;
        }
        .reviewed {
          vertical-align: -.1em;
        }
        .mobileNavLink {
          color: var(--primary-text-color);
          font-size: 1.5rem;
          font-weight: var(--font-weight-bold);
          text-decoration: none;
        }
        .mobileNavLink:not([href]) {
          color: var(--deemphasized-text-color);
        }
        .jumpToFileContainer {
          display: block;
          width: 100%;
        }
        gr-dropdown-list {
          width: 100%;
          --gr-select-style: {
            display: block;
            width: 100%;
          }
          --native-select-style: {
            width: 100%;
          }
        }
      }
    </style>
    <gr-fixed-panel
        class$="[[_computeContainerClass(_editMode)]]"
        floating-disabled="[[_panelFloatingDisabled]]"
        keep-on-scroll
        ready-for-measure="[[!_loading]]">
      <header>
        <h3>
          <a href$="[[_computeChangePath(_change, _patchRange.*, _change.revisions)]]">
            [[_changeNum]]</a><span>:</span>
          <span>[[_change.subject]]</span>
          <span class="dash"></span>
          <input id="reviewed"
              class="reviewed hideOnEdit"
              type="checkbox"
              on-change="_handleReviewedChange"
              hidden$="[[!_loggedIn]]" hidden>
          <div class="jumpToFileContainer">
            <gr-dropdown-list
                id="dropdown"
                value="[[_path]]"
                on-value-change="_handleFileChange"
                items="[[_formattedFiles]]"
                initial-count="75">
           </gr-dropdown-list>
          </div>
        </h3>
        <div class="navLinks desktop">
          <span class$="fileNum [[_computeFileNumClass(_fileNum, _formattedFiles)]]">
            File [[_fileNum]] of [[_formattedFiles.length]]
            <span class="separator"></span>
          </span>
          <a class="navLink"
              href$="[[_computeNavLinkURL(_change, _path, _fileList, -1, 1)]]">
            Prev</a>
          <span class="separator"></span>
          <a class="navLink"
              href$="[[_computeChangePath(_change, _patchRange.*, _change.revisions)]]">
            Up</a>
          <span class="separator"></span>
          <a class="navLink"
              href$="[[_computeNavLinkURL(_change, _path, _fileList, 1, 1)]]">
            Next</a>
        </div>
      </header>
      <div class="subHeader">
        <div class="patchRangeLeft">
          <gr-patch-range-select
              id="rangeSelect"
              change-num="[[_changeNum]]"
              change-comments="[[_changeComments]]"
              patch-num="[[_patchRange.patchNum]]"
              base-patch-num="[[_patchRange.basePatchNum]]"
              files-weblinks="[[_filesWeblinks]]"
              available-patches="[[_allPatchSets]]"
              revisions="[[_change.revisions]]"
              revision-info="[[_revisionInfo]]"
              on-patch-range-change="_handlePatchChange">
          </gr-patch-range-select>
          <span class="download desktop">
            <span class="separator"></span>
            <a
              class="downloadLink"
              download
              href$="[[_computeDownloadLink(_change.project, _changeNum, _patchRange, _path)]]">
              Download
            </a>
          </span>
        </div>
        <div class="rightControls">
          <span class$="blameLoader [[_computeBlameLoaderClass(_isImageDiff)]]">
            <gr-button
                link
                disabled="[[_isBlameLoading]]"
                on-tap="_toggleBlame">[[_computeBlameToggleLabel(_isBlameLoaded, _isBlameLoading)]]</gr-button>
            <span class="separator"></span>
          </span>
          <div class$="diffModeSelector [[_computeModeSelectHideClass(_isImageDiff)]]">
            <span>Diff view:</span>
            <gr-diff-mode-selector
                id="modeSelect"
                save-on-change="[[_loggedIn]]"
                mode="{{changeViewState.diffMode}}"></gr-diff-mode-selector>
          </div>
          <span id="diffPrefsContainer"
              hidden$="[[_computePrefsButtonHidden(_prefs, _loggedIn)]]" hidden>
            <span class="preferences desktop">
              <gr-button
                  link
                  class="prefsButton"
                  has-tooltip
                  title="Diff preferences"
                  on-tap="_handlePrefsTap"><iron-icon icon="gr-icons:settings"></iron-icon></gr-button>
            </span>
          </span>
          <gr-endpoint-decorator name="annotation-toggler">
            <span hidden id="annotation-span">
              <label for="annotation-checkbox" id="annotation-label"></label>
              <input is="iron-input" type="checkbox" id="annotation-checkbox" disabled>
            </span>
          </gr-endpoint-decorator>
        </div>
      </div>
      <div class="fileNav mobile">
        <a class="mobileNavLink"
          href$="[[_computeNavLinkURL(_change, _path, _fileList, -1, 1)]]">
          &lt;</a>
        <div class="fullFileName mobile">[[computeDisplayPath(_path)]]
        </div>
        <a class="mobileNavLink"
            href$="[[_computeNavLinkURL(_change, _path, _fileList, 1, 1)]]">
          &gt;</a>
      </div>
    </gr-fixed-panel>
    <div class="loading" hidden$="[[!_loading]]">Loading...</div>
    <gr-diff-host
        id="diffHost"
        hidden
        hidden$="[[_loading]]"
        class$="[[_computeDiffClass(_panelFloatingDisabled)]]"
        is-image-diff="{{_isImageDiff}}"
        files-weblinks="{{_filesWeblinks}}"
        change-num="[[_changeNum]]"
        commit-range="[[_commitRange]]"
        patch-range="[[_patchRange]]"
        path="[[_path]]"
        prefs="[[_prefs]]"
        project-config="[[_projectConfig]]"
        project-name="[[_change.project]]"
        view-mode="[[_diffMode]]"
        is-blame-loaded="{{_isBlameLoaded}}"
        on-line-selected="_onLineSelected">
    </gr-diff-host>
    <gr-diff-preferences
        id="diffPreferences"
        prefs="{{_prefs}}"
        local-prefs="{{_localPrefs}}"></gr-diff-preferences>
    <gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
    <gr-storage id="storage"></gr-storage>
    <gr-diff-cursor id="cursor"></gr-diff-cursor>
    <gr-comment-api id="commentAPI"></gr-comment-api>
    <gr-reporting id="reporting"></gr-reporting>
  </template>
  <script src="gr-diff-view.js"></script>
</dom-module>