Skip to content
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
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"@sourceacademy/sling-client": "^0.1.0",
"@szhsin/react-menu": "^4.0.0",
"@tanstack/react-table": "^8.9.3",
"@tremor/react": "^1.8.2",
"ace-builds": "^1.42.1",
"acorn": "^8.9.0",
"ag-grid-community": "^34.1.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import '@tremor/react/dist/esm/tremor.css';

import { Icon as BpIcon } from '@blueprintjs/core';
import { Button } from '@blueprintjs/core';
import { IconNames } from '@blueprintjs/icons';
import { Button, Flex } from '@tremor/react';
import React, { useCallback } from 'react';
import GradingFlex from 'src/commons/grading/GradingFlex';

import { AssessmentOverview } from '../../../../commons/assessment/AssessmentTypes';

Expand Down Expand Up @@ -44,22 +42,16 @@ const EditTeamSizeCell: React.FC<Props> = ({ data, onTeamSizeChange }) => {
};

return (
<Flex>
<GradingFlex alignItems="center" style={{ columnGap: '0.5rem' }}>
<Button
size="xs"
icon={() => <BpIcon icon={IconNames.MINUS} />}
variant="light"
variant="minimal"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The Blueprint Button component does not have a variant prop. To achieve the minimal style, use the minimal boolean prop instead.

Suggested change
variant="minimal"
minimal

icon={IconNames.MINUS}
onClick={handleDecrement}
disabled={teamSize === minTeamSize}
/>
<span>{teamSize}</span>
<Button
size="xs"
icon={() => <BpIcon icon={IconNames.PLUS} />}
variant="light"
onClick={handleIncrement}
/>
</Flex>
<Button variant="minimal" icon={IconNames.PLUS} onClick={handleIncrement} />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The Blueprint Button component uses the minimal boolean prop instead of a variant prop. Additionally, use onMouseUp instead of onClick for button actions that require an immediate component redraw, as onClick may not trigger the redraw instantly.

Suggested change
<Button variant="minimal" icon={IconNames.PLUS} onClick={handleIncrement} />
<Button minimal icon={IconNames.PLUS} onMouseUp={handleIncrement} />
References
  1. Use onMouseUp instead of onClick for button actions that require an immediate component redraw, as onClick may not trigger the redraw instantly.

</GradingFlex>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Icon as BpIcon } from '@blueprintjs/core';
import { Button, Position, Tooltip } from '@blueprintjs/core';
import { IconNames } from '@blueprintjs/icons';
import { Flex, Icon } from '@tremor/react';
import React, { useCallback } from 'react';
import { useDispatch } from 'react-redux';
import { Link } from 'react-router';
import SessionActions from 'src/commons/application/actions/SessionActions';
import GradingFlex from 'src/commons/grading/GradingFlex';
import { showSimpleConfirmDialog } from 'src/commons/utils/DialogHelper';
import { useSession } from 'src/commons/utils/Hooks';

Expand Down Expand Up @@ -33,15 +33,22 @@ const TeamFormationActions: React.FC<Props> = ({ teamId }) => {
}, [dispatch, teamId]);

return (
<Flex justifyContent="justify-start" spaceX="space-x-2">
<Link to={`/courses/${courseId}/teamformation/edit/${teamId}`}>
<Icon tooltip="Edit" icon={() => <BpIcon icon={IconNames.EDIT} />} variant="light" />
</Link>
<GradingFlex>
<Tooltip placement={Position.TOP} content="Edit">
<Link to={`/courses/${courseId}/teamformation/edit/${teamId}`}>
<Button intent="primary" icon={IconNames.EDIT} variant="minimal" />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Blueprint's Button does not support a variant prop. Use the minimal prop instead.

Suggested change
<Button intent="primary" icon={IconNames.EDIT} variant="minimal" />
<Button intent="primary" icon={IconNames.EDIT} minimal />

</Link>
</Tooltip>

<button type="button" style={{ padding: 0 }} onClick={handleDeleteTeamClick}>
<Icon tooltip="Delete" icon={() => <BpIcon icon={IconNames.TRASH} />} variant="simple" />
</button>
</Flex>
<Tooltip placement={Position.TOP} content="Delete">
<Button
intent="danger"
icon={IconNames.TRASH}
variant="minimal"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Blueprint's Button does not support a variant prop. Use the minimal prop instead.

Suggested change
variant="minimal"
minimal

onClick={handleDeleteTeamClick}
/>
</Tooltip>
</GradingFlex>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
import { Icon } from '@blueprintjs/core';
import { Button, Intent } from '@blueprintjs/core';
import { IconNames } from '@blueprintjs/icons';
import { ColumnFilter } from '@tanstack/react-table';
import { Badge } from '@tremor/react';
import React from 'react';

import { getBadgeColorFromLabelLegacy } from '../../grading/subcomponents/GradingBadges';

// TODO: Remove after migration is completed
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Avoid using TODO comments in the codebase. Please track this task in your project management system instead.

References
  1. Resolve known issues or track them in a formal task management system instead of leaving TODO comments in the codebase.

const TREMOR_TO_BLUEPRINT_INTENT: Record<string, Intent> = {
indigo: Intent.PRIMARY,
emerald: Intent.SUCCESS,
sky: Intent.PRIMARY,
purple: Intent.PRIMARY,
gray: Intent.NONE,
red: Intent.DANGER,
yellow: Intent.WARNING,
green: Intent.SUCCESS,
blue: Intent.PRIMARY
};

type Props = {
filter: ColumnFilter;
onRemove: (filter: ColumnFilter) => void;
Expand All @@ -14,14 +26,13 @@ type Props = {
const FilterBadge: React.FC<Props> = ({ filter, onRemove }) => {
let filterValue = filter.value as string;
filterValue = filterValue.charAt(0).toUpperCase() + filterValue.slice(1);
const legacyColor = getBadgeColorFromLabelLegacy(filterValue);
const intent = TREMOR_TO_BLUEPRINT_INTENT[legacyColor] || Intent.NONE;

return (
<button type="button" onClick={() => onRemove(filter)} style={{ padding: 0 }}>
<Badge
text={filterValue}
icon={() => <Icon icon={IconNames.CROSS} style={{ marginRight: '0.25rem' }} />}
color={getBadgeColorFromLabelLegacy(filterValue)}
/>
</button>
<Button intent={intent} icon={IconNames.CROSS} onClick={() => onRemove(filter)}>
{filterValue}
</Button>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import '@tremor/react/dist/esm/tremor.css';

import { Button as BpButton } from '@blueprintjs/core';
import { Card, Flex, Title } from '@tremor/react';
import { Button as BpButton, Card } from '@blueprintjs/core';
import { useNavigate } from 'react-router';
import GradingFlex from 'src/commons/grading/GradingFlex';
import GradingText from 'src/commons/grading/GradingText';
import { useSession } from 'src/commons/utils/Hooks';
import { TeamFormationOverview } from 'src/features/teamFormation/TeamFormationTypes';

Expand All @@ -27,13 +26,17 @@ const TeamFormationDashboard: React.FC<TeamFormationDashboardProps> = ({ teams }
const teamData = teams;
return (
<Card>
<Flex justifyContent="justify-between">
<Title>Teams</Title>
<Flex justifyContent="justify-end" spaceX="space-x-2">
<GradingFlex
justifyContent="space-between"
alignItems="center"
style={{ marginBottom: '1rem' }}
>
<GradingText style={{ fontSize: '1.125rem', opacity: 0.9, margin: 0 }}>Teams</GradingText>
<GradingFlex justifyContent="flex-end" style={{ columnGap: '0.5rem' }}>
<BpButton onClick={createTeam}>Create Team</BpButton>
<BpButton onClick={importTeam}>Import Team</BpButton>
</Flex>
</Flex>
</GradingFlex>
</GradingFlex>
<TeamFormationTable group={group} teams={teamData} />
</Card>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ColumnFilter, ColumnFiltersState } from '@tanstack/react-table';
import { Flex } from '@tremor/react';
import React from 'react';
import GradingFlex from 'src/commons/grading/GradingFlex';

import { FilterBadge } from './TeamFormationBadges';

Expand All @@ -10,11 +11,11 @@ type TeamFormationFiltersProps = {

const TeamFormationFilters: React.FC<TeamFormationFiltersProps> = ({ filters, onFilterRemove }) => {
return (
<Flex justifyContent="justify-start" spaceX="space-x-1">
<GradingFlex justifyContent="flex-start" style={{ columnGap: '0.25rem' }}>
{filters.map(filter => (
<FilterBadge filter={filter} onRemove={onFilterRemove} key={filter.id} />
))}
</Flex>
</GradingFlex>
);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import '@tremor/react/dist/esm/tremor.css';

import { Button } from '@blueprintjs/core';
import React, { useEffect, useState } from 'react';
import { useDispatch } from 'react-redux';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import '@tremor/react/dist/esm/tremor.css';

import { Button } from '@blueprintjs/core';
import { useState } from 'react';
import { FileUploader } from 'react-drag-drop-files';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import '@tremor/react/dist/esm/tremor.css';

import { Icon as BpIcon } from '@blueprintjs/core';
import { Button, HTMLTable, Icon as BpIcon, InputGroup } from '@blueprintjs/core';
import { IconNames } from '@blueprintjs/icons';
import {
Column,
Expand All @@ -14,20 +12,9 @@ import {
Row,
useReactTable
} from '@tanstack/react-table';
import {
Bold,
Button,
Flex,
Table,
TableBody,
TableCell,
TableHead,
TableHeaderCell,
TableRow,
Text,
TextInput
} from '@tremor/react';
import React, { useState } from 'react';
import GradingFlex from 'src/commons/grading/GradingFlex';
import GradingText from 'src/commons/grading/GradingText';
import { objectKeys } from 'src/commons/utils/TypeHelper';
import { TeamFormationOverview } from 'src/features/teamFormation/TeamFormationTypes';

Expand Down Expand Up @@ -140,72 +127,72 @@ const TeamFormationTable: React.FC<TeamFormationTableProps> = ({ group, teams })

return (
<>
<Flex marginTop="mt-2" justifyContent="justify-between" alignItems="items-center">
<Flex alignItems="items-center" spaceX="space-x-2">
<div style={{ display: 'flex', gap: '0.5rem', alignItems: 'center', height: '1.75rem' }}>
<GradingFlex
justifyContent="space-between"
alignItems="center"
style={{ marginTop: '0.5rem' }}
>
<GradingFlex alignItems="center" style={{ columnGap: '0.5rem' }}>
<GradingFlex alignItems="center" style={{ columnGap: '0.5rem', height: '1.75rem' }}>
<BpIcon icon={IconNames.FILTER_LIST} />
<Text>
<GradingText>
{columnFilters.length > 0
? 'Filters: '
: 'No filters applied. Click on any cell to filter by its value.'}{' '}
</Text>
</div>
</GradingText>
</GradingFlex>
<TeamFormationFilters filters={columnFilters} onFilterRemove={handleFilterRemove} />
</Flex>
</GradingFlex>

<TextInput
maxWidth="max-w-sm"
icon={() => <BpIcon icon={IconNames.SEARCH} style={{ marginLeft: '0.75rem' }} />}
<InputGroup
style={{ maxWidth: '14rem' }}
leftIcon={IconNames.SEARCH}
placeholder="Search for any value here..."
onChange={e => setGlobalFilter(e.target.value)}
/>
</Flex>
<Table marginTop="mt-2">
<TableHead>
</GradingFlex>
<HTMLTable style={{ marginTop: '0.5rem', width: '100%' }}>
<thead>
{table.getHeaderGroups().map(headerGroup => (
<TableRow key={headerGroup.id}>
<tr key={headerGroup.id}>
{headerGroup.headers.map(header => (
<TableHeaderCell key={header.id}>
<th key={header.id}>
{header.isPlaceholder
? null
: flexRender(header.column.columnDef.header, header.getContext())}
</TableHeaderCell>
</th>
))}
</TableRow>
</tr>
))}
</TableHead>
<TableBody>
</thead>
<tbody>
{table.getRowModel().rows.map(row => (
<TableRow key={row.id}>
<tr key={row.id}>
{row.getVisibleCells().map(cell => (
<TableCell key={cell.id}>
{flexRender(cell.column.columnDef.cell, cell.getContext())}
</TableCell>
<td key={cell.id}>{flexRender(cell.column.columnDef.cell, cell.getContext())}</td>
))}
</TableRow>
</tr>
))}
</TableBody>
</Table>
</tbody>
</HTMLTable>
<div>
<Flex justifyContent="justify-center" spaceX="space-x-3">
<GradingFlex justifyContent="center" style={{ columnGap: '0.75rem' }}>
<Button
size="xs"
icon={() => <BpIcon icon={IconNames.ARROW_LEFT} />}
variant="light"
variant="minimal"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Blueprint's Button uses the minimal prop rather than variant="minimal".

Suggested change
variant="minimal"
minimal

icon={IconNames.ARROW_LEFT}
onClick={() => table.previousPage()}
disabled={!table.getCanPreviousPage()}
/>
<Bold>
<GradingText style={{ fontWeight: 'bold' }}>
Page {table.getState().pagination.pageIndex + 1} of {table.getPageCount()}
</Bold>
</GradingText>
<Button
size="xs"
icon={() => <BpIcon icon={IconNames.ARROW_RIGHT} />}
variant="light"
variant="minimal"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Blueprint's Button uses the minimal prop rather than variant="minimal".

Suggested change
variant="minimal"
minimal

icon={IconNames.ARROW_RIGHT}
onClick={() => table.nextPage()}
disabled={!table.getCanNextPage()}
/>
</Flex>
</GradingFlex>
</div>
</>
);
Expand All @@ -223,9 +210,9 @@ const Filterable: React.FC<FilterableProps> = ({ column, value, children }) => {
};

return (
<button type="button" onClick={handleFilterChange} style={{ padding: 0 }}>
<Button variant="minimal" onClick={handleFilterChange} style={{ padding: 0 }}>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Blueprint's Button uses the minimal prop rather than variant="minimal". Also, use onMouseUp instead of onClick for button actions that require an immediate component redraw, as onClick may not trigger the redraw instantly.

Suggested change
<Button variant="minimal" onClick={handleFilterChange} style={{ padding: 0 }}>
<Button minimal onMouseUp={handleFilterChange} style={{ padding: 0 }}>
References
  1. Use onMouseUp instead of onClick for button actions that require an immediate component redraw, as onClick may not trigger the redraw instantly.

{children || value}
</button>
</Button>
);
};

Expand Down
Loading
Loading