Data (field) Locking
The data locking system facilitates concurrent editing of entities via disabling (locking) any field that has been updated locally by another user.
AWS DynamoDB Storage
Each field lock stores a record on a DynamoDB, keyed by the entity type and id of the entity.
This collection of field lock records becomes the External State of an entity.
This state is stored in DynamoDB external to Drupal API to prevent too many http request from hitting the API, but also enabling a canonical state of an entity to be recorded in case clients go out of sync.
envvars
process.env.WEBSOCKET_TABLE
process.env.AWS_DEFAULT_REGION
Handling broken records
todo: create utility available to internal Admin users to remove records from the CMS, this will be useful for handling these issue going forward
There have been a few instances where a DynamoDB record for a particular entity has become broken and either prevented editing of the field and prevented unlocking or white screened the CMS as an incorrect data format has been returned, this has now been mitigated where discovered but could happen in the future.
To solve this the record must be manually removed from the AWS UI
- Login to AWS
- Set user IAM for client in the correct env
- Goto DynamoDB dashboard
- Query table for the correct env_entityType_entityId this is format:
{env}-{type}-{id}
- Find broken record (this usually is a record with an empty data value but some knowledge of what type of data the
field expects might be required) 6. Select and delete record
Deleting records in this manner is low risk as all DynamoDB data is temporary data, this will NOT effect the saved or published data for the entity. The most high risk Deletion would be the body field as this could contain a lot of data that could be lost, keeping a copy of this data could be advisable or request editor to backup their editor locally.
Components
Components can be found here:
/src/components/fieldlock/form
Component | Data handled |
---|---|
FieldLockDateTime | unix timestamp |
FieldLockEditor | JSON object in editor format |
FieldLockGallery | Gallery object |
FieldLockImage | Image object |
FieldLockSelect | string |
FieldLockSelectAutocomplete | string |
FieldLockSortable | array |
FieldLockTextfield | string |
FieldLockToggle | boolean |
FieldLockVideo | Video object |
FieldLockVocabSelector | array of Vocab objects |
FieldLockVocabSelectorButton | Vocab object |
Components handled the data, events and locking state from the field property that can either be an array of nested properties or a string.
i.e.
<FieldLockTextfield field={FIELD_BADGE_TITLE} label={'Badge title'} />
or
<FieldLockTextfield field={[field, itemId, SPEAKER_NAME]} label={'Name'} />
All components have the following props:
Prop | Data |
---|---|
field | string or array |
label | string |
See separate components for additional fields.