chore: Move `InfoPanel` component to `ui-client` package (#37701)

chore/server-declarationMap^2
gabriellsh 1 month ago committed by GitHub
parent 75bd3e4625
commit e96bb84e4d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 37
      apps/meteor/client/components/InfoPanel/RetentionPolicyCallout.spec.tsx
  2. 32
      apps/meteor/client/components/InfoPanel/RetentionPolicyCallout.stories.tsx
  3. 75
      apps/meteor/client/components/InfoPanel/__snapshots__/RetentionPolicyCallout.spec.tsx.snap
  4. 19
      apps/meteor/client/components/UserInfo/UserInfo.tsx
  5. 5
      apps/meteor/client/views/admin/deviceManagement/DeviceManagementInfo/DeviceManagementInfo.tsx
  6. 2
      apps/meteor/client/views/omnichannel/additionalForms/MaxChatsPerAgentDisplay.tsx
  7. 3
      apps/meteor/client/views/omnichannel/agents/AgentInfo.tsx
  8. 2
      apps/meteor/client/views/omnichannel/components/CustomField.tsx
  9. 3
      apps/meteor/client/views/omnichannel/directory/calls/contextualBar/InfoField.tsx
  10. 5
      apps/meteor/client/views/omnichannel/directory/calls/contextualBar/VoipInfo.tsx
  11. 3
      apps/meteor/client/views/omnichannel/directory/chats/ChatInfo/ChatInfo.tsx
  12. 2
      apps/meteor/client/views/room/contextualBar/Info/RoomInfo/ABAC/RoomInfoABACSection.tsx
  13. 10
      apps/meteor/client/views/room/contextualBar/Info/RoomInfo/RoomInfo.tsx
  14. 3
      apps/meteor/client/views/room/contextualBar/Info/RoomInfo/RoomInfoActions.tsx
  15. 12
      apps/meteor/client/views/teams/contextualBar/info/TeamsInfo.tsx
  16. 0
      packages/ui-client/src/components/InfoPanel/InfoPanel.spec.tsx
  17. 8
      packages/ui-client/src/components/InfoPanel/InfoPanel.stories.tsx
  18. 0
      packages/ui-client/src/components/InfoPanel/InfoPanel.tsx
  19. 0
      packages/ui-client/src/components/InfoPanel/InfoPanelAction.tsx
  20. 0
      packages/ui-client/src/components/InfoPanel/InfoPanelActionGroup.tsx
  21. 0
      packages/ui-client/src/components/InfoPanel/InfoPanelAvatar.tsx
  22. 0
      packages/ui-client/src/components/InfoPanel/InfoPanelField.tsx
  23. 0
      packages/ui-client/src/components/InfoPanel/InfoPanelLabel.tsx
  24. 0
      packages/ui-client/src/components/InfoPanel/InfoPanelSection.tsx
  25. 0
      packages/ui-client/src/components/InfoPanel/InfoPanelText.tsx
  26. 0
      packages/ui-client/src/components/InfoPanel/InfoPanelTitle.tsx
  27. 3
      packages/ui-client/src/components/InfoPanel/__snapshots__/InfoPanel.spec.tsx.snap
  28. 0
      packages/ui-client/src/components/InfoPanel/index.ts
  29. 1
      packages/ui-client/src/components/index.ts

@ -1,29 +1,24 @@
import { render, screen } from '@testing-library/react';
import { composeStories } from '@storybook/react';
import { render } from '@testing-library/react';
import { axe } from 'jest-axe';
import RetentionPolicyCallout from './RetentionPolicyCallout';
import { createRenteionPolicySettingsMock as createMock } from '../../../tests/mocks/client/mockRetentionPolicySettings';
import { createFakeRoom } from '../../../tests/mocks/data';
import * as stories from './RetentionPolicyCallout.stories';
jest.useFakeTimers();
const testCases = Object.values(composeStories(stories)).map((Story) => [Story.storyName || 'Story', Story]);
beforeEach(() => {
test.each(testCases)(`renders %s without crashing`, async (_storyname, Story) => {
jest.useFakeTimers();
jest.setSystemTime(new Date(2024, 5, 1, 0, 0, 0));
const { baseElement } = render(<Story />);
expect(baseElement).toMatchSnapshot();
});
describe('RetentionPolicyCallout', () => {
it('Should render callout if settings are valid', () => {
const fakeRoom = createFakeRoom({ t: 'c' });
render(<RetentionPolicyCallout room={fakeRoom} />, {
wrapper: createMock({ appliesToChannels: true, TTLChannels: 60000 }),
});
expect(screen.getByRole('alert')).toHaveTextContent('a minute June 1, 2024 at 12:30 AM');
});
test.each(testCases)('%s should have no a11y violations', async (_storyname, Story) => {
// We have to use real timers here because `jest-axe` is breaking otherwise
jest.useRealTimers();
const { container } = render(<Story />);
it('Should not render callout if settings are invalid', () => {
const fakeRoom = createFakeRoom({ t: 'c' });
render(<RetentionPolicyCallout room={fakeRoom} />, {
wrapper: createMock({ appliesToChannels: true, TTLChannels: 60000, advancedPrecisionCron: '* * * 12 *', advancedPrecision: true }),
});
expect(screen.queryByRole('alert')).not.toBeInTheDocument();
});
const results = await axe(container);
expect(results).toHaveNoViolations();
});

@ -0,0 +1,32 @@
import type { Meta, StoryFn } from '@storybook/react';
import RetentionPolicyCallout from './RetentionPolicyCallout';
import { createRenteionPolicySettingsMock as createMock } from '../../../tests/mocks/client/mockRetentionPolicySettings';
import { createFakeRoom } from '../../../tests/mocks/data';
export default {
component: RetentionPolicyCallout,
} satisfies Meta<typeof RetentionPolicyCallout>;
const fakeRoom = createFakeRoom();
const DefaultWrapper = createMock({ appliesToChannels: true, TTLChannels: 60000 });
export const Default: StoryFn<typeof RetentionPolicyCallout> = () => (
<DefaultWrapper>
<RetentionPolicyCallout room={fakeRoom} />
</DefaultWrapper>
);
const InvalidSettingsWrapper = createMock({
appliesToChannels: true,
TTLChannels: 60000,
advancedPrecisionCron: '* * * 12 * *',
advancedPrecision: true,
});
export const InvalidSettings: StoryFn<typeof RetentionPolicyCallout> = () => (
<InvalidSettingsWrapper>
<RetentionPolicyCallout room={fakeRoom} />
</InvalidSettingsWrapper>
);

@ -0,0 +1,75 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`renders Default without crashing 1`] = `
<body>
<div>
<section
aria-live="polite"
arial-label="Retention_policy_warning_callout"
class="rcx-box rcx-box--full rcx-callout rcx-callout--warning"
role="alert"
>
<i
aria-hidden="true"
class="rcx-box rcx-box--full rcx-icon--name-warning rcx-icon rcx-callout__icon rcx-css-4pvxx3"
>
</i>
<div
class="rcx-box rcx-box--full rcx-callout__wrapper"
>
<div
class="rcx-box rcx-box--full rcx-callout__wrapper-content"
>
<div
class="rcx-box rcx-box--full rcx-callout__content"
>
<div>
<p>
a minute June 1, 2024 at 12:30 AM
</p>
</div>
</div>
</div>
</div>
</section>
</div>
</body>
`;
exports[`renders InvalidSettings without crashing 1`] = `
<body>
<div>
<section
aria-live="polite"
arial-label="Retention_policy_warning_callout"
class="rcx-box rcx-box--full rcx-callout rcx-callout--warning"
role="alert"
>
<i
aria-hidden="true"
class="rcx-box rcx-box--full rcx-icon--name-warning rcx-icon rcx-callout__icon rcx-css-4pvxx3"
>
</i>
<div
class="rcx-box rcx-box--full rcx-callout__wrapper"
>
<div
class="rcx-box rcx-box--full rcx-callout__wrapper-content"
>
<div
class="rcx-box rcx-box--full rcx-callout__content"
>
<div>
<p>
a minute June 12, 2024 at 12:00 AM
</p>
</div>
</div>
</div>
</div>
</section>
</div>
</body>
`;

@ -1,14 +1,8 @@
import type { IUser, Serialized } from '@rocket.chat/core-typings';
import { Box, Margins, Tag } from '@rocket.chat/fuselage';
import { useUserDisplayName, ContextualbarScrollableContent } from '@rocket.chat/ui-client';
import type { TranslationKey } from '@rocket.chat/ui-contexts';
import type { ReactElement, ReactNode } from 'react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { useTimeAgo } from '../../hooks/useTimeAgo';
import { useUserCustomFields } from '../../hooks/useUserCustomFields';
import {
useUserDisplayName,
ContextualbarScrollableContent,
InfoPanel,
InfoPanelActionGroup,
InfoPanelAvatar,
@ -17,7 +11,14 @@ import {
InfoPanelSection,
InfoPanelText,
InfoPanelTitle,
} from '../InfoPanel';
} from '@rocket.chat/ui-client';
import type { TranslationKey } from '@rocket.chat/ui-contexts';
import type { ReactElement, ReactNode } from 'react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { useTimeAgo } from '../../hooks/useTimeAgo';
import { useUserCustomFields } from '../../hooks/useUserCustomFields';
import MarkdownText from '../MarkdownText';
import UTCClock from '../UTCClock';
import { UserCardRoles } from '../UserCard';

@ -7,13 +7,16 @@ import {
ContextualbarScrollableContent,
ContextualbarFooter,
ContextualbarTitle,
InfoPanel,
InfoPanelField,
InfoPanelLabel,
InfoPanelText,
} from '@rocket.chat/ui-client';
import { useRoute, useUserPresence } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { InfoPanel, InfoPanelField, InfoPanelLabel, InfoPanelText } from '../../../../components/InfoPanel';
import { useDeviceLogout } from '../../../../hooks/useDeviceLogout';
import { useFormatDateAndTime } from '../../../../hooks/useFormatDateAndTime';

@ -1,6 +1,6 @@
import { InfoPanelLabel, InfoPanelText } from '@rocket.chat/ui-client';
import { useTranslation } from 'react-i18next';
import { InfoPanelLabel, InfoPanelText } from '../../../components/InfoPanel';
import { useHasLicenseModule } from '../../../hooks/useHasLicenseModule';
const MaxChatsPerAgentDisplay = ({ maxNumberSimultaneousChat = 0 }) => {

@ -5,13 +5,14 @@ import {
ContextualbarHeader,
ContextualbarScrollableContent,
ContextualbarSkeletonBody,
InfoPanelLabel,
InfoPanelText,
} from '@rocket.chat/ui-client';
import { useEndpoint, useRouter } from '@rocket.chat/ui-contexts';
import { useQuery } from '@tanstack/react-query';
import type { HTMLAttributes } from 'react';
import { useTranslation } from 'react-i18next';
import { InfoPanelLabel, InfoPanelText } from '../../../components/InfoPanel';
import { UserInfoAvatar, UserInfoUsername } from '../../../components/UserInfo';
import { UserStatus } from '../../../components/UserStatus';
import { MaxChatsPerAgentDisplay } from '../additionalForms';

@ -1,9 +1,9 @@
import { Box } from '@rocket.chat/fuselage';
import { InfoPanelField, InfoPanelLabel, InfoPanelText } from '@rocket.chat/ui-client';
import { useEndpoint } from '@rocket.chat/ui-contexts';
import { useQuery } from '@tanstack/react-query';
import { useTranslation } from 'react-i18next';
import { InfoPanelField, InfoPanelLabel, InfoPanelText } from '../../../components/InfoPanel';
import { FormSkeleton } from '../directory/components/FormSkeleton';
type CustomFieldProps = {

@ -1,7 +1,6 @@
import { InfoPanelField, InfoPanelLabel, InfoPanelText } from '@rocket.chat/ui-client';
import type { ReactElement } from 'react';
import { InfoPanelField, InfoPanelLabel, InfoPanelText } from '../../../../../components/InfoPanel';
type InfoFieldPropsType = {
label: string;
info: string;

@ -9,6 +9,10 @@ import {
ContextualbarScrollableContent,
ContextualbarFooter,
ContextualbarDialog,
InfoPanel,
InfoPanelField,
InfoPanelLabel,
InfoPanelText,
} from '@rocket.chat/ui-client';
import moment from 'moment';
import type { ReactElement } from 'react';
@ -17,7 +21,6 @@ import { useTranslation } from 'react-i18next';
import { InfoField } from './InfoField';
import { VoipInfoCallButton } from './VoipInfoCallButton';
import { InfoPanel, InfoPanelField, InfoPanelLabel, InfoPanelText } from '../../../../../components/InfoPanel';
import { UserStatus } from '../../../../../components/UserStatus';
import { useIsCallReady } from '../../../../../contexts/CallContext';
import { parseOutboundPhoneNumber } from '../../../../../lib/voip/parseOutboundPhoneNumber';

@ -1,7 +1,7 @@
import type { IOmnichannelRoom, IVisitor } from '@rocket.chat/core-typings';
import { Box, Margins, Tag, Button, ButtonGroup } from '@rocket.chat/fuselage';
import { useEffectEvent } from '@rocket.chat/fuselage-hooks';
import { ContextualbarScrollableContent, ContextualbarFooter } from '@rocket.chat/ui-client';
import { ContextualbarScrollableContent, ContextualbarFooter, InfoPanelField, InfoPanelLabel, InfoPanelText } from '@rocket.chat/ui-client';
import type { IRouterPaths } from '@rocket.chat/ui-contexts';
import { useToastMessageDispatch, useRoute, useUserSubscription, useTranslation, usePermission, useUserId } from '@rocket.chat/ui-contexts';
import moment from 'moment';
@ -9,7 +9,6 @@ import { useMemo } from 'react';
import DepartmentField from './DepartmentField';
import VisitorClientInfo from './VisitorClientInfo';
import { InfoPanelField, InfoPanelLabel, InfoPanelText } from '../../../../../components/InfoPanel';
import MarkdownText from '../../../../../components/MarkdownText';
import { useFormatDateAndTime } from '../../../../../hooks/useFormatDateAndTime';
import { useFormatDuration } from '../../../../../hooks/useFormatDuration';

@ -1,9 +1,9 @@
import type { IRoom } from '@rocket.chat/core-typings';
import { Box, Divider, Tag } from '@rocket.chat/fuselage';
import { InfoPanelField, InfoPanelLabel } from '@rocket.chat/ui-client';
import { useSetting } from '@rocket.chat/ui-contexts';
import { useTranslation } from 'react-i18next';
import { InfoPanelField, InfoPanelLabel } from '../../../../../../components/InfoPanel';
import { RoomIcon } from '../../../../../../components/RoomIcon';
// TODO: Remove type union when ABAC is implemented

@ -10,11 +10,6 @@ import {
ContextualbarClose,
ContextualbarTitle,
ContextualbarDialog,
} from '@rocket.chat/ui-client';
import { useTranslation } from 'react-i18next';
import RoomInfoActions from './RoomInfoActions';
import {
InfoPanel,
InfoPanelActionGroup,
InfoPanelAvatar,
@ -23,7 +18,10 @@ import {
InfoPanelSection,
InfoPanelText,
InfoPanelTitle,
} from '../../../../../components/InfoPanel';
} from '@rocket.chat/ui-client';
import { useTranslation } from 'react-i18next';
import RoomInfoActions from './RoomInfoActions';
import RetentionPolicyCallout from '../../../../../components/InfoPanel/RetentionPolicyCallout';
import MarkdownText from '../../../../../components/MarkdownText';
import { useRetentionPolicy } from '../../../hooks/useRetentionPolicy';

@ -1,6 +1,5 @@
import type { Keys as IconKeys } from '@rocket.chat/icons';
import { InfoPanelAction } from '../../../../../components/InfoPanel';
import { InfoPanelAction } from '@rocket.chat/ui-client';
type Action = {
id: string;

@ -9,12 +9,6 @@ import {
ContextualbarClose,
ContextualbarScrollableContent,
ContextualbarDialog,
} from '@rocket.chat/ui-client';
import type { ReactElement } from 'react';
import { useTranslation } from 'react-i18next';
import { useTeamActions } from './useTeamActions';
import {
InfoPanel,
InfoPanelAction,
InfoPanelActionGroup,
@ -24,7 +18,11 @@ import {
InfoPanelSection,
InfoPanelText,
InfoPanelTitle,
} from '../../../../components/InfoPanel';
} from '@rocket.chat/ui-client';
import type { ReactElement } from 'react';
import { useTranslation } from 'react-i18next';
import { useTeamActions } from './useTeamActions';
import RetentionPolicyCallout from '../../../../components/InfoPanel/RetentionPolicyCallout';
import MarkdownText from '../../../../components/MarkdownText';
import { useSplitRoomActions } from '../../../room/contextualBar/Info/hooks/useSplitRoomActions';

@ -12,8 +12,6 @@ import {
InfoPanelText,
InfoPanelTitle,
} from '.';
import RetentionPolicyCallout from './RetentionPolicyCallout';
import { createFakeRoom } from '../../../tests/mocks/data';
export default {
component: InfoPanel,
@ -26,12 +24,9 @@ export default {
InfoPanelSection: InfoPanelSection as ComponentType<any>,
InfoPanelText: InfoPanelText as ComponentType<any>,
InfoPanelTitle: InfoPanelTitle as ComponentType<any>,
RetentionPolicyCallout: RetentionPolicyCallout as ComponentType<any>,
},
} satisfies Meta<typeof InfoPanel>;
const fakeRoom = createFakeRoom();
export const Default: StoryFn<typeof InfoPanel> = () => (
<InfoPanel>
<InfoPanelAvatar />
@ -61,8 +56,5 @@ export const Default: StoryFn<typeof InfoPanel> = () => (
</InfoPanelText>
</InfoPanelField>
</InfoPanelSection>
<InfoPanelSection>
<RetentionPolicyCallout room={fakeRoom} />
</InfoPanelSection>
</InfoPanel>
);

@ -82,9 +82,6 @@ exports[`renders Default without crashing 1`] = `
</div>
</div>
</div>
<div
class="rcx-box rcx-box--full rcx-css-6jv9ad"
/>
</div>
</div>
</body>

@ -20,3 +20,4 @@ export * from './Modal';
export * from './Wizard';
export * from './CustomScrollbars';
export * from './Page';
export * from './InfoPanel';

Loading…
Cancel
Save