diff --git a/CHANGELOG.md b/CHANGELOG.md index 29181c985d..2bdffa8348 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ For details about compatibility between different releases, see the **Commitment ### Fixed +- Fix storybook errors. + ### Security ## [3.37.0] - unreleased diff --git a/config/storybook/preview-head.html b/config/storybook/preview-head.html index 25dc6bcf51..36c76273ba 100644 --- a/config/storybook/preview-head.html +++ b/config/storybook/preview-head.html @@ -2,6 +2,14 @@ window.__ttn_config__ = { APP_CONFIG: { documentation_base_url: 'https://thethingsstack.io', + stack_config: { + is: { enabled: true }, + gs: { enabled: true }, + ns: { enabled: true }, + as: { enabled: true }, + js: { enabled: true }, + gcs: { enabled: true }, + }, }, } diff --git a/config/storybook/preview.js b/config/storybook/preview.js index 8ab998ce6b..dcdc865699 100644 --- a/config/storybook/preview.js +++ b/config/storybook/preview.js @@ -17,9 +17,18 @@ import React from 'react' import { IntlProvider } from 'react-intl' import { MemoryRouter } from 'react-router-dom' +import { Provider } from 'react-redux' +import { configureStore } from '@reduxjs/toolkit' import messages from '@ttn-lw/locales/en.json' import backendMessages from '@ttn-lw/locales/.backend/en.json' +import rootReducer from '@console/store/reducers' + +import { BreadcrumbsProvider } from '@ttn-lw/components/breadcrumbs/context' +import { AlertBannerProvider } from '@ttn-lw/components/alert-banner/context' + +import { EventSplitFrameContextProvider } from '@console/containers/event-split-frame/context' +import { SidebarContextProvider } from '@console/containers/sidebar/context' import '../../pkg/webui/styles/main.styl' import '../../pkg/webui/styles/utilities/general.styl' @@ -28,12 +37,34 @@ import '../../pkg/webui/styles/utilities/tokens.styl' import 'focus-visible/dist/focus-visible' import Center from './center' +document.documentElement.classList.add('light') + +const store = configureStore({ + reducer: rootReducer, + middleware: getDefaultMiddleware => + getDefaultMiddleware({ serializableCheck: false, immutableCheck: false }), +}) + export const decorators = [ - Story => ( - - -
{Story()}
-
-
- ), + (Story, { parameters }) => { + const Router = parameters.dataRouter ? React.Fragment : MemoryRouter + + return ( + + + + + + + +
{Story()}
+
+
+
+
+
+
+
+ ) + }, ] diff --git a/pkg/webui/components/dropdown/story.js b/pkg/webui/components/dropdown/story.js index bf9f3f9a1e..d2e22b29fa 100644 --- a/pkg/webui/components/dropdown/story.js +++ b/pkg/webui/components/dropdown/story.js @@ -14,7 +14,7 @@ import React from 'react' -import { IconUser, IconLogout, IconAdminShield } from '@ttn-lw/components/icon' +import { IconUser, IconLogout, IconAdminPanel } from '@ttn-lw/components/icon' import Dropdown from '.' @@ -28,7 +28,7 @@ export const Default = () => ( - +
diff --git a/pkg/webui/components/header/story.js b/pkg/webui/components/header/story.js index 923954293b..f477638650 100644 --- a/pkg/webui/components/header/story.js +++ b/pkg/webui/components/header/story.js @@ -19,7 +19,7 @@ import TtsLogo from '@assets/static/tts-logo.svg' import { IconUser, IconLogout, - IconAdminShield, + IconAdminPanel, IconCreditCard, IconChartBar, IconBook, @@ -31,7 +31,6 @@ import { } from '@ttn-lw/components/icon' import Dropdown from '@ttn-lw/components/dropdown' import ExampleLogo from '@ttn-lw/components/logo/story-logo-new.svg' -import Breadcrumb from '@ttn-lw/components/breadcrumbs/breadcrumb' import Header from '.' @@ -59,7 +58,7 @@ const plusDropdownItems = ( ) -const starDropdownItems = ( +const bookmarkDropdownItems = ( <> @@ -79,7 +78,7 @@ const profileDropdownItems = ( path="/manage-cloud-subs" /> - +
@@ -89,24 +88,21 @@ const profileDropdownItems = ( ) -export const Default = () => { - const breadcrumbs = [ - , - , - , - ] +// eslint-disable-next-line react/prop-types +const Logo = ({ className }) => Logo - return ( -
-
-
- ) -} +export const Default = () => ( +
+
null} + expandSidebar={() => null} + /> +
+) diff --git a/pkg/webui/components/icon/story.js b/pkg/webui/components/icon/story.js index fd6b67d887..bb8747bca0 100644 --- a/pkg/webui/components/icon/story.js +++ b/pkg/webui/components/icon/story.js @@ -14,32 +14,46 @@ import React from 'react' -import Icon, { IconDevice } from '@ttn-lw/components/icon' +import Icon, { + IconApplication, + IconLiveData, + IconDevice, + IconGateway, + IconGeneralSettings, + IconIntegration, + IconLock, + IconLockOpen, + IconMenu2, + IconOrganization, + IconOverview, + IconSort, + IconTransform, + IconX, +} from '@ttn-lw/components/icon' import style from './story.styl' -const icons = [ - 'device', - 'integration', - 'settings', - 'lock', - 'lock_open', - 'close', - 'menu', - 'dashboard', - 'transform', - 'data', - 'sort', - 'overview', - 'application', - 'gateway', - 'organization', -] +const icons = { + IconDevice, + IconIntegration, + IconGeneralSettings, + IconLock, + IconLockOpen, + IconX, + IconMenu2, + IconTransform, + IconLiveData, + IconSort, + IconOverview, + IconApplication, + IconGateway, + IconOrganization, +} -const iconElement = icons.map(icon => ( -
+const iconElement = Object.entries(icons).map(([name, icon]) => ( +
- {icon} + {name}
)) diff --git a/pkg/webui/components/profile-dropdown/story.js b/pkg/webui/components/profile-dropdown/story.js index 5f67a63b31..c447e773de 100644 --- a/pkg/webui/components/profile-dropdown/story.js +++ b/pkg/webui/components/profile-dropdown/story.js @@ -17,7 +17,7 @@ import React from 'react' import { IconUser, IconLogout, - IconAdminShield, + IconAdminPanel, IconCreditCard, IconChartBar, IconBook, @@ -49,7 +49,7 @@ export const Default = () => ( path="/manage-cloud-subs" /> - +
diff --git a/pkg/webui/components/progress-bar/index.js b/pkg/webui/components/progress-bar/index.js index b300238e94..595f0f4a06 100644 --- a/pkg/webui/components/progress-bar/index.js +++ b/pkg/webui/components/progress-bar/index.js @@ -17,7 +17,7 @@ import classnames from 'classnames' import { defineMessages } from 'react-intl' import Message from '@ttn-lw/lib/components/message' -import RelativeDateTime from '@ttn-lw/lib/components/date-time/relative' +import DateTime from '@ttn-lw/lib/components/date-time' import PropTypes from '@ttn-lw/lib/prop-types' @@ -67,11 +67,11 @@ const ProgressBar = props => { displayEstimation = !showEstimation || estimations < 3 || // Avoid inaccurate early estimations. - estimatedDuration === Infinity || + !Number.isFinite(estimatedDuration) || !startTime ? null : (
- Estimated completion + Estimated completion
) @@ -107,11 +107,7 @@ const ProgressBar = props => { )} {children} {props.percentage !== undefined && ( - + )} {displayEstimation}
diff --git a/pkg/webui/components/prompt/story.js b/pkg/webui/components/prompt/story.js index e286b7eb92..e783a6d256 100644 --- a/pkg/webui/components/prompt/story.js +++ b/pkg/webui/components/prompt/story.js @@ -13,6 +13,7 @@ // limitations under the License. import React from 'react' +import { createMemoryRouter, RouterProvider } from 'react-router-dom' import { action } from '@storybook/addon-actions' import Link from '@ttn-lw/components/link' @@ -28,9 +29,11 @@ const linkContainerStyle = { export default { title: 'Prompt', component: Prompt, + // The `Prompt` component requires a data router. + parameters: { dataRouter: true }, } -export const Default = () => ( +const Content = () => (
Navigate using the links below to trigger the `Prompt` component to appear.
@@ -64,3 +67,7 @@ export const Default = () => (
) + +const router = createMemoryRouter([{ path: '*', element: }]) + +export const Default = () => diff --git a/pkg/webui/components/stepper/step/index.js b/pkg/webui/components/stepper/step/index.js index 9ab2043de0..177189dfe7 100644 --- a/pkg/webui/components/stepper/step/index.js +++ b/pkg/webui/components/stepper/step/index.js @@ -15,7 +15,7 @@ import React from 'react' import classnames from 'classnames' -import Icon, { IconCicleCheck, IconX } from '@ttn-lw/components/icon' +import Icon, { IconCircleCheck, IconX } from '@ttn-lw/components/icon' import Message from '@ttn-lw/lib/components/message' @@ -48,7 +48,7 @@ const Step = props => { let label if (isSuccess) { - label = + label = } else if (isFailure) { label = } else { diff --git a/pkg/webui/components/submit-bar/story.js b/pkg/webui/components/submit-bar/story.js index 56b6b6db33..2c7385a1b1 100644 --- a/pkg/webui/components/submit-bar/story.js +++ b/pkg/webui/components/submit-bar/story.js @@ -14,7 +14,7 @@ import React from 'react' -import { IconCicleCheck, IconTrash } from '@ttn-lw/components/icon' +import { IconCircleCheck, IconTrash } from '@ttn-lw/components/icon' import Button from '@ttn-lw/components/button' import SubmitBar from '.' @@ -25,13 +25,13 @@ export default { export const OnlySubmit = () => ( -