This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Improving storybook for current widgets and in general #3736
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7427978
Improving storybook components information
jespino fbf2fb4
Merge remote-tracking branch 'origin/master' into MM-18212
jespino e26dff5
Adding a mattermost theme
jespino 15573dd
Moving menu_item_blockable_link outside of the widgets
jespino 1974321
Upgrade to storybook 5.2.0
jespino e36f683
Upgrade to storybook 5.2.1
jespino 3cc38c5
Merge remote-tracking branch 'origin/master' into MM-18212
jespino File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Improving storybook components information
- Loading branch information
commit 742797804950f208664390de3743f949d70511f1
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
components/admin_console/admin_navbar_dropdown/menu_item_blockable_link.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import BlockableLink from 'components/admin_console/blockable_link'; | ||
import menuItem from 'components/widgets/menu/menu_items/menu_item'; | ||
|
||
export const MenuItemBlockableLinkImpl = ({to, text}) => <BlockableLink to={to}>{text}</BlockableLink>; | ||
MenuItemBlockableLinkImpl.propTypes = { | ||
to: PropTypes.string.isRequired, | ||
text: PropTypes.oneOfType([PropTypes.string, PropTypes.node]).isRequired, | ||
}; | ||
|
||
const MenuItemBlockableLink = menuItem(MenuItemBlockableLinkImpl); | ||
MenuItemBlockableLink.displayName = 'MenuItemBlockableLinkImpl'; | ||
|
||
export default MenuItemBlockableLink; |
26 changes: 26 additions & 0 deletions
26
components/admin_console/admin_navbar_dropdown/menu_item_blockable_link.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import React from 'react'; | ||
import {shallow} from 'enzyme'; | ||
|
||
import {MenuItemBlockableLinkImpl} from './menu_item_blockable_link.jsx'; | ||
|
||
describe('components/MenuItemBlockableLink', () => { | ||
test('should match snapshot', () => { | ||
const wrapper = shallow( | ||
<MenuItemBlockableLinkImpl | ||
to='/wherever' | ||
text='Whatever' | ||
/> | ||
); | ||
|
||
expect(wrapper).toMatchInlineSnapshot(` | ||
<Connect(BlockableLink) | ||
to="/wherever" | ||
> | ||
Whatever | ||
</Connect(BlockableLink)> | ||
`); | ||
}); | ||
}); |
140 changes: 140 additions & 0 deletions
140
components/widgets/admin_console/admin_console.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import React, {useState} from 'react'; | ||
|
||
import {storiesOf} from '@storybook/react'; | ||
import {withKnobs, text, boolean} from '@storybook/addon-knobs'; | ||
import {action} from '@storybook/addon-actions'; | ||
|
||
import AdminPanel from './admin_panel'; | ||
import AdminPanelTogglable from './admin_panel_togglable'; | ||
import AdminPanelWithButton from './admin_panel_with_button'; | ||
import AdminPanelWithLink from './admin_panel_with_link'; | ||
import AdminHeader from './admin_header'; | ||
import FormattedAdminHeader from './formatted_admin_header'; | ||
|
||
storiesOf('Admin Console', module). | ||
addDecorator(withKnobs). | ||
add( | ||
'admin panel', | ||
() => { | ||
const content = text('Content', 'Content'); | ||
const onHeaderClick = action('clicked header'); | ||
const onButtonClick = action('clicked button'); | ||
const title = text('Title', 'title'); | ||
const subtitle = text('Subtitle', 'subtitle'); | ||
const hasButton = boolean('HasButton', false); | ||
return ( | ||
<AdminPanel | ||
onHeaderClick={onHeaderClick} | ||
titleId='not-valid-id' | ||
titleDefault={title} | ||
subtitleId='not-valid-id' | ||
subtitleDefault={subtitle} | ||
button={hasButton ? <button onClick={onButtonClick}>{'Button'}</button> : null} | ||
> | ||
{content} | ||
</AdminPanel> | ||
); | ||
} | ||
). | ||
add( | ||
'admin panel with button', | ||
() => { | ||
const content = text('Content', 'Content'); | ||
const onHeaderClick = action('clicked header'); | ||
const onButtonClick = action('clicked button'); | ||
const title = text('Title', 'title'); | ||
const subtitle = text('Subtitle', 'subtitle'); | ||
const buttonText = text('Button text', 'Button'); | ||
const disabled = boolean('Button disabled', false); | ||
return ( | ||
<AdminPanelWithButton | ||
onHeaderClick={onHeaderClick} | ||
titleId='not-valid-id' | ||
titleDefault={title} | ||
subtitleId='not-valid-id' | ||
subtitleDefault={subtitle} | ||
buttonTextId='not-valid-id' | ||
buttonTextDefault={buttonText} | ||
onButtonClick={onButtonClick} | ||
disabled={disabled} | ||
> | ||
{content} | ||
</AdminPanelWithButton> | ||
); | ||
} | ||
). | ||
add( | ||
'admin panel with link', | ||
() => { | ||
const content = text('Content', 'Content'); | ||
const onHeaderClick = action('clicked header'); | ||
const title = text('Title', 'title'); | ||
const subtitle = text('Subtitle', 'subtitle'); | ||
const linkText = text('Link text', 'Home'); | ||
const url = text('Link url', '/'); | ||
const disabled = boolean('Button disabled', false); | ||
return ( | ||
<AdminPanelWithLink | ||
onHeaderClick={onHeaderClick} | ||
titleId='not-valid-id' | ||
titleDefault={title} | ||
subtitleId='not-valid-id' | ||
subtitleDefault={subtitle} | ||
linkTextId='not-valid-id' | ||
linkTextDefault={linkText} | ||
url={url} | ||
disabled={disabled} | ||
> | ||
{content} | ||
</AdminPanelWithLink> | ||
); | ||
} | ||
). | ||
add( | ||
'togglable admin panel', | ||
() => { | ||
const content = text('Content', 'Content'); | ||
const title = text('Title', 'title'); | ||
const subtitle = text('Subtitle', 'subtitle'); | ||
const Wrapper = () => { | ||
const [open, setOpen] = useState(true); | ||
return ( | ||
<AdminPanelTogglable | ||
titleId='not-valid-id' | ||
titleDefault={title} | ||
subtitleId='not-valid-id' | ||
subtitleDefault={subtitle} | ||
open={open} | ||
onToggle={() => setOpen(!open)} | ||
> | ||
{content} | ||
</AdminPanelTogglable> | ||
); | ||
}; | ||
return <Wrapper/>; | ||
} | ||
). | ||
add( | ||
'admin header', | ||
() => { | ||
const title = text('Title', 'title'); | ||
return ( | ||
<AdminHeader>{title}</AdminHeader> | ||
); | ||
} | ||
). | ||
add( | ||
'formatted admin header', | ||
() => { | ||
const markdown = text('Markdown', '**Markdown** text'); | ||
return ( | ||
<FormattedAdminHeader | ||
id='not-valid-id' | ||
defaultMessage={markdown} | ||
/> | ||
); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
import React, {useState} from 'react'; | ||
|
||
import {storiesOf} from '@storybook/react'; | ||
import {withKnobs, text} from '@storybook/addon-knobs'; | ||
|
||
import ChannelsInput from './channels_input'; | ||
import UsersEmailsInput from './users_emails_input'; | ||
|
||
storiesOf('Inputs', module). | ||
addDecorator(withKnobs). | ||
add( | ||
'channels input', | ||
() => { | ||
const WrapperComponent = () => { | ||
const placeholder = text('Placeholder', 'Placeholder'); | ||
const loadingMessageDefault = text('Loading Message', 'Loading'); | ||
const noOptionsMessageDefault = text('No Options Message', 'No channels found'); | ||
const options = [ | ||
{id: '1', name: 'public', display_name: 'Public Channel', type: 'O'}, | ||
{id: '2', name: 'private', display_name: 'Private Channel', type: 'P'}, | ||
{id: '3', name: 'town-square', display_name: 'Town Square', type: 'O'}, | ||
{id: '4', name: 'off-topic', display_name: 'Off Topic', type: 'O'}, | ||
]; | ||
|
||
const [value, setValue] = useState([]); | ||
const [inputValue, setInputValue] = useState(''); | ||
|
||
const channelsLoader = (input, callback) => { | ||
const values = options.filter((channel) => channel.display_name.toLowerCase().startsWith(input.toLowerCase())); | ||
setTimeout(() => callback(values), 500); | ||
}; | ||
|
||
return ( | ||
<ChannelsInput | ||
channelsLoader={channelsLoader} | ||
placeholder={placeholder} | ||
onChange={setValue} | ||
value={value} | ||
onInputChange={setInputValue} | ||
inputValue={inputValue} | ||
loadingMessageDefault={loadingMessageDefault} | ||
loadingMessageId='not-existing-id' | ||
noOptionsMessageDefault={noOptionsMessageDefault} | ||
noOptionsMessageId='not-existing-id' | ||
/> | ||
); | ||
}; | ||
return ( | ||
<WrapperComponent/> | ||
); | ||
} | ||
). | ||
add( | ||
'users emails input', | ||
() => { | ||
const WrapperComponent = () => { | ||
const placeholder = text('Placeholder', 'Placeholder'); | ||
const loadingMessageDefault = text('Loading Message', 'Loading'); | ||
const noMatchMessageDefault = text('No Match Message', 'No one found matching **{text}**, type email address'); | ||
const validAddressMessageDefault = text('Valid Address', 'Add **{email}**'); | ||
const options = [ | ||
{id: '1', username: 'jesus.espino', first_name: 'Jesús', last_name: 'Espino', nickname: 'jespino'}, | ||
{id: '2', username: 'jora.wilander', first_name: 'Joram', last_name: 'Wilander', nickname: 'jwilander'}, | ||
{id: '3', username: 'ben.schumaher', first_name: 'Ben', last_name: 'Schumacher', nickname: 'Hanzei'}, | ||
{id: '4', username: 'martin.kraft', first_name: 'Martin', last_name: 'Kraft', nickname: 'mkraft'}, | ||
]; | ||
|
||
const [value, setValue] = useState([]); | ||
const [inputValue, setInputValue] = useState(''); | ||
|
||
const usersLoader = (input, callback) => { | ||
const values = options.filter((user) => { | ||
return ( | ||
user.first_name.toLowerCase().startsWith(input.toLowerCase()) || | ||
user.last_name.toLowerCase().startsWith(input.toLowerCase()) || | ||
user.username.toLowerCase().startsWith(input.toLowerCase()) || | ||
user.nickname.toLowerCase().startsWith(input.toLowerCase()) | ||
); | ||
}); | ||
setTimeout(() => callback(values), 500); | ||
}; | ||
|
||
return ( | ||
<UsersEmailsInput | ||
usersLoader={usersLoader} | ||
placeholder={placeholder} | ||
onChange={setValue} | ||
value={value} | ||
onInputChange={setInputValue} | ||
inputValue={inputValue} | ||
loadingMessageDefault={loadingMessageDefault} | ||
loadingMessageId='not-existing-id' | ||
noMatchMessageDefault={noMatchMessageDefault} | ||
noMatchMessageId='not-existing-id' | ||
validAddressMessageDefault={validAddressMessageDefault} | ||
validAddressMessageId='not-existing-id' | ||
/> | ||
); | ||
}; | ||
return ( | ||
<WrapperComponent/> | ||
); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
sass/widgets/menu/_menu.scss → components/widgets/menu/menu.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
@import 'compass/utilities'; | ||
@import 'compass/css3'; | ||
|
||
.Menu { | ||
z-index: 10000; | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Moving this outside the Menu widget because is too specific to this case, so makes no sense as a general menu entry type.