Use gr-dropdown-list for diff view file select

The diff view file select used its own implementation of a dropdown,
which also had two versions, a native select for mobile and a custom
design for desktop.

gr-autocomplete-dropdown was designed so that it could be used in this
scenario as well, as it also has a native select built in.

This will also allow us to add comments in the dropdown (follow-up
change) and use Gerrit.Nav instead of generated URLs.

Change-Id: I5613bb8e327a3f6ae227bf69e64bfafbbfe09b6c
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js
index 7c46b58..63c774f 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js
@@ -75,6 +75,13 @@
       _changeComments: Object,
       _changeNum: String,
       _diff: Object,
+      // An array specifically formatted to be used in a gr-dropdown-list
+      // element for selected a file to view.
+      _formattedFiles: {
+        type: Array,
+        computed: '_formatFilesForDropdown(_fileList)',
+      },
+      // An sorted array of files, as returned by the rest API.
       _fileList: {
         type: Array,
         value() { return []; },
@@ -586,10 +593,6 @@
           patchRange.basePatchNum);
     },
 
-    _computeDiffURL(change, patchRangeRecord, path) {
-      return this._getDiffUrl(change, patchRangeRecord.base, path);
-    },
-
     _patchRangeStr(patchRange) {
       let patchStr = patchRange.patchNum;
       if (patchRange.basePatchNum != null &&
@@ -638,23 +641,32 @@
       return this._getChangePath(change, patchRangeRecord.base, revisions);
     },
 
-    _computeFileSelected(path, currentPath) {
-      return path == currentPath;
+    _formatFilesForDropdown(fileList) {
+      if (!fileList) { return; }
+      const dropdownContent = [];
+      for (const path of fileList) {
+        dropdownContent.push({
+          text: this.computeDisplayPath(path),
+          mobileText: this.computeTruncatedPath(path),
+          value: this.computeDisplayPath(path),
+        });
+      }
+      return dropdownContent;
     },
 
     _computePrefsButtonHidden(prefs, loggedIn) {
       return !loggedIn || !prefs;
     },
 
-    _computeKeyNav(path, selectedPath, fileList) {
-      const selectedIndex = fileList.indexOf(selectedPath);
-      if (fileList.indexOf(path) == selectedIndex - 1) {
-        return '[';
+    _handleFileChange(e) {
+      // This is when it gets set initially.
+      const path = e.detail.value;
+      if (path === this._path) {
+        return;
       }
-      if (fileList.indexOf(path) == selectedIndex + 1) {
-        return ']';
-      }
-      return '';
+
+      Gerrit.Nav.navigateToDiff(this._change, path, this._patchRange.patchNum,
+          this._patchRange.basePatchNum);
     },
 
     _handleFileTap(e) {
@@ -665,16 +677,6 @@
       }, 1);
     },
 
-    _handleMobileSelectChange(e) {
-      const path = Polymer.dom(e).rootTarget.value;
-      Gerrit.Nav.navigateToDiff(this._change, path, this._patchRange.patchNum,
-          this._patchRange.basePatchNum);
-    },
-
-    _showDropdownTapHandler(e) {
-      this.$.dropdown.open();
-    },
-
     _handlePatchChange(e) {
       const {basePatchNum, patchNum} = e.detail;
       if (this.patchNumEquals(basePatchNum, this._patchRange.basePatchNum) &&