Add stuff for new 'share project' flow (#1403)

Coming up in the ephemeral state branch is the new 'share project' flow
where it uploads the document data before redirecting. This sets up some
stuff that will be needed there.

### Change Type

<!-- 💡 Indicate the type of change your pull request is. -->
<!-- 🤷‍♀️ If you're not sure, don't select anything -->
<!-- ✂️ Feel free to delete unselected options -->

<!-- To select one, put an x in the box: [x] -->

- [ ] `patch` — Bug Fix
- [x] `minor` — New Feature
- [ ] `major` — Breaking Change
- [ ] `dependencies` — Dependency Update (publishes a `patch` release,
for devDependencies use `internal`)
- [ ] `documentation` — Changes to the documentation only (will not
publish a new version)
- [ ] `tests` — Changes to any testing-related code only (will not
publish a new version)
- [ ] `internal` — Any other changes that don't affect the published
package (will not publish a new version)
This commit is contained in:
David Sheldrick 2023-05-17 17:17:31 +01:00 committed by GitHub
parent 6573cb2fbe
commit ad5a23e135
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 1 deletions

View file

@ -231,6 +231,7 @@
"share-menu.copy-link-note": "Anyone with the link will be able to view and edit this project.", "share-menu.copy-link-note": "Anyone with the link will be able to view and edit this project.",
"share-menu.copy-readonly-link-note": "Anyone with the link will be able to view (but not edit) this project.", "share-menu.copy-readonly-link-note": "Anyone with the link will be able to view (but not edit) this project.",
"share-menu.project-too-large": "Sorry, this project can't be shared because it's too large. We're working on it!", "share-menu.project-too-large": "Sorry, this project can't be shared because it's too large. We're working on it!",
"share-menu.upload-failed": "Sorry, we couldn't upload your project at the moment. Please try again or let us know if the problem persists.",
"people-menu.title": "People", "people-menu.title": "People",
"people-menu.change-name": "Change name", "people-menu.change-name": "Change name",
"people-menu.change-color": "Change color", "people-menu.change-color": "Change color",

View file

@ -250,6 +250,7 @@ export class Store<R extends BaseRecord = BaseRecord, Props = unknown> {
// (undocumented) // (undocumented)
readonly schema: StoreSchema<R, Props>; readonly schema: StoreSchema<R, Props>;
serialize: (filter?: ((record: R) => boolean) | undefined) => StoreSnapshot<R>; serialize: (filter?: ((record: R) => boolean) | undefined) => StoreSnapshot<R>;
serializeDocumentState: () => StoreSnapshot<R>;
unsafeGetWithoutCapture: <K extends ID<R>>(id: K) => RecFromId<K> | undefined; unsafeGetWithoutCapture: <K extends ID<R>>(id: K) => RecFromId<K> | undefined;
update: <K extends ID<R>>(id: K, updater: (record: RecFromId<K>) => RecFromId<K>) => void; update: <K extends ID<R>>(id: K, updater: (record: RecFromId<K>) => RecFromId<K>) => void;
// (undocumented) // (undocumented)

View file

@ -3,6 +3,7 @@ import { atom, Atom, computed, Computed, Reactor, reactor, transact } from 'sign
import { BaseRecord, ID } from './BaseRecord' import { BaseRecord, ID } from './BaseRecord'
import { Cache } from './Cache' import { Cache } from './Cache'
import { devFreeze } from './devFreeze' import { devFreeze } from './devFreeze'
import { RecordType } from './RecordType'
import { StoreQueries } from './StoreQueries' import { StoreQueries } from './StoreQueries'
import { StoreSchema } from './StoreSchema' import { StoreSchema } from './StoreSchema'
@ -429,6 +430,17 @@ export class Store<R extends BaseRecord = BaseRecord, Props = unknown> {
return result return result
} }
/**
* The same as `serialize`, but only serializes records with a scope of `document`.
* @returns The record store snapshot as a JSON payload.
*/
serializeDocumentState = (): StoreSnapshot<R> => {
return this.serialize((r) => {
const type = this.schema.types[r.typeName as R['typeName']] as RecordType<any, any>
return type.scope === 'document'
})
}
/** /**
* Opposite of `serialize`. Replace the store's current records with records as defined by a * Opposite of `serialize`. Replace the store's current records with records as defined by a
* simple JSON structure into the stores. * simple JSON structure into the stores.

File diff suppressed because one or more lines are too long

View file

@ -235,6 +235,7 @@ export type TLTranslationKey =
| 'share-menu.copy-link-note' | 'share-menu.copy-link-note'
| 'share-menu.copy-readonly-link-note' | 'share-menu.copy-readonly-link-note'
| 'share-menu.project-too-large' | 'share-menu.project-too-large'
| 'share-menu.upload-failed'
| 'people-menu.title' | 'people-menu.title'
| 'people-menu.change-name' | 'people-menu.change-name'
| 'people-menu.change-color' | 'people-menu.change-color'

View file

@ -237,6 +237,8 @@ export const DEFAULT_TRANSLATION = {
'Anyone with the link will be able to view (but not edit) this project.', 'Anyone with the link will be able to view (but not edit) this project.',
'share-menu.project-too-large': 'share-menu.project-too-large':
"Sorry, this project can't be shared because it's too large. We're working on it!", "Sorry, this project can't be shared because it's too large. We're working on it!",
'share-menu.upload-failed':
"Sorry, we couldn't upload your project at the moment. Please try again or let us know if the problem persists.",
'people-menu.title': 'People', 'people-menu.title': 'People',
'people-menu.change-name': 'Change name', 'people-menu.change-name': 'Change name',
'people-menu.change-color': 'Change color', 'people-menu.change-color': 'Change color',