-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(api): Extend getMetadata in Metadata API #3611
Conversation
6910705
to
165b976
Compare
165b976
to
5c28b98
Compare
5c28b98
to
a38a799
Compare
src/api/Metadata.js
Outdated
description: field.description, | ||
displayName: field.displayName, | ||
hidden: field.hidden, | ||
id: field.id, | ||
key: field.key, | ||
options: field.options, | ||
type: field.type, | ||
value: instance[field.key], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about:
description: field.description, | |
displayName: field.displayName, | |
hidden: field.hidden, | |
id: field.id, | |
key: field.key, | |
options: field.options, | |
type: field.type, | |
value: instance[field.key], | |
...field, | |
value: instance[field.key], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MetadataTemplateField
has isHidden
field which is not expected by MetadataTemplateInstanceField
, but it's the only difference which does not collide that much. I implemented your suggestion.
src/api/Metadata.js
Outdated
displayName: template.displayName, | ||
hidden: template.hidden, | ||
id: template.id, | ||
metadataFields, | ||
scope: template.scope, | ||
templateKey: template.templateKey, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
displayName: template.displayName, | |
hidden: template.hidden, | |
id: template.id, | |
metadataFields, | |
scope: template.scope, | |
templateKey: template.templateKey, | |
...template, | |
fields: metadataFields |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't implement this as suggested because template: MetadataTemplate
has isHidden
field that we do not want to have in MetadataTemplateInstance
. Moreover, template: MetadataTemplate
already has fields
defined which has incompatible type - it's type is Array<MetadataTemplateField>
while MetadataTemplateInstance
is expecting MetadataTemplateInstanceField[]
. The difference in these two types is that the first one has isHidden
and does not have value
in comparison to second one.
All in all, I'd rather stay with my implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
91e218b
to
6f5f319
Compare
This change extends
getMetadata
method inMetadata API
in order to meet Metadata Sidebar Redesign needs as it will require less complex typing.Currently MetadataSidebar fetches
editors
which are objects containing:template
object - it holds data on which template was used to create metadata instance for current file and current user and most importantly it holdsfields
array. This array consists offield
objects which hold details on field displayName, field type etc. but do not hold field value for current file and current user - this is job forinstance
object.instance
object - as explained above is simple object with instance details like id and key-value pairs which reflect template fields keys.For now in order to get field details AND value for particular metadata instance, there's a lot of mapping needed which makes components implementation less straight forward. Additionally, more types are needed to handle that.
On the top of that, most of the above explanation is not valid in custom metadata case as it does not use templates. This makes whole logic even more complex.
We want to improve this in new Metadata Sidebar to simplify logic inside components and reduce number of types. In this change we are unifying data provided for metadata instances from template and custom metadata, so that components do not have to introduce any additional logic, checks etc. In redesigned Metadata Sidebar we'll introduce the same component for viewing both metadata instances from template and custom metadata instead of dedicated component for each type of instance.