Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About box improvements #8959

Merged
merged 15 commits into from
Oct 8, 2024
Merged
16 changes: 7 additions & 9 deletions front/app/components/ProjectCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -717,15 +717,13 @@ const ProjectCard = memo<InputProps>(
className={`${size} ${!showFooter ? 'hidden' : ''}`}
>
<Box h="100%" display="flex" alignItems="center">
{hasAvatars && (
<AvatarBubbles
size={32}
limit={3}
userCountBgColor={theme.colors.tenantPrimary}
avatarIds={avatarIds}
userCount={project.data.attributes.participants_count}
/>
)}
<AvatarBubbles
size={32}
limit={3}
userCountBgColor={theme.colors.tenantPrimary}
avatarIds={avatarIds}
userCount={project.data.attributes.participants_count}
/>
</Box>
</ContentFooter>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ const mockProjectData = {
input_term: 'idea',
uses_content_builder: true,
},
relationships: {
avatars: {
data: [
{
id: '1',
type: 'avatar',
},
{
id: '2',
type: 'avatar',
},
],
},
},
};

const mockProjectDescriptionBuilderLayoutData:
Expand Down Expand Up @@ -70,7 +84,7 @@ describe('Preview', () => {
screen.queryByTestId('projectDescriptionBuilderProjectDescription')
).not.toBeInTheDocument();
});
it('should shows description when project description builder is not enabled', () => {
it('should show description when project description builder is not enabled', () => {
DEFAULT_PROJECT_DESCRIPTION_BUILDER_LAYOUT_DATA.data.attributes.enabled =
false;
render(<Preview projectId={projectId} projectTitle={projectTitle} />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from 'react';

import { Box, Spinner, Title } from '@citizenlab/cl2-component-library';
import { isEmpty } from 'lodash-es';
import useProjectDescriptionBuilderLayout from 'api/project_description_builder/useProjectDescriptionBuilderLayout';
import { Multiloc } from 'typings';

import useProjectDescriptionBuilderLayout from 'api/project_description_builder/useProjectDescriptionBuilderLayout';
import useProjectFiles from 'api/project_files/useProjectFiles';
import useProjectById from 'api/projects/useProjectById';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import React from 'react';

import { Box } from '@citizenlab/cl2-component-library';
import { Box, colors, Toggle } from '@citizenlab/cl2-component-library';
import { useNode } from '@craftjs/core';
import { useParams } from 'react-router-dom';

import useProjectBySlug from 'api/projects/useProjectBySlug';

import ProjectInfoSideBar from 'containers/ProjectsShowPage/shared/header/ProjectInfoSideBar';

import { useIntl } from 'utils/cl-intl';

import useCraftComponentDefaultPadding from '../../useCraftComponentDefaultPadding';

import messages from './messages';

const AboutBox = () => {
type AboutBoxProps = {
hideParticipationNumbers?: boolean;
};

const AboutBox = ({ hideParticipationNumbers }: AboutBoxProps) => {
const { projectId, slug } = useParams() as {
projectId: string;
slug: string;
Expand All @@ -26,14 +33,48 @@ const AboutBox = () => {
margin="0 auto"
px={componentDefaultPadding}
>
{projectID && <ProjectInfoSideBar projectId={projectID} />}
{projectID && (
<ProjectInfoSideBar
projectId={projectID}
hideParticipationNumbers={hideParticipationNumbers}
/>
)}
</Box>
);
};

const AboutBoxSettings = () => {
const { formatMessage } = useIntl();
const {
actions: { setProp },
hideParticipationNumbers,
} = useNode((node) => ({
hideParticipationNumbers: node.data.props.hideParticipationNumbers,
id: node.id,
}));

return (
<Box background={colors.white} my="32px">
<Toggle
checked={hideParticipationNumbers}
onChange={() => {
setProp(
(props: AboutBoxProps) =>
(props.hideParticipationNumbers = !hideParticipationNumbers)
);
}}
label={formatMessage(messages.hideParticipationNumbersText)}
/>
</Box>
);
};

AboutBox.craft = {
related: {
settings: AboutBoxSettings,
},
custom: {
title: messages.aboutBox,
title: messages.participationBox,
noPointerEvents: true,
},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { defineMessages } from 'react-intl';

export default defineMessages({
aboutBox: {
id: 'app.containers.admin.ContentBuilder.aboutBox',
defaultMessage: 'About Box',
participationBox: {
id: 'app.containers.admin.ContentBuilder.participationBox',
defaultMessage: 'Participation Box',
},
hideParticipationNumbersText: {
id: 'app.containers.admin.ContentBuilder.hideParticipationNumbersText',
defaultMessage: 'Hide participation numbers',
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Text,
colors,
IconNames,
Tooltip,
} from '@citizenlab/cl2-component-library';
import moment from 'moment';
import styled from 'styled-components';
Expand All @@ -21,7 +22,7 @@ import otherProjectMessages from 'containers/Admin/projects/all/messages';
import NavigationTabs from 'components/admin/NavigationTabs';
import Button from 'components/UI/Button';

import { MessageDescriptor, useIntl } from 'utils/cl-intl';
import { FormattedMessage, MessageDescriptor, useIntl } from 'utils/cl-intl';

import messages from './messages';

Expand Down Expand Up @@ -171,14 +172,57 @@ const ProjectHeader = ({ projectId }: Props) => {
<Text color="coolGrey600" fontSize="s" my="0px">
·
</Text>
<Box display="flex" alignItems="center">
<Icon name="user" fill={colors.coolGrey600} width="16px" />
<Text color="coolGrey600" fontSize="s" m="0px">
{formatMessage(messages.participants, {
participantsCount: project.data.attributes.participants_count,
})}
</Text>
</Box>
<Tooltip
theme="dark"
maxWidth={280}
placement="bottom"
content={
<Box p="8px">
<FormattedMessage {...messages.participantsInfoTitle} />
<ul
style={{
margin: '0',
marginBottom: '8px',
listStyleType: 'disc',
}}
>
<li>
<FormattedMessage {...messages.users} />
</li>
<li>
<FormattedMessage {...messages.attendees} />
</li>
</ul>

<FormattedMessage {...messages.participantsExclusionTitle} />
<ul
style={{
margin: '0',
marginBottom: '8px',
listStyleType: 'disc',
}}
>
<li>
<FormattedMessage {...messages.followers} />
</li>
<li>
<FormattedMessage {...messages.embeddedMethods} />
</li>
</ul>

<FormattedMessage {...messages.note} />
</Box>
}
>
<Box display="flex" alignItems="center">
<Icon name="user" fill={colors.coolGrey600} width="16px" />
<Text color="coolGrey600" fontSize="s" m="0px">
{formatMessage(messages.participants, {
participantsCount: project.data.attributes.participants_count,
})}
</Text>
</Box>
</Tooltip>
EdwinKato marked this conversation as resolved.
Show resolved Hide resolved
</Box>
</Box>
</NavigationTabs>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,33 @@ export default defineMessages({
id: 'app.components.app.containers.AdminPage.ProjectEdit.projectHeader.publishedFinished1',
defaultMessage: 'Published - Finished',
},
participantsInfoTitle: {
id: 'app.components.app.containers.AdminPage.ProjectEdit.projectHeader.participantsInfo.participantsInfoTitle',
defaultMessage: 'Participants include:',
},
users: {
id: 'app.components.app.containers.AdminPage.ProjectEdit.projectHeader.participantsInfo.users',
defaultMessage: 'Users interacting with Go Vocal methods',
},
attendees: {
id: 'app.components.app.containers.AdminPage.ProjectEdit.projectHeader.participantsInfo.attendees',
defaultMessage: 'Event attendees',
},
participantsExclusionTitle: {
id: 'app.components.app.containers.AdminPage.ProjectEdit.projectHeader.participantsInfo.participantsExclusionTitle',
defaultMessage: 'Participants do not include:',
},
followers: {
id: 'app.components.app.containers.AdminPage.ProjectEdit.projectHeader.participantsInfo.followers',
defaultMessage: 'Followers of a project',
},
embeddedMethods: {
id: 'app.components.app.containers.AdminPage.ProjectEdit.projectHeader.participantsInfo.embeddedMethods',
defaultMessage: 'Participants in embedded methods (e.g., external surveys)',
},
note: {
id: 'app.components.app.containers.AdminPage.ProjectEdit.projectHeader.participantsInfo.note',
defaultMessage:
'Note: Enabling anonymous or open participation permissions may allow users to participate multiple times, leading to misleading or incomplete user data.',
},
});
Loading