FIX: Handle empty directory columns in /u route (#22747)

The `/u` route was broken when there were no directory columns because
its order parameter relied on the first column's name. This commit adds
a `likes_received` as the default order when there are no columns, which
results in a list of users being output without any additional columns.

For this very edge case, that's better than a JS error.
This commit is contained in:
Penar Musaraj 2023-07-25 10:58:43 -04:00 committed by GitHub
parent 00903f6b11
commit 4e5756e3ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -42,7 +42,10 @@ export default DiscourseRoute.extend({
model(params) {
return ajax("/directory-columns.json")
.then((response) => {
params.order = params.order || response.directory_columns[0].name;
params.order =
params.order ||
response.directory_columns[0]?.name ||
"likes_received";
return { params, columns: response.directory_columns };
})
.catch(popupAjaxError);