Skip to content

Commit

Permalink
Merge branch 'develop' into fix/omni-queue-race-condition
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Dec 6, 2024
2 parents 7350070 + 18cea50 commit 5be0a84
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 72 deletions.
69 changes: 47 additions & 22 deletions apps/meteor/client/components/UserCard/UserCard.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,34 @@ import React from 'react';

import { UserCard, UserCardRole, UserCardAction } from '.';

const user = {
name: 'guilherme.gazzo',
customStatus: '🛴 currently working on User Card',
roles: (
<>
<UserCardRole>Admin</UserCardRole>
<UserCardRole>Rocket.Chat</UserCardRole>
<UserCardRole>Team</UserCardRole>
</>
),
bio: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla tempus, eros convallis vulputate cursus, nisi neque eleifend libero, eget lacinia justo purus nec est. In at sodales ipsum. Sed lacinia quis purus eget pulvinar. Aenean eu pretium nunc, at aliquam magna. Praesent dignissim, tortor sed volutpat mattis, mauris diam pulvinar leo, porta commodo risus est non purus. Mauris in justo vel lorem ullamcorper hendrerit. Nam est metus, viverra a pellentesque vitae, ornare eget odio. Morbi tempor feugiat mattis. Morbi non felis tempor, aliquam justo sed, sagittis nibh. Mauris consequat ex metus. Praesent sodales sit amet nibh a vulputate. Integer commodo, mi vel bibendum sollicitudin, urna lectus accumsan ante, eget faucibus augue ex id neque. Aenean consectetur, orci a pellentesque mattis, tortor tellus fringilla elit, non ullamcorper risus nunc feugiat risus. Fusce sit amet nisi dapibus turpis commodo placerat. In tortor ante, vehicula sit amet augue et, imperdiet porta sem.',
localTime: 'Local Time: 7:44 AM',
};

export default {
title: 'Components/UserCard',
component: UserCard,
parameters: {
layout: 'centered',
},
args: {
name: 'guilherme.gazzo',
customStatus: '🛴 currently working on User Card',
roles: (
<>
<UserCardRole>Admin</UserCardRole>
<UserCardRole>Rocket.Chat</UserCardRole>
<UserCardRole>Team</UserCardRole>
</>
),
bio: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla tempus, eros convallis vulputate cursus, nisi neque eleifend libero, eget lacinia justo purus nec est. In at sodales ipsum. Sed lacinia quis purus eget pulvinar. Aenean eu pretium nunc, at aliquam magna. Praesent dignissim, tortor sed volutpat mattis, mauris diam pulvinar leo, porta commodo risus est non purus. Mauris in justo vel lorem ullamcorper hendrerit. Nam est metus, viverra a pellentesque vitae, ornare eget odio. Morbi tempor feugiat mattis. Morbi non felis tempor, aliquam justo sed, sagittis nibh. Mauris consequat ex metus. Praesent sodales sit amet nibh a vulputate. Integer commodo, mi vel bibendum sollicitudin, urna lectus accumsan ante, eget faucibus augue ex id neque. Aenean consectetur, orci a pellentesque mattis, tortor tellus fringilla elit, non ullamcorper risus nunc feugiat risus. Fusce sit amet nisi dapibus turpis commodo placerat. In tortor ante, vehicula sit amet augue et, imperdiet porta sem.',
user,
actions: (
<>
<UserCardAction icon='message' />
<UserCardAction icon='phone' />
</>
),
localTime: 'Local Time: 7:44 AM',
},
} satisfies Meta<typeof UserCard>;

Expand All @@ -36,18 +40,27 @@ export const Example = Template.bind({});

export const Nickname = Template.bind({});
Nickname.args = {
nickname: 'nicknamenickname',
user: {
...user,
nickname: 'nicknamenickname',
},
} as any;

export const LargeName = Template.bind({});
LargeName.args = {
customStatus: '🛴 currently working on User Card on User Card on User Card on User Card on User Card ',
name: 'guilherme.gazzo.guilherme.gazzo.guilherme.gazzo.guilherme.gazzo.guilherme.gazzo.guilherme.gazzo.guilherme.gazzo.guilherme.gazzo.',
user: {
...user,
customStatus: '🛴 currently working on User Card on User Card on User Card on User Card on User Card ',
name: 'guilherme.gazzo.guilherme.gazzo.guilherme.gazzo.guilherme.gazzo.guilherme.gazzo.guilherme.gazzo.guilherme.gazzo.guilherme.gazzo.',
},
} as any;

export const NoRoles = Template.bind({});
NoRoles.args = {
roles: undefined,
user: {
...user,
roles: undefined,
},
} as any;

export const NoActions = Template.bind({});
Expand All @@ -57,25 +70,37 @@ NoActions.args = {

export const NoLocalTime = Template.bind({});
NoLocalTime.args = {
localTime: undefined,
user: {
...user,
localTime: undefined,
},
} as any;

export const NoBio = Template.bind({});
NoBio.args = {
bio: undefined,
user: {
...user,
bio: undefined,
},
} as any;

export const NoBioAndNoLocalTime = Template.bind({});
NoBioAndNoLocalTime.args = {
bio: undefined,
localTime: undefined,
user: {
...user,
bio: undefined,
localTime: undefined,
},
} as any;

export const NoBioNoLocalTimeNoRoles = Template.bind({});
NoBioNoLocalTimeNoRoles.args = {
bio: undefined,
localTime: undefined,
roles: undefined,
user: {
...user,
bio: undefined,
localTime: undefined,
roles: undefined,
},
} as any;

export const Loading = () => <UserCard />;
34 changes: 14 additions & 20 deletions apps/meteor/client/components/UserCard/UserCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,27 @@ const clampStyle = css`
`;

type UserCardProps = {
onOpenUserInfo?: () => void;
name?: string;
username?: string;
etag?: string;
customStatus?: ReactNode;
roles?: ReactNode;
bio?: ReactNode;
status?: ReactNode;
user?: {
nickname?: string;
name?: string;
username?: string;
etag?: string;
customStatus?: ReactNode;
roles?: ReactNode;
bio?: ReactNode;
status?: ReactNode;
localTime?: ReactNode;
};
actions?: ReactNode;
localTime?: ReactNode;
onOpenUserInfo?: () => void;
onClose?: () => void;
nickname?: string;
} & ComponentProps<typeof UserCardDialog>;

const UserCard = ({
onOpenUserInfo,
name,
username,
etag,
customStatus,
roles,
bio,
status = <Status.Offline />,
user: { name, username, etag, customStatus, roles, bio, status = <Status.Offline />, localTime, nickname } = {},
actions,
localTime,
onOpenUserInfo,
onClose,
nickname,
...props
}: UserCardProps) => {
const { t } = useTranslation();
Expand Down
44 changes: 24 additions & 20 deletions apps/meteor/client/views/oauth/components/CurrentUserDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { IUser } from '@rocket.chat/core-typings';
import { css } from '@rocket.chat/css-in-js';
import { UserStatus } from '@rocket.chat/ui-client';
import { useRolesDescription, useSetting } from '@rocket.chat/ui-contexts';
import React from 'react';
import React, { useMemo } from 'react';
import { useTranslation } from 'react-i18next';

import LocalTime from '../../../components/LocalTime';
Expand All @@ -26,29 +26,33 @@ const CurrentUserDisplay = ({ user }: CurrentUserDisplayProps) => {
const getRoles = useRolesDescription();

const { t } = useTranslation();
const { username, avatarETag, name, statusText, nickname, roles, utcOffset, bio } = user;

const data = useMemo(
() => ({
username,
etag: avatarETag,
name: showRealNames ? name : username,
nickname,
status: <UserStatus.Online />,
customStatus: statusText ?? <></>,
roles: roles && getRoles(roles).map((role, index) => <UserCardRole key={index}>{role}</UserCardRole>),
localTime: utcOffset && Number.isInteger(utcOffset) && <LocalTime utcOffset={utcOffset} />,
bio: bio ? (
<UserCardInfo withTruncatedText={false} className={clampStyle} height='x60'>
{typeof bio === 'string' ? <MarkdownText variant='inline' content={bio} /> : bio}
</UserCardInfo>
) : (
<></>
),
}),
[avatarETag, bio, getRoles, name, nickname, roles, showRealNames, statusText, username, utcOffset],
);

return (
<>
<p>{t('core.You_are_logged_in_as')}</p>
<UserCard
username={user.username}
etag={user.avatarETag}
name={showRealNames ? user.name : user.username}
nickname={user.nickname}
status={<UserStatus.Online />}
customStatus={user.statusText ?? <></>}
roles={user.roles && getRoles(user.roles).map((role, index) => <UserCardRole key={index}>{role}</UserCardRole>)}
localTime={user.utcOffset && Number.isInteger(user.utcOffset) && <LocalTime utcOffset={user.utcOffset} />}
bio={
user.bio ? (
<UserCardInfo withTruncatedText={false} className={clampStyle} height='x60'>
{typeof user.bio === 'string' ? <MarkdownText variant='inline' content={user.bio} /> : user.bio}
</UserCardInfo>
) : (
<></>
)
}
/>
<UserCard user={data} />
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const UserCardWithData = ({ username, rid, onOpenUserInfo, onClose }: UserCardWi
return <UserCardSkeleton />;
}

return <UserCard {...user} onClose={onClose} onOpenUserInfo={handleOpenUserInfo} actions={actions} />;
return <UserCard user={user} onClose={onClose} onOpenUserInfo={handleOpenUserInfo} actions={actions} />;
};

export default UserCardWithData;
11 changes: 3 additions & 8 deletions packages/release-action/src/getMetadata.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { readFile } from 'fs/promises';
import path from 'path';

import { getExecOutput } from '@actions/exec';

import { readPackageJson } from './utils';

export async function getMongoVersion(cwd: string) {
Expand All @@ -27,14 +25,11 @@ export async function getNodeNpmVersions(cwd: string): Promise<{ node: string; y
return packageJson.engines;
}

export async function getAppsEngineVersion() {
export async function getAppsEngineVersion(cwd: string) {
try {
const result = await getExecOutput('yarn why @rocket.chat/apps-engine --json');
const result = await readPackageJson(path.join(cwd, 'packages/apps-engine'));

const match = result.stdout.match(/"@rocket\.chat\/meteor@workspace:apps\/meteor".*"@rocket\.chat\/apps\-engine@[^#]+#npm:([^"]+)"/);
if (match) {
return match[1];
}
return result.version ?? 'Not Available';
} catch (e) {
console.error(e);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/release-action/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Bump ${pkgName} version.

export async function getEngineVersionsMd(cwd: string) {
const { node } = await getNodeNpmVersions(cwd);
const appsEngine = await getAppsEngineVersion();
const appsEngine = await getAppsEngineVersion(cwd);
const mongo = await getMongoVersion(cwd);

return `### Engine versions
Expand Down

0 comments on commit 5be0a84

Please sign in to comment.