(core) Add new UI for writing memos

Summary:
Adds a new UI for writing access rule memos.

Migrates old memos (written as Python comments) to the new UI.

Test Plan: Browser and migration tests.

Reviewers: jarek, dsagal

Reviewed By: jarek

Subscribers: dsagal, paulfitz

Differential Revision: https://phab.getgrist.com/D3726
This commit is contained in:
George Gevoian
2022-12-12 01:29:20 -05:00
parent aaf32ece50
commit e146f95c1c
14 changed files with 233 additions and 53 deletions

View File

@@ -1115,7 +1115,7 @@ def migration33(tdset):
@migration(schema_version=34)
def migration34(tdset):
""""
"""
Add pinned column to _grist_Filters and populate based on existing sections.
When populating, pinned will be set to true for filters that either belong to
@@ -1154,3 +1154,37 @@ def migration34(tdset):
))
return tdset.apply_doc_actions(doc_actions)
@migration(schema_version=35)
def migration35(tdset):
"""
Add memo column to _grist_ACLRules and populate with comments stored in
_grist_ACLRules.aclFormula.
From this version on, comments in _grist_ACLRules.aclFormula will no longer
be used as memos.
"""
doc_actions = [add_column('_grist_ACLRules', 'memo', 'Text')]
acl_rules = list(actions.transpose_bulk_action(tdset.all_tables['_grist_ACLRules']))
# List of (acl_rule_rec, memo) pairs.
acl_rule_updates = []
for acl_rule_rec in acl_rules:
acl_formula = safe_parse(acl_rule_rec.aclFormulaParsed)
if not acl_formula or acl_formula[0] != 'Comment':
continue
acl_rule_updates.append((
acl_rule_rec,
acl_formula[2]
))
if acl_rule_updates:
doc_actions.append(actions.BulkUpdateRecord(
'_grist_ACLRules',
[acl_rule_rec.id for acl_rule_rec, _ in acl_rule_updates],
{'memo': [memo for _, memo in acl_rule_updates]},
))
return tdset.apply_doc_actions(doc_actions)

View File

@@ -15,7 +15,7 @@ import six
import actions
SCHEMA_VERSION = 34
SCHEMA_VERSION = 35
def make_column(col_id, col_type, formula='', isFormula=False):
return {
@@ -280,6 +280,10 @@ def schema_create_actions():
# becomes available to matchFunc. These rules are processed in order of rulePos,
# which should list them before regular rules.
make_column('userAttributes', 'Text'),
# Text of memo associated with this rule, if any. Prior to version 35, this was
# stored within aclFormula.
make_column('memo', 'Text'),
]),
# Note that the special resource with tableId of '' and colIds of '' should be ignored. It is