Refactor file path truncation into behavior
Change-Id: I21af00d3efc28291aa6918fde643cc6c77a7d05c
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 fbd845a..ee12e34 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
@@ -14,9 +14,6 @@
(function() {
'use strict';
- const COMMIT_MESSAGE_PATH = '/COMMIT_MSG';
- const MERGE_LIST_PATH = '/MERGE_LIST';
-
const ERR_REVIEW_STATUS = 'Couldn’t change file review status.';
const MSG_LOADING_BLAME = 'Loading blame...';
const MSG_LOADED_BLAME = 'Blame loaded';
@@ -142,6 +139,7 @@
behaviors: [
Gerrit.KeyboardShortcutBehavior,
Gerrit.PatchSetBehavior,
+ Gerrit.PathListBehavior,
Gerrit.RESTClientBehavior,
],
@@ -495,7 +493,7 @@
// has been queued, the event can bubble up to the handler in gr-app.
this.async(() => {
this.fire('title-change',
- {title: this._computeTruncatedFileDisplayName(this._path)});
+ {title: this.computeTruncatedPath(this._path)});
});
// When navigating away from the page, there is a possibility that the
@@ -568,7 +566,7 @@
_pathChanged(path) {
if (path) {
this.fire('title-change',
- {title: this._computeTruncatedFileDisplayName(path)});
+ {title: this.computeTruncatedPath(path)});
}
if (this._fileList.length == 0) { return; }
@@ -640,19 +638,6 @@
return this._getChangePath(change, patchRangeRecord.base, revisions);
},
- _computeFileDisplayName(path) {
- if (path === COMMIT_MESSAGE_PATH) {
- return 'Commit message';
- } else if (path === MERGE_LIST_PATH) {
- return 'Merge list';
- }
- return path;
- },
-
- _computeTruncatedFileDisplayName(path) {
- return util.truncatePath(this._computeFileDisplayName(path));
- },
-
_computeFileSelected(path, currentPath) {
return path == currentPath;
},