Chore: TS migration SortList (#25167)
parent
e7733ac4d6
commit
08af753264
@ -1,9 +0,0 @@ |
||||
import { useRef, useEffect } from 'react'; |
||||
|
||||
export const useBlockRendered = () => { |
||||
const ref = useRef(); |
||||
useEffect(() => { |
||||
ref.current.dispatchEvent(new Event('rendered')); |
||||
}, []); |
||||
return { className: 'js-block-wrapper', ref }; |
||||
}; |
||||
@ -0,0 +1,13 @@ |
||||
import { useRef, useEffect, RefObject } from 'react'; |
||||
|
||||
// @deprecated
|
||||
export const useBlockRendered = <T extends HTMLElement>(): { |
||||
className: string; |
||||
ref: RefObject<T>; |
||||
} => { |
||||
const ref = useRef<T>(null); |
||||
useEffect(() => { |
||||
ref.current?.dispatchEvent(new Event('rendered')); |
||||
}, []); |
||||
return { className: 'js-block-wrapper', ref }; |
||||
}; |
||||
@ -1,38 +0,0 @@ |
||||
import { Box, Tag } from '@rocket.chat/fuselage'; |
||||
import { useSafely } from '@rocket.chat/fuselage-hooks'; |
||||
import React, { useEffect, useState } from 'react'; |
||||
|
||||
import { useMethod } from '../contexts/ServerContext'; |
||||
|
||||
function PlanTag() { |
||||
const [plans, setPlans] = useSafely(useState([])); |
||||
|
||||
const getTags = useMethod('license:getTags'); |
||||
|
||||
useEffect(() => { |
||||
const developmentTag = process.env.NODE_ENV === 'development' ? { name: 'development', color: '#095ad2' } : null; |
||||
|
||||
const fetchTags = async () => { |
||||
const tags = await getTags(); |
||||
setPlans([developmentTag, ...tags].filter(Boolean).map((plan) => ({ plan: plan.name, background: plan.color }))); |
||||
}; |
||||
|
||||
fetchTags(); |
||||
}, [getTags, setPlans]); |
||||
|
||||
return plans.map(({ plan, background }) => ( |
||||
<Box marginInline='x4' display='inline-block' verticalAlign='middle' key={plan}> |
||||
<Tag |
||||
style={{ |
||||
color: '#fff', |
||||
backgroundColor: background, |
||||
textTransform: 'capitalize', |
||||
}} |
||||
> |
||||
{plan} |
||||
</Tag> |
||||
</Box> |
||||
)); |
||||
} |
||||
|
||||
export default PlanTag; |
||||
@ -0,0 +1,50 @@ |
||||
import { Box, Tag } from '@rocket.chat/fuselage'; |
||||
import { useSafely } from '@rocket.chat/fuselage-hooks'; |
||||
import React, { ReactElement, useEffect, useState } from 'react'; |
||||
|
||||
import { ILicenseTag } from '../../ee/app/license/definitions/ILicenseTag'; |
||||
import { useMethod } from '../contexts/ServerContext'; |
||||
|
||||
function PlanTag(): ReactElement { |
||||
const [plans, setPlans] = useSafely( |
||||
useState< |
||||
{ |
||||
name: string; |
||||
color: string; |
||||
}[] |
||||
>([]), |
||||
); |
||||
|
||||
const getTags = useMethod('license:getTags'); |
||||
|
||||
useEffect(() => { |
||||
const developmentTag = process.env.NODE_ENV === 'development' ? { name: 'development', color: '#095ad2' } : null; |
||||
|
||||
const fetchTags = async (): Promise<void> => { |
||||
const tags = await getTags(); |
||||
setPlans([developmentTag, ...tags].filter(Boolean) as ILicenseTag[]); |
||||
}; |
||||
|
||||
fetchTags(); |
||||
}, [getTags, setPlans]); |
||||
|
||||
return ( |
||||
<> |
||||
{plans.map(({ name, color }) => ( |
||||
<Box marginInline='x4' display='inline-block' verticalAlign='middle' key={name}> |
||||
<Tag |
||||
style={{ |
||||
color: '#fff', |
||||
backgroundColor: color, |
||||
textTransform: 'capitalize', |
||||
}} |
||||
> |
||||
{name} |
||||
</Tag> |
||||
</Box> |
||||
))} |
||||
</> |
||||
); |
||||
} |
||||
|
||||
export default PlanTag; |
||||
@ -1,5 +0,0 @@ |
||||
import React from 'react'; |
||||
|
||||
const RawText = ({ children }) => <span dangerouslySetInnerHTML={{ __html: children }} />; |
||||
|
||||
export default RawText; |
||||
@ -0,0 +1,6 @@ |
||||
import React, { ReactElement } from 'react'; |
||||
|
||||
// @deprecated
|
||||
const RawText = ({ children }: { children: string }): ReactElement => <span dangerouslySetInnerHTML={{ __html: children }} />; |
||||
|
||||
export default RawText; |
||||
@ -1,7 +1,7 @@ |
||||
import { Box, Skeleton } from '@rocket.chat/fuselage'; |
||||
import React from 'react'; |
||||
import React, { ComponentProps, ReactElement } from 'react'; |
||||
|
||||
export const FormSkeleton = (props) => ( |
||||
export const FormSkeleton = (props: ComponentProps<typeof Box>): ReactElement => ( |
||||
<Box w='full' pb='x24' {...props}> |
||||
<Skeleton mbe='x8' /> |
||||
<Skeleton mbe='x4' /> |
||||
@ -1,11 +1,11 @@ |
||||
import { Option } from '@rocket.chat/fuselage'; |
||||
import React from 'react'; |
||||
import React, { ReactElement } from 'react'; |
||||
|
||||
import GroupingList from './GroupingList'; |
||||
import SortModeList from './SortModeList'; |
||||
import ViewModeList from './ViewModeList'; |
||||
|
||||
function SortList() { |
||||
function SortList(): ReactElement { |
||||
return ( |
||||
<> |
||||
<ViewModeList /> |
||||
@ -1,7 +1,8 @@ |
||||
import { Box } from '@rocket.chat/fuselage'; |
||||
import React from 'react'; |
||||
import React, { ReactElement } from 'react'; |
||||
|
||||
function Subtitle(props) { |
||||
// @deprecated
|
||||
function Subtitle(props: { children: ReactElement }): ReactElement { |
||||
return <Box color='default' fontFamily='sans' fontScale='h4' marginBlockEnd='x8' withRichContent {...props} />; |
||||
} |
||||
|
||||
@ -1,14 +1,14 @@ |
||||
import React from 'react'; |
||||
import React, { ReactElement } from 'react'; |
||||
|
||||
import { usePermission } from '../../contexts/AuthorizationContext'; |
||||
import NotAuthorizedPage from '../notAuthorized/NotAuthorizedPage'; |
||||
import ChannelsTable from './ChannelsTable'; |
||||
|
||||
function ChannelsTab(props) { |
||||
function ChannelsTab(): ReactElement { |
||||
const canViewPublicRooms = usePermission('view-c-room'); |
||||
|
||||
if (canViewPublicRooms) { |
||||
return <ChannelsTable {...props} />; |
||||
return <ChannelsTable />; |
||||
} |
||||
|
||||
return <NotAuthorizedPage />; |
||||
@ -1,14 +1,14 @@ |
||||
import React from 'react'; |
||||
import React, { ReactElement } from 'react'; |
||||
|
||||
import { usePermission } from '../../contexts/AuthorizationContext'; |
||||
import NotAuthorizedPage from '../notAuthorized/NotAuthorizedPage'; |
||||
import TeamsTable from './TeamsTable'; |
||||
|
||||
function TeamsTab(props) { |
||||
function TeamsTab(): ReactElement { |
||||
const canViewPublicRooms = usePermission('view-c-room'); |
||||
|
||||
if (canViewPublicRooms) { |
||||
return <TeamsTable {...props} />; |
||||
return <TeamsTable />; |
||||
} |
||||
|
||||
return <NotAuthorizedPage />; |
||||
@ -1,10 +1,10 @@ |
||||
import React from 'react'; |
||||
import React, { ReactElement } from 'react'; |
||||
|
||||
import { usePermission } from '../../contexts/AuthorizationContext'; |
||||
import NotAuthorizedPage from '../notAuthorized/NotAuthorizedPage'; |
||||
import UserTable from './UserTable'; |
||||
|
||||
function UserTab(props) { |
||||
function UserTab(props: { workspace?: 'external' | 'local' }): ReactElement { |
||||
const canViewOutsideRoom = usePermission('view-outside-room'); |
||||
const canViewDM = usePermission('view-d-room'); |
||||
|
||||
Loading…
Reference in new issue