Skip to content

Commit

Permalink
fix: make PR changes and remove jest
Browse files Browse the repository at this point in the history
  • Loading branch information
spaenleh committed Aug 30, 2022
1 parent 5e91817 commit c5d5a0f
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 892 deletions.
4 changes: 2 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"no-use-before-define": 0,
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-use-before-define": ["error"],
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off"
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off"
},
"overrides": [
{
Expand Down
19 changes: 8 additions & 11 deletions example/src/components/ChatboxTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const ChatboxTest: FC = () => {
_: unknown,
newValue: number | number[],
): void => {
// narrow type of newValue to a simple number and not an array of numbers (slider with range)
if (typeof newValue === 'number') {
setTestWidth(newValue);
} else {
Expand All @@ -116,7 +117,7 @@ const ChatboxTest: FC = () => {
onChange={({ target }): void => setChatId(target.value)}
/>
}
label={'Chat Id'}
label="Chat Id"
labelPlacement="top"
/>
<FormControl>
Expand All @@ -126,12 +127,8 @@ const ChatboxTest: FC = () => {
value={lang}
onChange={({ target }): void => setLang(target.value)}
>
<FormControlLabel value="fr" control={<Radio />} label={'French'} />
<FormControlLabel
value="en"
control={<Radio />}
label={'English'}
/>
<FormControlLabel value="fr" control={<Radio />} label="French" />
<FormControlLabel value="en" control={<Radio />} label="English" />
</RadioGroup>
</FormControl>
<FormControl>
Expand All @@ -143,7 +140,7 @@ const ChatboxTest: FC = () => {
onChange={(): void => setShowTools(!showTools)}
/>
}
label={'Show Admin tools'}
label="Show Admin tools"
/>
<FormControlLabel
control={
Expand All @@ -152,16 +149,16 @@ const ChatboxTest: FC = () => {
min={GRAASP_PANEL_WIDTH}
step={20}
max={800}
color={'secondary'}
color="secondary"
onChange={onChangePanelWidth}
/>
}
labelPlacement="top"
label={'Panel Width'}
label="Panel Width"
/>
</FormControl>
<MentionButton
color={'primary'}
color="primary"
useMentions={hooks.useMentions}
useMembers={hooks.useMembers}
patchMentionFunction={patchMentionFunction}
Expand Down
2 changes: 1 addition & 1 deletion example/src/components/ChatboxWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const ChatboxWrapper: FC<Props> = ({
showHeader = false,
showAdminTools = false,
}) => {
// use kooks
// use hooks
const { data: currentMember } = hooks.useCurrentMember();
const { data: chat } = hooks.useItemChat(chatId);
const memberships = hooks.useItemMemberships(chatId).data;
Expand Down
5 changes: 0 additions & 5 deletions example/src/setupTests.ts

This file was deleted.

24 changes: 0 additions & 24 deletions jest.config.js

This file was deleted.

16 changes: 3 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
"prettier:check": "prettier --check \"{src,example}/**/*.{js,ts,tsx}\"",
"prettier:write": "prettier --write \"{src,example,cypress}/**/*.{js,ts,tsx}\"",
"pretest": "cd example && yarn",
"test": "yarn build && yarn test:unit",
"test:unit": "cross-env CI=1 jest src --env=jsdom",
"test:watch": "react-scripts test --env=jsdom",
"test": "yarn build",
"hooks:uninstall": "husky uninstall",
"hooks:install": "husky install",
"predeploy": "cd example && yarn install && yarn build",
Expand Down Expand Up @@ -83,9 +81,6 @@
"@rollup/plugin-json": "4.1.0",
"@rollup/plugin-node-resolve": "13.1.3",
"@rollup/plugin-typescript": "8.3.0",
"@testing-library/jest-dom": "5.16.1",
"@testing-library/react": "12.1.2",
"@testing-library/user-event": "13.5.0",
"@trivago/prettier-plugin-sort-imports": "3.2.0",
"@types/jest": "27.4.0",
"@types/lodash.truncate": "4.4.6",
Expand All @@ -100,11 +95,8 @@
"@typescript-eslint/eslint-plugin": "5.30.7",
"@typescript-eslint/parser": "5.30.7",
"cross-env": "7.0.3",
"cypress": "10",
"enzyme": "3.11.0",
"enzyme-adapter-react-16": "1.15.6",
"enzyme-to-json": "3.6.2",
"eslint": "7.32.0",
"cypress": "10.6.0",
"eslint": "8.23.0",
"eslint-config-prettier": "8.3.0",
"eslint-config-standard": "16.0.3",
"eslint-plugin-import": "2.25.4",
Expand All @@ -113,7 +105,6 @@
"eslint-plugin-promise": "5.2.0",
"eslint-plugin-react": "7.30.1",
"husky": "8.0.1",
"jest": "27.4.7",
"papaparse": "5.3.2",
"prettier": "2.7.1",
"react": "17.0.2",
Expand All @@ -125,7 +116,6 @@
"rollup-plugin-import-css": "3.0.3",
"rollup-plugin-peer-deps-external": "2.2.4",
"standard-version": "9.5.0",
"ts-jest": "27.1.2",
"ts-loader": "9.3.1",
"tslib": "2.3.1",
"typescript": "4.7.4"
Expand Down
11 changes: 6 additions & 5 deletions src/components/Chatbox/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,13 @@ const Input: FC<Props> = ({
const { id: currentMemberId } = useCurrentMemberContext();
const { t } = useTranslation();

// exclude self from suggestions
const membersExcludingSelf: MemberRecord[] =
members?.filter((m) => m.id !== currentMemberId)?.toArray() || [];
// exclude self from suggestions and add @all pseudo member
const memberSuggestions: SuggestionDataItem[] = [
{ id: ALL_MEMBERS_ID, display: ALL_MEMBERS_DISPLAY },
...membersExcludingSelf.map((m) => ({ id: m.id, display: m.name })),
...(members
?.filter((m) => m.id !== currentMemberId)
?.map((m) => ({ id: m.id, display: m.name }))
?.toArray() || []),
];

// compute if message exceeds max length
Expand Down Expand Up @@ -241,7 +242,7 @@ const Input: FC<Props> = ({
<Mention
displayTransform={(_, login): string => `@${login}`}
markup="`<!@__display__>[__id__]`"
trigger={'@'}
trigger="@"
renderSuggestion={(_, __, highlightedDisplay): ReactElement => (
<div className="user">{highlightedDisplay}</div>
)}
Expand Down
14 changes: 8 additions & 6 deletions src/components/Mentions/MentionsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ import {
import { Check, Close, FiberManualRecord } from '@material-ui/icons';

import { ChatMentionRecord } from '@graasp/query-client/dist/src/types';
import { MentionStatus, buildItemLinkForBuilder } from '@graasp/sdk';
import { getIdsFromPath } from '@graasp/sdk/dist/utils/item';
import {
MentionStatus,
buildItemLinkForBuilder,
getIdsFromPath,
} from '@graasp/sdk';
import { CHATBOX } from '@graasp/translations';
import { Button } from '@graasp/ui';

Expand Down Expand Up @@ -74,13 +77,12 @@ const MentionsTable: FC<Props> = ({
itemId: getIdsFromPath(m.itemPath).slice(-1)[0],
chatOpen: true,
});
console.log(link);
window.location.href = link;
}}
>
<TableCell>
{m.status === MentionStatus.UNREAD && (
<FiberManualRecord fontSize={'small'} color={'primary'} />
<FiberManualRecord fontSize="small" color="primary" />
)}
</TableCell>
<TableCell>{normalizeMentions(m.message)}</TableCell>
Expand All @@ -95,7 +97,7 @@ const MentionsTable: FC<Props> = ({
markAsRead(m.id);
}}
>
<Check color={'primary'} />
<Check color="primary" />
</IconButton>
</Tooltip>
</Grid>
Expand All @@ -107,7 +109,7 @@ const MentionsTable: FC<Props> = ({
deleteMention(m.id);
}}
>
<Close color={'primary'} />
<Close color="primary" />
</IconButton>
</Tooltip>
</Grid>
Expand Down
Loading

0 comments on commit c5d5a0f

Please sign in to comment.