parent
4658208560
commit
50375898a0
@ -1,3 +1,37 @@ |
||||
import { configure } from '@storybook/react'; |
||||
import { action } from '@storybook/addon-actions'; |
||||
import { addDecorator, configure } from '@storybook/react'; |
||||
import React from 'react'; |
||||
|
||||
import { ConnectionStatusProvider } from '../client/components/providers/ConnectionStatusProvider.mock'; |
||||
import { TranslationProvider } from '../client/components/providers/TranslationProvider.mock'; |
||||
|
||||
addDecorator(function RocketChatDecorator(fn) { |
||||
require('@rocket.chat/icons/dist/font/RocketChat.minimal.css'); |
||||
require('../app/theme/client/main.css'); |
||||
|
||||
const linkElement = document.getElementById('theme-styles') || document.createElement('link'); |
||||
if (linkElement.id !== 'theme-styles') { |
||||
linkElement.setAttribute('id', 'theme-styles'); |
||||
linkElement.setAttribute('rel', 'stylesheet'); |
||||
linkElement.setAttribute('href', 'https://open.rocket.chat/theme.css'); |
||||
document.head.appendChild(linkElement); |
||||
} |
||||
|
||||
return <ConnectionStatusProvider connected status='connected' reconnect={action('reconnect')}> |
||||
<TranslationProvider> |
||||
<style>{` |
||||
body { |
||||
background-color: white; |
||||
} |
||||
`}</style>
|
||||
<div className='rc-old'> |
||||
<div dangerouslySetInnerHTML={{__html: require('!!raw-loader!../private/public/icons.svg').default}} /> |
||||
<div className='global-font-family color-primary-font-color'> |
||||
{fn()} |
||||
</div> |
||||
</div> |
||||
</TranslationProvider> |
||||
</ConnectionStatusProvider>; |
||||
}); |
||||
|
||||
configure(require.context('../client', true, /\.stories\.js$/), module); |
||||
|
||||
@ -1,44 +1 @@ |
||||
import { action } from '@storybook/addon-actions'; |
||||
import '@rocket.chat/icons/dist/font/RocketChat.minimal.css'; |
||||
import React from 'react'; |
||||
|
||||
import '../app/theme/client/main.css'; |
||||
import { ConnectionStatusProvider } from '../client/components/providers/ConnectionStatusProvider.mock'; |
||||
import { TranslationProvider } from '../client/components/providers/TranslationProvider.mock'; |
||||
|
||||
export const rocketChatWrapper = (fn) => |
||||
<ConnectionStatusProvider connected status='connected' reconnect={action('reconnect')}> |
||||
<TranslationProvider> |
||||
<style>{` |
||||
body { |
||||
background-color: white; |
||||
} |
||||
|
||||
.global-font-family { |
||||
font-family: |
||||
-apple-system, |
||||
BlinkMacSystemFont, |
||||
'Segoe UI', |
||||
Roboto, |
||||
Oxygen, |
||||
Ubuntu, |
||||
Cantarell, |
||||
'Helvetica Neue', |
||||
'Apple Color Emoji', |
||||
'Segoe UI Emoji', |
||||
'Segoe UI Symbol', |
||||
'Meiryo UI', |
||||
Arial, |
||||
sans-serif; |
||||
} |
||||
|
||||
.color-primary-font-color { |
||||
color: #444; |
||||
} |
||||
`}</style>
|
||||
<div dangerouslySetInnerHTML={{__html: require('!!raw-loader!../private/public/icons.svg').default}} /> |
||||
<div className='global-font-family color-primary-font-color'> |
||||
{fn()} |
||||
</div> |
||||
</TranslationProvider> |
||||
</ConnectionStatusProvider>; |
||||
export const dummyDate = new Date(2015, 4, 19); |
||||
|
||||
@ -0,0 +1,21 @@ |
||||
import React from 'react'; |
||||
|
||||
import { dummyDate } from '../../../../.storybook/helpers'; |
||||
import { BuildEnvironmentSection } from './BuildEnvironmentSection'; |
||||
|
||||
export default { |
||||
title: 'admin/info/BuildEnvironmentSection', |
||||
component: BuildEnvironmentSection, |
||||
}; |
||||
|
||||
const info = { |
||||
compile: { |
||||
platform: 'info.compile.platform', |
||||
arch: 'info.compile.arch', |
||||
osRelease: 'info.compile.osRelease', |
||||
nodeVersion: 'info.compile.nodeVersion', |
||||
date: dummyDate, |
||||
}, |
||||
}; |
||||
|
||||
export const _default = () => <BuildEnvironmentSection info={info} />; |
||||
@ -0,0 +1,21 @@ |
||||
import React from 'react'; |
||||
|
||||
import { CommitSection } from './CommitSection'; |
||||
|
||||
export default { |
||||
title: 'admin/info/CommitSection', |
||||
component: CommitSection, |
||||
}; |
||||
|
||||
const info = { |
||||
commit: { |
||||
hash: 'info.commit.hash', |
||||
date: 'info.commit.date', |
||||
branch: 'info.commit.branch', |
||||
tag: 'info.commit.tag', |
||||
author: 'info.commit.author', |
||||
subject: 'info.commit.subject', |
||||
}, |
||||
}; |
||||
|
||||
export const _default = () => <CommitSection info={info} />; |
||||
@ -0,0 +1,20 @@ |
||||
import React from 'react'; |
||||
|
||||
import { InformationList } from './InformationList'; |
||||
import { InformationEntry } from './InformationEntry'; |
||||
|
||||
export default { |
||||
title: 'admin/info/InformationList', |
||||
component: InformationList, |
||||
decorators: [ |
||||
(fn) => <section className='page-container page-list'> |
||||
<div className='content'> |
||||
{fn()} |
||||
</div> |
||||
</section>, |
||||
], |
||||
}; |
||||
|
||||
export const _default = () => <InformationList> |
||||
<InformationEntry label='Key'>Value</InformationEntry> |
||||
</InformationList>; |
||||
@ -0,0 +1,29 @@ |
||||
import React from 'react'; |
||||
|
||||
import { dummyDate } from '../../../../.storybook/helpers'; |
||||
import { InstancesSection } from './InstancesSection'; |
||||
|
||||
export default { |
||||
title: 'admin/info/InstancesSection', |
||||
component: InstancesSection, |
||||
}; |
||||
|
||||
const instances = [ |
||||
{ |
||||
address: 'instances[].address', |
||||
broadcastAuth: 'instances[].broadcastAuth', |
||||
currentStatus: { |
||||
connected: 'instances[].currentStatus.connected', |
||||
retryCount: 'instances[].currentStatus.retryCount', |
||||
status: 'instances[].currentStatus.status', |
||||
}, |
||||
instanceRecord: { |
||||
_id: 'instances[].instanceRecord._id', |
||||
pid: 'instances[].instanceRecord.pid', |
||||
_createdAt: dummyDate, |
||||
_updatedAt: dummyDate, |
||||
}, |
||||
}, |
||||
]; |
||||
|
||||
export const _default = () => <InstancesSection instances={instances} />; |
||||
@ -0,0 +1,33 @@ |
||||
import React from 'react'; |
||||
|
||||
import { dummyDate } from '../../../../.storybook/helpers'; |
||||
import { RocketChatSection } from './RocketChatSection'; |
||||
|
||||
export default { |
||||
title: 'admin/info/RocketChatSection', |
||||
component: RocketChatSection, |
||||
}; |
||||
|
||||
const info = { |
||||
marketplaceApiVersion: 'info.marketplaceApiVersion', |
||||
}; |
||||
|
||||
const statistics = { |
||||
version: 'statistics.version', |
||||
migration: { |
||||
version: 'statistics.migration.version', |
||||
lockedAt: dummyDate, |
||||
}, |
||||
installedAt: dummyDate, |
||||
process: { |
||||
uptime: 10 * 24 * 60 * 60, |
||||
pid: 'statistics.process.pid', |
||||
}, |
||||
uniqueId: 'statistics.uniqueId', |
||||
instanceCount: 1, |
||||
oplogEnabled: true, |
||||
}; |
||||
|
||||
export const _default = () => <RocketChatSection info={info} statistics={statistics} />; |
||||
|
||||
export const loading = () => <RocketChatSection info={{}} statistics={{}} isLoading />; |
||||
@ -0,0 +1,31 @@ |
||||
import React from 'react'; |
||||
|
||||
import { RuntimeEnvironmentSection } from './RuntimeEnvironmentSection'; |
||||
|
||||
export default { |
||||
title: 'admin/info/RuntimeEnvironmentSection', |
||||
component: RuntimeEnvironmentSection, |
||||
}; |
||||
|
||||
const statistics = { |
||||
os: { |
||||
type: 'statistics.os.type', |
||||
platform: 'statistics.os.platform', |
||||
arch: 'statistics.os.arch', |
||||
release: 'statistics.os.release', |
||||
uptime: 10 * 24 * 60 * 60, |
||||
loadavg: [1.1, 1.5, 1.15], |
||||
totalmem: 1024, |
||||
freemem: 1024, |
||||
cpus: [{}], |
||||
}, |
||||
process: { |
||||
nodeVersion: 'statistics.process.nodeVersion', |
||||
}, |
||||
mongoVersion: 'statistics.mongoVersion', |
||||
mongoStorageEngine: 'statistics.mongoStorageEngine', |
||||
}; |
||||
|
||||
export const _default = () => <RuntimeEnvironmentSection statistics={statistics} />; |
||||
|
||||
export const loading = () => <RuntimeEnvironmentSection statistics={{}} isLoading />; |
||||
@ -0,0 +1,10 @@ |
||||
import React from 'react'; |
||||
|
||||
import { SkeletonText } from './SkeletonText'; |
||||
|
||||
export default { |
||||
title: 'admin/info/SkeletonText', |
||||
component: SkeletonText, |
||||
}; |
||||
|
||||
export const _default = () => <SkeletonText />; |
||||
@ -0,0 +1,51 @@ |
||||
import React from 'react'; |
||||
|
||||
import { UsageSection } from './UsageSection'; |
||||
|
||||
export default { |
||||
title: 'admin/info/UsageSection', |
||||
component: UsageSection, |
||||
}; |
||||
|
||||
const statistics = { |
||||
totalUsers: 'statistics.totalUsers', |
||||
nonActiveUsers: 'nonActiveUsers', |
||||
activeUsers: 'statistics.activeUsers', |
||||
totalConnectedUsers: 'statistics.totalConnectedUsers', |
||||
onlineUsers: 'statistics.onlineUsers', |
||||
awayUsers: 'statistics.awayUsers', |
||||
offlineUsers: 'statistics.offlineUsers', |
||||
totalRooms: 'statistics.totalRooms', |
||||
totalChannels: 'statistics.totalChannels', |
||||
totalPrivateGroups: 'statistics.totalPrivateGroups', |
||||
totalDirect: 'statistics.totalDirect', |
||||
totalLivechat: 'statistics.totalLivechat', |
||||
totalDiscussions: 'statistics.totalDiscussions', |
||||
totalThreads: 'statistics.totalThreads', |
||||
totalMessages: 'statistics.totalMessages', |
||||
totalChannelMessages: 'statistics.totalChannelMessages', |
||||
totalPrivateGroupMessages: 'statistics.totalPrivateGroupMessages', |
||||
totalDirectMessages: 'statistics.totalDirectMessages', |
||||
totalLivechatMessages: 'statistics.totalLivechatMessages', |
||||
uploadsTotal: 'statistics.uploadsTotal', |
||||
uploadsTotalSize: 1024, |
||||
integrations: { |
||||
totalIntegrations: 'statistics.integrations.totalIntegrations', |
||||
totalIncoming: 'statistics.integrations.totalIncoming', |
||||
totalIncomingActive: 'statistics.integrations.totalIncomingActive', |
||||
totalOutgoing: 'statistics.integrations.totalOutgoing', |
||||
totalOutgoingActive: 'statistics.integrations.totalOutgoingActive', |
||||
totalWithScriptEnabled: 'statistics.integrations.totalWithScriptEnabled', |
||||
}, |
||||
}; |
||||
|
||||
const apps = { |
||||
totalInstalled: 'statistics.apps.totalInstalled', |
||||
totalActive: 'statistics.apps.totalActive', |
||||
}; |
||||
|
||||
export const _default = () => <UsageSection statistics={statistics} />; |
||||
|
||||
export const withApps = () => <UsageSection statistics={{ ...statistics, apps }} />; |
||||
|
||||
export const loading = () => <UsageSection statistics={{}} isLoading />; |
||||
@ -0,0 +1,3 @@ |
||||
import { createContext } from 'react'; |
||||
|
||||
export const MeteorContext = createContext({}); |
||||
@ -1,15 +1,25 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
import { Tracker } from 'meteor/tracker'; |
||||
import React from 'react'; |
||||
|
||||
import { MeteorContext } from '../contexts/MeteorContext'; |
||||
import { RouterProvider } from './RouterProvider'; |
||||
import { ConnectionStatusProvider } from './ConnectionStatusProvider'; |
||||
import { TranslationProvider } from './TranslationProvider'; |
||||
|
||||
const contextValue = { |
||||
Meteor, |
||||
Tracker, |
||||
}; |
||||
|
||||
export function MeteorProvider({ children }) { |
||||
return <ConnectionStatusProvider> |
||||
<RouterProvider> |
||||
<TranslationProvider> |
||||
{children} |
||||
</TranslationProvider> |
||||
</RouterProvider> |
||||
</ConnectionStatusProvider>; |
||||
return <MeteorContext.Provider value={contextValue}> |
||||
<ConnectionStatusProvider> |
||||
<RouterProvider> |
||||
<TranslationProvider> |
||||
{children} |
||||
</TranslationProvider> |
||||
</RouterProvider> |
||||
</ConnectionStatusProvider> |
||||
</MeteorContext.Provider>; |
||||
} |
||||
|
||||
@ -0,0 +1,5 @@ |
||||
import { useContext } from 'react'; |
||||
|
||||
import { MeteorContext } from '../components/contexts/MeteorContext'; |
||||
|
||||
export const useMeteor = () => useContext(MeteorContext).Meteor; |
||||
@ -0,0 +1,5 @@ |
||||
import { useContext } from 'react'; |
||||
|
||||
import { MeteorContext } from '../components/contexts/MeteorContext'; |
||||
|
||||
export const useTracker = () => useContext(MeteorContext).Tracker; |
||||
@ -0,0 +1,5 @@ |
||||
import { useContext } from 'react'; |
||||
|
||||
import { TranslationContext } from '../components/contexts/TranslationContext'; |
||||
|
||||
export const useTranslation = () => useContext(TranslationContext); |
||||
Loading…
Reference in new issue