From 097359bf7cad9b64e7be9263e0061625268f18ec Mon Sep 17 00:00:00 2001
From: Tom Moor
Date: Tue, 9 Feb 2021 19:04:03 -0800
Subject: [PATCH 01/25] feat: Added ability to disable sharing at collection
(#1875)
* feat: Added ability to disable sharing at collection
* fix: Disable all previous share links when disabling collection share
Language
* fix: Disable document sharing for read-only collection members
* wip
* test
* fix: Clear policies after updating sharing settings
* chore: Less ambiguous language
* feat: Allow setting sharing choice on collection creation
---
app/components/Switch.js | 19 ++++++--
app/menus/CollectionMenu.js | 4 +-
app/menus/DocumentMenu.js | 10 ++--
app/models/Collection.js | 2 +
app/scenes/Collection.js | 2 +-
app/scenes/CollectionEdit.js | 34 ++++++++++++-
app/scenes/CollectionNew.js | 48 ++++++++++++++-----
app/scenes/Document/components/Header.js | 4 +-
app/stores/CollectionsStore.js | 21 +++++++-
server/api/collections.js | 7 ++-
server/api/collections.test.js | 12 +++++
server/api/documents.js | 5 ++
server/api/documents.test.js | 17 +++++++
server/api/shares.test.js | 11 ++++-
...210208062816-disable-collection-sharing.js | 12 +++++
server/models/Collection.js | 5 ++
server/policies/collection.js | 23 +++++++++
server/policies/document.js | 16 +++++--
server/presenters/collection.js | 1 +
shared/i18n/locales/en_US/translation.json | 7 ++-
20 files changed, 227 insertions(+), 33 deletions(-)
create mode 100644 server/migrations/20210208062816-disable-collection-sharing.js
diff --git a/app/components/Switch.js b/app/components/Switch.js
index aaa08f186c..172c54e905 100644
--- a/app/components/Switch.js
+++ b/app/components/Switch.js
@@ -13,17 +13,23 @@ type Props = {|
id?: string,
|};
-function Switch({ width = 38, height = 20, label, ...props }: Props) {
+function Switch({ width = 38, height = 20, label, disabled, ...props }: Props) {
const component = (
-
+
);
if (label) {
return (
-
}>
-
-
- )}
+
{hasPinnedDocuments && (
<>
@@ -396,10 +377,5 @@ const Wrapper = styled(Flex)`
`;
export default withTranslation()(
- inject(
- "collections",
- "policies",
- "documents",
- "ui"
- )(withTheme(CollectionScene))
+ inject("collections", "policies", "documents", "ui")(CollectionScene)
);
diff --git a/app/scenes/CollectionEdit.js b/app/scenes/CollectionEdit.js
index 84ede83370..a759821ad9 100644
--- a/app/scenes/CollectionEdit.js
+++ b/app/scenes/CollectionEdit.js
@@ -11,7 +11,6 @@ import Flex from "components/Flex";
import HelpText from "components/HelpText";
import IconPicker from "components/IconPicker";
import Input from "components/Input";
-import InputRich from "components/InputRich";
import InputSelect from "components/InputSelect";
import Switch from "components/Switch";
@@ -27,7 +26,6 @@ type Props = {
class CollectionEdit extends React.Component {
@observable name: string = this.props.collection.name;
@observable sharing: boolean = this.props.collection.sharing;
- @observable description: string = this.props.collection.description;
@observable icon: string = this.props.collection.icon;
@observable color: string = this.props.collection.color || "#4E5C6E";
@observable private: boolean = this.props.collection.private;
@@ -43,7 +41,6 @@ class CollectionEdit extends React.Component {
try {
await this.props.collection.save({
name: this.name,
- description: this.description,
icon: this.icon,
color: this.color,
private: this.private,
@@ -69,10 +66,6 @@ class CollectionEdit extends React.Component {
}
};
- handleDescriptionChange = (getValue: () => string) => {
- this.description = getValue();
- };
-
handleNameChange = (ev: SyntheticInputEvent<*>) => {
this.name = ev.target.value;
};
@@ -120,15 +113,6 @@ class CollectionEdit extends React.Component {
icon={this.icon}
/>
-
{
@observable name: string = "";
- @observable description: string = "";
@observable icon: string = "";
@observable color: string = "#4E5C6E";
@observable sharing: boolean = true;
@@ -43,7 +41,6 @@ class CollectionNew extends React.Component {
const collection = new Collection(
{
name: this.name,
- description: this.description,
sharing: this.sharing,
icon: this.icon,
color: this.color,
@@ -90,10 +87,6 @@ class CollectionNew extends React.Component {
this.hasOpenedIconPicker = true;
};
- handleDescriptionChange = (getValue: () => string) => {
- this.description = getValue();
- };
-
handlePrivateChange = (ev: SyntheticInputEvent) => {
this.private = ev.target.checked;
};
@@ -115,9 +108,9 @@ class CollectionNew extends React.Component {