Skip to content
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

ui.itemProps on collections #3411

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

newash
Copy link

@newash newash commented Nov 20, 2022

Hello!

I created this PR for #3389

I tried it with experimental-examples/tina-cloud-starter adding the draft field and the ui.itemProps to the collection schema:

...
const schema = defineSchema({
  collections: [
    {
      label: "Blog Posts",
      name: "posts",
      path: "content/posts",
      format: "mdx",
      ui: {
        router: ({ document, collection }) => {
          return `/${collection.name}/${document._sys.filename}`;
        },
        itemProps: (item) => ({
          label: item.draft ? `🚧 ${item.title}` : item.title,
          className: item.draft ? 'bg-blue-50' : ''
        })
      },
      fields: [
        {
          type: "boolean",
          name: "draft",
          label: "Draft",
        },
...

and could produce this:

2022-11-20_15h58_05


I'm not sure though if both packages/@tinacms/schema-tools/src/types.ts and packages/@tinacms/schema-tools/src/types/SchemaTypes.ts file needed to be updated, or one would have been enough.

I also haven't looked into your tests, so I'm not sure about the necessary tests either.

@newash newash requested a review from a team as a code owner November 20, 2022 15:09
@changeset-bot
Copy link

changeset-bot bot commented Nov 20, 2022

🦋 Changeset detected

Latest commit: 08c26ac

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@tinacms/schema-tools Minor
tinacms Minor
@tinacms/cli Patch
@tinacms/graphql Patch
@tinacms/mdx Patch
starter-basic-iframe Patch
starter-basic Patch
starter-empty Patch
e2e-next Patch
kitchen-sink-starter Patch
@tinacms/starter-iframe Patch
@tinacms/starter Patch
kitchen-sink Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@CLAassistant
Copy link

CLAassistant commented Nov 20, 2022

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link
Contributor

Warnings
⚠️

packages/tinacms was modified but its README.md was not updated. Please check if any changes should be reflected in the documentation.

⚠️

packages/@tinacms/schema-tools was modified but its README.md was not updated. Please check if any changes should be reflected in the documentation.

Modified Packages

The following packages were modified by this pull request:

  • @tinacms/schema-tools
  • tinacms

Generated by 🚫 dangerJS against 08c26ac

@@ -97,6 +97,7 @@ export class TinaAdminApi {
filename
extension
}
_values
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the PR is nicely small, you might agree that it's not very bandwidth-efficient.

What I could change here, is to introduce a _sys.fields attribute
in packages/@tinacms/graphql/src/resolver/index.ts instead:
an object that would have only the subset of fields.

The question is: what that subset should contain?

  • everything but the one with isBody: true ?
  • everything but those with type: "rich-text"?
  • only those with simple types? (not rich-text and not object)

That is a design decision, and you probably in a better position than me to answer that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is a good point, it has the potential to de-optimize that query, it might be best to provide a property on field definitions that would populate it to the _sys.fields property, as you noted.

It's not so much a matter of the size of payload, but also if we can avoid providing the _values then we can skip retrieving the document entirely (basically the same thing we do with _sys.title, except it'd be a JSON type probably.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just thinking ahead a bit, If the user can specify which fields they want available to that list-view, maybe we should allow them to create new columns for a given field?
In that case, instead of using itemProps to control the label field, they'd be able to control the UI for any given column, as opposed to just the title-label.

Screen Shot 2023-01-17 at 9 39 00 AM

(Another common example might be including a custom "author" field in this list).

@jeffsee55
Copy link
Member

Thanks for the PR @newash - we'll discuss the ramifications of including the _values key as you mention, but this is a solid approach!

@newash
Copy link
Author

newash commented Jan 3, 2023

Do you have any updates on this @jeffsee55 ?

@jeffsee55
Copy link
Member

We'll be discussing this next week and we'll get back to you, thanks @newash !

@newash
Copy link
Author

newash commented Feb 1, 2023

Any update lads?

@jeffsee55
Copy link
Member

Hey @newash - sorry for the delay, this PR is definitely something we'd like to have but it introduces more complexity than we'd thought. We don't have the bandwidth right now to approach it properly, but do plan to address it.

@stale
Copy link

stale bot commented Jun 26, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Jun 26, 2023
@newash
Copy link
Author

newash commented Jun 26, 2023

I still need this

@stale stale bot removed the wontfix This will not be worked on label Jun 26, 2023
@jeffsee55
Copy link
Member

not stale

@stale
Copy link

stale bot commented Oct 28, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Oct 28, 2023
@newash
Copy link
Author

newash commented Oct 28, 2023

still need this

@stale stale bot removed the wontfix This will not be worked on label Oct 28, 2023
Copy link

stale bot commented Apr 25, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Apr 25, 2024
@newash
Copy link
Author

newash commented Apr 25, 2024

will this ever be addressed?

@stale stale bot removed the wontfix This will not be worked on label Apr 25, 2024
@scottgallant
Copy link
Member

Hey @newash, I've been thinking a lot about the suggestion here and would like to go that route:

#3411 (comment)

What do you think?

Our roadmap is fully booked for the next few weeks, but I'll try to slot this in shortly after that.

@newash
Copy link
Author

newash commented Apr 25, 2024

Of course, I'm not going to argue against your obviously neater solution. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants