feat: Option for separate edit mode (#4203)

* stash

* wip

* cleanup

* Remove collaborativeEditing toggle, it will always be on in next release.
Flip separateEdit -> seamlessEdit

* Clarify language, hide toggle when collaborative editing is disabled

* Flip boolean to match, easier to reason about
This commit is contained in:
Tom Moor
2022-10-02 17:58:33 +02:00
committed by GitHub
parent b9bf2e58cb
commit 933fbb2578
20 changed files with 172 additions and 124 deletions

View File

@@ -19,7 +19,7 @@ import {
IsUrl,
AllowNull,
} from "sequelize-typescript";
import { CollectionPermission } from "@shared/types";
import { CollectionPermission, TeamPreference } from "@shared/types";
import { getBaseDomain, RESERVED_SUBDOMAINS } from "@shared/utils/domains";
import env from "@server/env";
import { generateAvatarUrl } from "@server/utils/avatars";
@@ -169,6 +169,35 @@ class Team extends ParanoidModel {
);
}
/**
* Preferences that decide behavior for the team.
*
* @param preference The team preference to set
* @param value Sets the preference value
* @returns The current team preferences
*/
public setPreference = (preference: TeamPreference, value: boolean) => {
if (!this.preferences) {
this.preferences = {};
}
this.preferences[preference] = value;
this.changed("preferences", true);
return this.preferences;
};
/**
* Returns the passed preference value
*
* @param preference The user preference to retrieve
* @returns The preference value if set, else undefined
*/
public getPreference = (preference: TeamPreference) => {
return !!this.preferences && this.preferences[preference]
? this.preferences[preference]
: undefined;
};
provisionFirstCollection = async (userId: string) => {
await this.sequelize!.transaction(async (transaction) => {
const collection = await Collection.create(