Skip to content

Commit 64716e8

Browse files
Fix regression from sorting ACL rules (#1768)
1 parent 4a2e2bc commit 64716e8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

app/client/aclui/AccessRules.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import {
4242
UserAttributeRule
4343
} from 'app/common/GranularAccessClause';
4444
import {getDefaultForType, isHiddenCol} from 'app/common/gristTypes';
45-
import {isNonNullish, unwrap} from 'app/common/gutil';
45+
import {isNonNullish, localeCompare, unwrap} from 'app/common/gutil';
4646
import {EmptyRecordView, InfoView, RecordView} from 'app/common/RecordView';
4747
import {
4848
getPredicateFormulaProperties,
@@ -129,6 +129,7 @@ export class AccessRules extends Disposable {
129129

130130
// Array of all per-table rules.
131131
private _tableRules = this.autoDispose(obsArray<TableRules>());
132+
private _sortedTableRules: Computed<TableRules[]>;
132133

133134
// The default rule set for the document (for "*:*").
134135
private _docDefaultRuleSet = Observable.create<DefaultObsRuleSet|null>(this, null);
@@ -184,6 +185,12 @@ export class AccessRules extends Disposable {
184185
);
185186
});
186187

188+
this._sortedTableRules = Computed.create(this, (use) =>
189+
[...use(this._tableRules)].sort((a, b) =>
190+
localeCompare(a.tableId, b.tableId)
191+
)
192+
);
193+
187194
this._savingEnabled = Computed.create(this, this._ruleStatus, (use, s) =>
188195
(s === RuleStatus.ChangedValid));
189196

@@ -253,7 +260,6 @@ export class AccessRules extends Disposable {
253260
this._tableRules.set(
254261
rules.getAllTableIds()
255262
.filter(tableId => (tableId !== SPECIAL_RULES_TABLE_ID))
256-
.sort((a, b) => a.localeCompare(b))
257263
.map(tableId => TableRules.create(this._tableRules,
258264
tableId, this, rules.getAllColumnRuleSets(tableId), rules.getTableDefaultRuleSet(tableId)))
259265
);
@@ -480,7 +486,7 @@ export class AccessRules extends Disposable {
480486
),
481487
),
482488
),
483-
dom.forEach(this._tableRules, (tableRules) => tableRules.buildDom()),
489+
dom.forEach(this._sortedTableRules, (tableRules) => tableRules.buildDom()),
484490
cssSection(
485491
cssSectionHeading(t("Default Rules"), testId('rule-table-header')),
486492
dom.maybe(this._specialRulesWithDefault, tableRules => cssSeedRule(

0 commit comments

Comments
 (0)