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

Bugfixes #396

Merged
merged 3 commits into from
Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -191,21 +191,38 @@ function LiveFeedbackPromptList({ queryRef, responsesModalStatusRef }: LiveFeedb
};

const PromptResponseList = () => {
if (selectedPromptRef.current) {
if (selectedPromptRef.current)
return (
<ConditionalRender client>
<React.Suspense fallback={<Loader />}>
<PreloadedLiveFeedbackPromptResponseList prompt={selectedPromptRef.current} />
</React.Suspense>
</ConditionalRender>
);
}
return <React.Fragment />;
};

const PromptText = React.useCallback(() => {
if (selectedPromptRef.current)
return (
<Grid container padding='1rem'>
<Grid item xs>
<Typography variant='h5' style={{ overflowWrap: 'break-word' }}>
Prompt: {selectedPromptRef.current.prompt}
</Typography>
</Grid>
</Grid>
);
return <React.Fragment />;
}, []);

const ShareFeedbackResultsButton = () => {
if (selectedPromptRef.current && selectedPromptRef.current.isVote)
return <ShareFeedbackPromptResults prompt={selectedPromptRef.current} />;
return (
<Grid item paddingBottom='1rem'>
<ShareFeedbackPromptResults prompt={selectedPromptRef.current} />
</Grid>
);
return <React.Fragment />;
};

Expand All @@ -226,6 +243,7 @@ function LiveFeedbackPromptList({ queryRef, responsesModalStatusRef }: LiveFeedb
</StyledDialogTitle>
<DialogContent dividers>
<Grid container direction='column' alignItems='center' alignContent='center'>
<PromptText />
<ShareFeedbackResultsButton />
<PromptResponseList />
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,17 @@ function PromptResponseList({ promptResponses, promptData }: PromptListProps) {

return (
<React.Fragment>
<Grid container paddingX='1rem'>
<Grid item xs>
<Typography style={{ overflowWrap: 'break-word' }}>Prompt: {promptData.prompt}</Typography>
</Grid>
</Grid>
<Grid container justifyContent='center'>
<Grid container justifyContent='center' paddingBottom='1rem'>
{promptData.isVote ? (
<Button onClick={toggleChartVisiblity}>{chartVisiblity ? 'Hide Chart' : 'Show Chart'}</Button>
) : (
<></>
<React.Fragment />
)}
</Grid>
{chartVisiblity && (
<React.Fragment>
{zeroVotes ? (
<div>No Votes Yet</div>
<Typography>No Votes Yet</Typography>
) : (
<VoteResponseChart
votes={{ for: voteCount.for, against: voteCount.against, conflicted: voteCount.conflicted }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function Results({ promptResponseVotes }: ResultsProps) {
return (
<React.Fragment>
{zeroVotes ? (
<div>No Votes To Display</div>
<Typography>No Votes To Display</Typography>
) : (
<VoteResponseChart votes={{ for: forVotes, against: againstVotes, conflicted: conflictedVotes }} />
)}
Expand Down Expand Up @@ -107,9 +107,18 @@ export function ViewLiveFeedbackPromptResults({ promptRef, closeSnack }: ViewLiv
</StyledDialogTitle>
<DialogContent dividers>
<Grid container direction='column' alignItems='center' alignContent='center'>
<Typography className='modal-prompt' variant='h5' paddingTop='1.5rem'>
{promptRef.current.prompt}
</Typography>
<Grid container padding='1rem'>
<Grid item xs>
<Typography
className='modal-prompt'
variant='h5'
paddingY='1.5rem'
style={{ overflowWrap: 'break-word' }}
>
Prompt: {promptRef.current.prompt}
</Typography>
</Grid>
</Grid>
<ConditionalRender client>
<React.Suspense fallback={<Loader />}>
<PreloadedViewLiveFeedbackPromptResults promptId={promptRef.current.id} />
Expand Down
6 changes: 4 additions & 2 deletions app/client/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export function debounce<T extends Callback>(cb: T, timeout: number): Callback {
}
// source link for Regex https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url
export function isURL(str: string) {
const pattern = new RegExp(/[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)?/gi);
const pattern = new RegExp(
// eslint-disable-next-line no-useless-escape
/[(http(s)?):\/\/(www\.)?a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/gi
);
return !!pattern.test(str);
}

4 changes: 1 addition & 3 deletions app/e2e/tests/dashboard/organizer-dashboard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ export default function organizerTests() {
await expect(dashboardPageOrganizer.page).toHaveURL(/.*settings/);
});

test('I can see sections for Current Events and Upcoming Events.', async ({
dashboardPageOrganizer,
}) => {
test('I can see sections for Current Events and Upcoming Events.', async ({ dashboardPageOrganizer }) => {
// Go to Dashboard
await dashboardPageOrganizer.goto();

Expand Down