Handle legacy name in change_table preferences
After updating the "Project" column name to "Repo", there were still references to the former name in the change_table preference, which controls what columns appear in the change table. Because, following the rename, preferences would have an outdated key, this had the unintended effect of hiding the repo column by default for any user who had modified that preference. With this change, the appearance of "Project" in a change_table list is treated like an appearance of "Repo". Bug: Issue 9509 Change-Id: I1e773b5dd07dd086551f62aacbbe5973078e9ee4
This commit is contained in:
parent
e27a404a3e
commit
3b5ae7518d
@ -58,6 +58,22 @@ limitations under the License.
|
||||
isColumnHidden(columnToCheck, columnsToDisplay) {
|
||||
return !columnsToDisplay.includes(columnToCheck);
|
||||
},
|
||||
|
||||
/**
|
||||
* The Project column was renamed to Repo, but some users may have
|
||||
* preferences that use its old name. If that column is found, rename it
|
||||
* before use.
|
||||
* @param {!Array<string>} columns
|
||||
* @return {!Array<string>} If the column was renamed, returns a new array
|
||||
* with the corrected name. Otherwise, it returns the original param.
|
||||
*/
|
||||
getVisibleColumns(columns) {
|
||||
const projectIndex = columns.indexOf('Project');
|
||||
if (projectIndex === -1) { return columns; }
|
||||
const newColumns = columns.slice(0);
|
||||
newColumns[projectIndex] = 'Repo';
|
||||
return newColumns;
|
||||
},
|
||||
};
|
||||
})(window);
|
||||
</script>
|
||||
|
@ -107,5 +107,17 @@ limitations under the License.
|
||||
];
|
||||
assert.isTrue(element.isColumnHidden(columnToCheck, columnsToDisplay));
|
||||
});
|
||||
|
||||
test('getVisibleColumns maps Project to Repo', () => {
|
||||
const columns = [
|
||||
'Subject',
|
||||
'Status',
|
||||
'Owner',
|
||||
];
|
||||
assert.deepEqual(element.getVisibleColumns(columns), columns.slice(0));
|
||||
assert.deepEqual(
|
||||
element.getVisibleColumns(columns.concat(['Project'])),
|
||||
columns.slice(0).concat(['Repo']));
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
@ -151,7 +151,7 @@
|
||||
this.showNumber = !!(preferences &&
|
||||
preferences.legacycid_in_change_table);
|
||||
this.visibleChangeTableColumns = preferences.change_table.length > 0 ?
|
||||
preferences.change_table : this.columnNames;
|
||||
this.getVisibleColumns(preferences.change_table) : this.columnNames;
|
||||
} else {
|
||||
// Not logged in.
|
||||
this.showNumber = false;
|
||||
|
@ -249,7 +249,7 @@
|
||||
},
|
||||
|
||||
_cloneChangeTableColumns() {
|
||||
let columns = this.prefs.change_table;
|
||||
let columns = this.getVisibleColumns(this.prefs.change_table);
|
||||
|
||||
if (columns.length === 0) {
|
||||
columns = this.columnNames;
|
||||
|
Loading…
x
Reference in New Issue
Block a user