1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-09 09:35:00 +09:00

Merge pull request #1960 from anyproto/go-4724-remove-template-restriction-from-sets

GO-4724 Remove template restriction from sets
This commit is contained in:
Kirill Stonozhenko 2024-12-18 13:11:03 +01:00 committed by GitHub
commit 713dbf0aac
Signed by: github
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 9 deletions

View file

@ -35,6 +35,11 @@ var (
model.Restrictions_Blocks,
model.Restrictions_LayoutChange,
model.Restrictions_TypeChange,
}
objRestrictEditAndTemplate = ObjectRestrictions{
model.Restrictions_Blocks,
model.Restrictions_LayoutChange,
model.Restrictions_TypeChange,
model.Restrictions_Template,
}
sysTypesRestrictions = ObjectRestrictions{
@ -61,8 +66,8 @@ var (
model.ObjectType_todo: {},
model.ObjectType_set: objRestrictEdit,
model.ObjectType_collection: objRestrictEdit,
model.ObjectType_objectType: objRestrictEdit,
model.ObjectType_relation: objRestrictEdit,
model.ObjectType_objectType: objRestrictEditAndTemplate,
model.ObjectType_relation: objRestrictEditAndTemplate,
model.ObjectType_file: objRestrictEditAndDuplicate,
model.ObjectType_dashboard: {
model.Restrictions_Details,
@ -80,14 +85,14 @@ var (
},
model.ObjectType_bookmark: {},
model.ObjectType_relationOption: objRestrictEdit,
model.ObjectType_relationOption: objRestrictEditAndTemplate,
model.ObjectType_relationOptionsList: {
model.Restrictions_Template,
},
model.ObjectType_participant: objRestrictAll,
model.ObjectType_chat: objRestrictEditAndDuplicate,
model.ObjectType_chatDerived: objRestrictEditAndDuplicate,
model.ObjectType_tag: objRestrictEdit,
model.ObjectType_tag: objRestrictEditAndTemplate,
}
objectRestrictionsBySBType = map[smartblock.SmartBlockType]ObjectRestrictions{
@ -120,9 +125,9 @@ var (
smartblock.SmartBlockTypeFileObject: objRestrictEditAndDuplicate,
smartblock.SmartBlockTypeArchive: objRestrictAll,
smartblock.SmartBlockTypeBundledRelation: objRestrictAll,
smartblock.SmartBlockTypeSubObject: objRestrictEdit,
smartblock.SmartBlockTypeObjectType: objRestrictEdit,
smartblock.SmartBlockTypeRelation: objRestrictEdit,
smartblock.SmartBlockTypeSubObject: objRestrictEditAndTemplate,
smartblock.SmartBlockTypeObjectType: objRestrictEditAndTemplate,
smartblock.SmartBlockTypeRelation: objRestrictEditAndTemplate,
smartblock.SmartBlockTypeBundledObjectType: objRestrictAll,
smartblock.SmartBlockTypeBundledTemplate: objRestrictAll,
smartblock.SmartBlockTypeTemplate: {

View file

@ -108,9 +108,11 @@ func TestTemplateRestriction(t *testing.T) {
assert.ErrorIs(t, rs.GetRestrictions(template).Object.Check(model.Restrictions_Template), ErrRestricted)
})
t.Run("cannot make template from set or collection layout", func(t *testing.T) {
t.Run("we CAN make template from set or collection layout", func(t *testing.T) {
collection := givenRestrictionHolder(coresb.SmartBlockTypePage, bundle.TypeKeyCollection)
assert.ErrorIs(t, rs.GetRestrictions(collection).Object.Check(model.Restrictions_Template), ErrRestricted)
set := givenRestrictionHolder(coresb.SmartBlockTypePage, bundle.TypeKeySet)
assert.NoError(t, rs.GetRestrictions(collection).Object.Check(model.Restrictions_Template))
assert.NoError(t, rs.GetRestrictions(set).Object.Check(model.Restrictions_Template))
})
t.Run("cannot make template from space layout", func(t *testing.T) {