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

Ability to rename Knobs / Actions Tab-Titles #6879

Closed
psi-4ward opened this issue May 24, 2019 · 13 comments
Closed

Ability to rename Knobs / Actions Tab-Titles #6879

psi-4ward opened this issue May 24, 2019 · 13 comments

Comments

@psi-4ward
Copy link

Would be cool to have the ability to use own title for Knobs and Actions tabs to make it more consistent with other frameworks like Vue: Props and Events.

If I look at the code it's hopefully not to difficult.

@stale
Copy link

stale bot commented Jun 15, 2019

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Jun 15, 2019
@stale
Copy link

stale bot commented Jul 15, 2019

Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

@stale stale bot closed this as completed Jul 15, 2019
@Utzel-Butzel
Copy link

Utzel-Butzel commented Aug 27, 2019

Hi psi-4ward, you can rename the Tab title by acessing the addons object in your config.

import addons from '@storybook/addons';

addons.elements.panel['storybookjs/knobs/panel'].title = 'Props';
addons.elements.panel['storybook/actions/panel'].title = 'Event';

@aviraminy
Copy link

aviraminy commented Oct 24, 2019

Hi psi-4ward, you can rename the Tab title by acessing the addons object in your config.

import addons from '@storybook/addons';

addons.elements.panel['storybookjs/knobs/panel'].title = 'Props';
addons.elements.panel['storybook/actions/panel'].title = 'Event';

actually this doesn't work for me at all i get an empty addons.elements object.
It seems to me that the addon register is delayed and that is why it isn't adding the element yet during the configure phase.

PS - i am using storybook v5.2.1

@diamond-darrell
Copy link

Hi psi-4ward, you can rename the Tab title by acessing the addons object in your config.

import addons from '@storybook/addons';

addons.elements.panel['storybookjs/knobs/panel'].title = 'Props';
addons.elements.panel['storybook/actions/panel'].title = 'Event';

actually this doesn't work for me at all i get an empty addons.elements object.
It seems to me that the addon register is delayed and that is why it isn't adding the element yet during the configure phase.

PS - i am using storybook v5.2.1

wrapping assignment in setTimeout worked out for me

@mboudriga
Copy link

mboudriga commented Nov 19, 2019

Hi psi-4ward, you can rename the Tab title by acessing the addons object in your config.

import addons from '@storybook/addons';

addons.elements.panel['storybookjs/knobs/panel'].title = 'Props';
addons.elements.panel['storybook/actions/panel'].title = 'Event';

actually this doesn't work for me at all i get an empty addons.elements object.
It seems to me that the addon register is delayed and that is why it isn't adding the element yet during the configure phase.
PS - i am using storybook v5.2.1

wrapping assignment in setTimeout worked out for me

This didn't work for me from the config.js file but did work from the addons.js file

import addons from "@storybook/addons";

setTimeout(function() {
  addons.elements.panel["storybookjs/knobs/panel"].title = "Props";
  addons.elements.panel["storybook/actions/panel"].title = "Events";
}, 0);

@aviraminy
Copy link

This is not such a good workaround and relies on runtime, i wish there was a proper config for this.

@diamond-darrell
Copy link

Hi psi-4ward, you can rename the Tab title by acessing the addons object in your config.

import addons from '@storybook/addons';

addons.elements.panel['storybookjs/knobs/panel'].title = 'Props';
addons.elements.panel['storybook/actions/panel'].title = 'Event';

actually this doesn't work for me at all i get an empty addons.elements object.
It seems to me that the addon register is delayed and that is why it isn't adding the element yet during the configure phase.
PS - i am using storybook v5.2.1

wrapping assignment in setTimeout worked out for me

This didn't work for me from the config.js file but did work from the addons.js file

import addons from "@storybook/addons";

setTimeout(function() {
  addons.elements.panel["storybookjs/knobs/panel"].title = "Props";
  addons.elements.panel["storybook/actions/panel"].title = "Events";
}, 0);

yes, I'm sorry, I should've mentioned it, I did this in the addons.js file as well as you are

@StanCreuna
Copy link

Is there a way to rename Addons like Controls/Actions in new Storybook?

@shilman
Copy link
Member

shilman commented Sep 10, 2021

@StanCreuna .storybook/addons.js has been renamed to .storybook/manager.js. The method above is not "officially supported" but you could give it a try in manager.js and I bet it would "just work."

@curtgrimes
Copy link

In recent versions of Storybook (I am on 6.5 alpha 48 currently) the workaround for changing the addon title changes slightly because the elements property is private.

This changes the Storysource addon's title to "Raw Source":

// in manager.js
setTimeout(() => {
    const sourceLoaderAddon = addons.getElements(types.PANEL)['storybook/source-loader/panel'];
    if (sourceLoaderAddon) {
        sourceLoaderAddon.title = 'Raw Source';
    }
}, 0);

@levaigabor
Copy link

@curtgrimes I just came across this problem, maybe you are looking for smth like this (from this PR #9095)?

   addon_id: string: {
    title?: string; // new title for the addon tab
    index?: number; // override the place/order of the tabs (by default the change uses the order of the addon_id keys but index can be used to override in the story parameyters
    hidden?: boolean; // wether to hide the addon tab
    disabled?: boolean; // wether to disable the addon tab
  }
}

@sag1v
Copy link

sag1v commented Aug 31, 2023

@levaigabor This doesn't seems to work, the only way that seems to work is the "workaround" suggested above.
(storybook v7)

In my case (trying to hide/remove a tab) i can't even use the suggested workaround, seems like the hidden property is ignored.

This is the only (ugly) way i managed to remove/hide a tab:

// .storybook/manager.js

setTimeout(() => {
  // removes the 'Code' tab from the panel
  const {
    ['storybook/source-loader/panel']: sourceTab,
    ...restOfTabs
  } = addons.elements.panel;
  addons.elements.panel = restOfTabs;
}, 0);

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

No branches or pull requests

10 participants