refine icon indicating copy to clipboard operation
refine copied to clipboard

[FEAT] Customization of RefineKbar

Open bastianwegge opened this issue 1 year ago • 5 comments

Is your feature request related to a problem? Please describe.

Currently it's possible to have resources with the same name but different identifiers. We are using this to differentiate between different databases, that have the same kind of model inside (i.e. Country). The problem here is that we cannot differentiate between the resources, since the dataProvider or dataProviderName is not taken into concern.

Describe alternatives you've considered

  • We could go ahead and rewrite the RefineKbar provider ourselves, but that'd just lead to a separating solution where nobody benefits ultimately
  • We could also just rewrite a similar provider, but then we'd face issues when it comes down to access control

Describe the thing to improve

The problem is that RefineKbar is not customizable. Customizing a component inside of a framework to your needs is ultimately what Refine should be able to do for its users. I'd love to see a way of providing a template or component for the RefineKbar component that might take specialized Resource-Attributes and just renders what the user passed in.

bastianwegge avatar Jun 21 '23 12:06 bastianwegge

Hello @bastianwegge, thanks for the issue as always and sorry for the late reply.

Our KBar package is quite outdated atm, I've added this issue to our backlog, we'll work on this one in our next sprint!

BatuhanW avatar Jun 23 '23 12:06 BatuhanW

Thanks for the reply @BatuhanW !

I have copied the code for useRefineKbar and adjusted the section like this which had the desired effect:

let section = label;
if (resource.meta?.parent) {
  section = `${resource.meta?.parent} ${t(
    `${resource.name}.${resource.name}`,
    userFriendlyResourceName(resource.name, 'plural'),
  )}`;
}

I think adding a render prop for both the section as well as the displayed action would make sense here. If you want to go all the way, you could also provide a way to create custom kbar-Actions and pass them to useRefineKbar.

Again thanks for working with my feedback! Looking forward to making progress here! 💪

bastianwegge avatar Jun 23 '23 14:06 bastianwegge

Glad to see you have a workaround for now, stay tuned for the updates 🙌🏼

BatuhanW avatar Jun 23 '23 15:06 BatuhanW

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[bot] avatar Aug 22 '23 15:08 stale[bot]

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[bot] avatar Jan 20 '24 10:01 stale[bot]