Skip to content

Commit

Permalink
GO-5126 Migrate types icons
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillSto committed Feb 18, 2025
1 parent 175f496 commit 91715f3
Show file tree
Hide file tree
Showing 9 changed files with 824 additions and 644 deletions.
2 changes: 2 additions & 0 deletions core/block/editor/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ var typeRequiredRelations = append(typeAndRelationRequiredRelations,
bundle.RelationKeyRecommendedFileRelations,
bundle.RelationKeyRecommendedLayout,
bundle.RelationKeySmartblockTypes,
bundle.RelationKeyIconOption,
bundle.RelationKeyIconName,
)

var relationRequiredRelations = append(typeAndRelationRequiredRelations,
Expand Down
3 changes: 2 additions & 1 deletion core/relationutils/objecttype.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func (ot *ObjectType) BundledTypeDetails() *domain.Details {
det.SetInt64(bundle.RelationKeyLayout, int64(model.ObjectType_objectType))
det.SetString(bundle.RelationKeyName, ot.Name)
det.SetString(bundle.RelationKeyCreator, addr.AnytypeProfileId)
det.SetString(bundle.RelationKeyIconEmoji, ot.IconEmoji)
det.SetString(bundle.RelationKeyUniqueKey, uk.Marshal())
det.SetStringList(bundle.RelationKeyRecommendedRelations, relationIds)
det.SetInt64(bundle.RelationKeyRecommendedLayout, int64(ot.Layout))
Expand All @@ -54,5 +53,7 @@ func (ot *ObjectType) BundledTypeDetails() *domain.Details {
det.SetString(bundle.RelationKeySpaceId, addr.AnytypeMarketplaceWorkspace)
det.SetInt64(bundle.RelationKeyOrigin, int64(model.ObjectOrigin_builtin))
det.SetInt64(bundle.RelationKeyRevision, ot.Revision)
det.SetInt64(bundle.RelationKeyIconOption, ot.IconColor)
det.SetString(bundle.RelationKeyIconName, ot.IconName)
return det
}
2 changes: 2 additions & 0 deletions docs/proto.md
Original file line number Diff line number Diff line change
Expand Up @@ -30387,6 +30387,8 @@ Used to decode block meta only, without the content itself
| key | [string](#string) | | name of objectType (can be localized for bundled types) |
| revision | [int64](#int64) | | revision of system objectType. Used to check if we should change type content or not |
| restrictObjectCreation | [bool](#bool) | | restricts creating objects of this type for users |
| iconColor | [int64](#int64) | | color of object type icon |
| iconName | [string](#string) | | name of object type icon |



Expand Down
11 changes: 8 additions & 3 deletions pkg/lib/bundle/generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ type ObjectType struct {
Description string `json:"description"`
Revision int `json:"revision"`
RestrictObjectCreation bool `json:"restrictObjectCreation"`
IconColor int `json:"iconColor"`
IconName string `json:"iconName"`
}

type Layout struct {
Expand Down Expand Up @@ -277,9 +279,6 @@ func generateTypes() error {
if ot.Hidden {
dictS[Id("Hidden")] = Lit(ot.Hidden)
}
if ot.Emoji != "" {
dictS[Id("IconEmoji")] = Lit(ot.Emoji)
}

dictS[Id("Readonly")] = Lit(true)

Expand Down Expand Up @@ -310,6 +309,12 @@ func generateTypes() error {
dictS[Id("RestrictObjectCreation")] = Lit(ot.RestrictObjectCreation)
}

dictS[Id("IconColor")] = Lit(ot.IconColor)

if ot.IconName != "" {
dictS[Id("IconName")] = Lit(ot.IconName)
}

dict[Id(typeConst(ot.ID))] = Block(dictS)
}
g.Id("types").Op("=").Map(Qual(domainPkg, "TypeKey")).Op("*").Qual(relPbPkg, "ObjectType").Values(Dict(dict))
Expand Down
Loading

0 comments on commit 91715f3

Please sign in to comment.