Skip to content

Commit

Permalink
feat: add action triggers on item view and download (#374)
Browse files Browse the repository at this point in the history
Co-authored-by: LinaYahya <[email protected]>
  • Loading branch information
LinaYahya authored Dec 1, 2023
1 parent c32538e commit bdd3a4a
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 1,886 deletions.
40 changes: 1 addition & 39 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ All notable changes to this project will be documented in this file. See [standa

## [2.1.0](https://github.com/graasp/graasp-player/compare/v2.0.1...v2.1.0) (2023-11-16)


### Features

* redirects to account for profile ([#403](https://github.com/graasp/graasp-player/issues/403)) ([06887c7](https://github.com/graasp/graasp-player/commit/06887c7eeceb7e59206e24dd9a55e6b2cfc5283d))


### Bug Fixes

* allow apps to render even when member is null ([#406](https://github.com/graasp/graasp-player/issues/406)) ([310f557](https://github.com/graasp/graasp-player/commit/310f5574b10578ea5217add1cde3b409b2103564))
Expand All @@ -18,7 +16,6 @@ All notable changes to this project will be documented in this file. See [standa

## [2.0.1](https://github.com/graasp/graasp-player/compare/v2.0.0...v2.0.1) (2023-11-06)


### Bug Fixes

* **deps:** update dependency @sentry/react to v7.77.0 ([#390](https://github.com/graasp/graasp-player/issues/390)) ([25f3052](https://github.com/graasp/graasp-player/commit/25f30528627948b213521950636f7002bb9fc34f))
Expand All @@ -28,7 +25,6 @@ All notable changes to this project will be documented in this file. See [standa

## [2.0.0](https://github.com/graasp/graasp-player/compare/v1.2.2...v2.0.0) (2023-11-03)


### ⚠ BREAKING CHANGES

* remove immutable ([#392](https://github.com/graasp/graasp-player/issues/392))
Expand All @@ -37,7 +33,6 @@ All notable changes to this project will be documented in this file. See [standa

* remove immutable ([#392](https://github.com/graasp/graasp-player/issues/392)) ([36937ad](https://github.com/graasp/graasp-player/commit/36937add6bbf93babcdb8dc9af60f3a79f68fcab))


### Bug Fixes

* **deps:** update dependency @sentry/react to v7.74.1 ([7f9eb64](https://github.com/graasp/graasp-player/commit/7f9eb64ffb5b7ee6187931420ad21966970c329c))
Expand All @@ -47,7 +42,6 @@ All notable changes to this project will be documented in this file. See [standa

## [1.2.2](https://github.com/graasp/graasp-player/compare/v1.2.1...v1.2.2) (2023-10-16)


### Bug Fixes

* **deps:** update dependency @graasp/query-client to v1.11.0 ([#364](https://github.com/graasp/graasp-player/issues/364)) ([9352303](https://github.com/graasp/graasp-player/commit/935230367aee7cd0da127312db0dcbe6cb008df7))
Expand All @@ -61,7 +55,6 @@ All notable changes to this project will be documented in this file. See [standa

## [1.2.1](https://github.com/graasp/graasp-player/compare/v1.2.0...v1.2.1) (2023-09-27)


### Bug Fixes

* add collapsible on shortcuts ([#354](https://github.com/graasp/graasp-player/issues/354)) ([7ad6092](https://github.com/graasp/graasp-player/commit/7ad6092aaecdce8c4b5b72c32049d0ccda2c6b5b))
Expand All @@ -71,12 +64,10 @@ All notable changes to this project will be documented in this file. See [standa

## [1.2.0](https://github.com/graasp/graasp-player/compare/v1.1.0...v1.2.0) (2023-09-21)


### Features

* keep current window location on login of forbidden screen ([#344](https://github.com/graasp/graasp-player/issues/344)) ([a4b755b](https://github.com/graasp/graasp-player/commit/a4b755b46422007a8a4c3f723137c573197d2b39))


### Bug Fixes

* allow multiple etherpads to be opened simultaneously ([#345](https://github.com/graasp/graasp-player/issues/345)) ([b08d27c](https://github.com/graasp/graasp-player/commit/b08d27c04ea899bd66aefb25411dacdae48b4c63))
Expand All @@ -97,20 +88,17 @@ All notable changes to this project will be documented in this file. See [standa

## [1.1.0](https://github.com/graasp/graasp-player/compare/v1.0.3...v1.1.0) (2023-08-10)


### Features

* enable analytics dashboard ([#306](https://github.com/graasp/graasp-player/issues/306)) ([6aabddd](https://github.com/graasp/graasp-player/commit/6aabddd294b6c19ba1c1fb3a29393bf864e8cbd0))


### Bug Fixes

* **deps:** update dependency @graasp/query-client to v1.4.0 ([#288](https://github.com/graasp/graasp-player/issues/288)) ([fc1cafe](https://github.com/graasp/graasp-player/commit/fc1cafeff9d0ae2917c6d3be05636235563d2dc5))
* **deps:** update sentry packages to v7.62.0 ([#301](https://github.com/graasp/graasp-player/issues/301)) ([cced3b4](https://github.com/graasp/graasp-player/commit/cced3b4d9e859844ba78fbc8c5a451dfbc259419))

## [1.0.3](https://github.com/graasp/graasp-player/compare/v1.0.2...v1.0.3) (2023-08-09)


### Bug Fixes

* deps and prettier ([#295](https://github.com/graasp/graasp-player/issues/295)) ([9750005](https://github.com/graasp/graasp-player/commit/975000578afce173137f970f166eff8fd1ed92a6))
Expand All @@ -122,7 +110,6 @@ All notable changes to this project will be documented in this file. See [standa

## [1.0.2](https://github.com/graasp/graasp-player/compare/v1.0.1...v1.0.2) (2023-07-20)


### Bug Fixes

* **deps:** update dependency @graasp/translations to v1.15.0 ([#258](https://github.com/graasp/graasp-player/issues/258)) ([b0f1122](https://github.com/graasp/graasp-player/commit/b0f1122b0883e387e0d32ba66dd74a1f07689d29))
Expand All @@ -139,7 +126,6 @@ All notable changes to this project will be documented in this file. See [standa

## [1.0.1](https://github.com/graasp/graasp-player/compare/v1.0.0...v1.0.1) (2023-06-30)


### Bug Fixes

* bump @graasp/query-client to fix etherpad queries ([#262](https://github.com/graasp/graasp-player/issues/262)) ([d72ff2b](https://github.com/graasp/graasp-player/commit/d72ff2bb6890a09fc52c53b88a4ab57967f14bb7))
Expand All @@ -151,7 +137,6 @@ All notable changes to this project will be documented in this file. See [standa

## [1.0.0](https://github.com/graasp/graasp-player/compare/v0.6.4...v1.0.0) (2023-06-01)


### ⚠ BREAKING CHANGES

* typeorm ([#216](https://github.com/graasp/graasp-player/issues/216))
Expand All @@ -162,14 +147,12 @@ All notable changes to this project will be documented in this file. See [standa

## [0.6.4](https://github.com/graasp/graasp-player/compare/v0.6.3...v0.6.4) (2023-05-09)


### Bug Fixes

* bump @graasp/ui to 2.5.0 and @graasp/translations to 1.12.0 ([#236](https://github.com/graasp/graasp-player/issues/236)) ([4522964](https://github.com/graasp/graasp-player/commit/45229640d3832d7bedabe3737b9b941724de206a))

## [0.6.3](https://github.com/graasp/graasp-player/compare/v0.6.2...v0.6.3) (2023-04-27)


### Bug Fixes

* apps loading forever ([#227](https://github.com/graasp/graasp-player/issues/227)) ([04a0e61](https://github.com/graasp/graasp-player/commit/04a0e618240bd461667e3ed223d0cfc19d46ce69))
Expand All @@ -178,7 +161,6 @@ All notable changes to this project will be documented in this file. See [standa

## [0.6.2](https://github.com/graasp/graasp-player/compare/v0.6.1...v0.6.2) (2023-04-18)


### Bug Fixes

* assign showCollapse prop to items ([8df59c9](https://github.com/graasp/graasp-player/commit/8df59c9e4e5255c7cd55cf13de1e483168fa91b8))
Expand All @@ -187,34 +169,29 @@ All notable changes to this project will be documented in this file. See [standa

## [0.6.1](https://github.com/graasp/graasp-player/compare/v0.6.0...v0.6.1) (2023-03-24)


### Bug Fixes

* **ui:** styles of text and images ([#221](https://github.com/graasp/graasp-player/issues/221)) ([2ee61bd](https://github.com/graasp/graasp-player/commit/2ee61bdcee94f49fc5cd4a6c81654721ea24ac7d))


### Documentation

* improve doc related to env files ([#213](https://github.com/graasp/graasp-player/issues/213)) ([0e309d4](https://github.com/graasp/graasp-player/commit/0e309d495ff0a5499ed1074000088c01f42cefa6))

## [0.6.0](https://github.com/graasp/graasp-player/compare/v0.5.0...v0.6.0) (2023-03-16)


### Features

* move player to vite ([#204](https://github.com/graasp/graasp-player/issues/204)) ([fff08ab](https://github.com/graasp/graasp-player/commit/fff08abb4c8d9cbcaab0974b81d60e917865119c))

## [0.5.0](https://github.com/graasp/graasp-player/compare/v0.4.1...v0.5.0) (2023-03-06)


### Features

* add document styles in Player ([#203](https://github.com/graasp/graasp-player/issues/203)) ([944f158](https://github.com/graasp/graasp-player/commit/944f1588da4be12665dfd4fe1ddb76a4b96896bc))
* remove builder button ([#198](https://github.com/graasp/graasp-player/issues/198)) ([967addc](https://github.com/graasp/graasp-player/commit/967addce3eb711120ed784c4712a6dad3a24e16f))

## [0.4.1](https://github.com/graasp/graasp-player/compare/v0.4.0...v0.4.1) (2023-02-24)


### Bug Fixes

* fixes overflow of card title in button wrapper ([00baf46](https://github.com/graasp/graasp-player/commit/00baf469a688926bcdbddc52e1437171268f8f3d))
Expand All @@ -224,43 +201,37 @@ All notable changes to this project will be documented in this file. See [standa

## [0.4.0](https://github.com/graasp/graasp-player/compare/v0.3.0...v0.4.0) (2023-02-16)


### Features

* add platform switch to player ([#184](https://github.com/graasp/graasp-player/issues/184)) ([b7a32d4](https://github.com/graasp/graasp-player/commit/b7a32d4fb00355c71c4142949610bf7bf3ae3b80))

## [0.3.0](https://github.com/graasp/graasp-player/compare/v0.2.2...v0.3.0) (2023-02-14)


### Features

* upgrade packages ([#187](https://github.com/graasp/graasp-player/issues/187)) ([bf3ef37](https://github.com/graasp/graasp-player/commit/bf3ef3740ef0553c12297127c25c85d295dd774c))

## [0.2.2](https://github.com/graasp/graasp-player/compare/v0.2.1...v0.2.2) (2023-01-31)


### Bug Fixes

* update @graasp/query-client ([#182](https://github.com/graasp/graasp-player/issues/182)) ([28ad838](https://github.com/graasp/graasp-player/commit/28ad838d74f20b73c56ad00b16f705d1af3705f9))
* update chatbox with mention fix ([e3eaa11](https://github.com/graasp/graasp-player/commit/e3eaa11344867c8bf64d500491d2ebb9988602c1))

## [0.2.1](https://github.com/graasp/graasp-player/compare/v0.2.0...v0.2.1) (2023-01-19)


### Bug Fixes

* h5p revert to default iframe ([#174](https://github.com/graasp/graasp-player/issues/174)) ([7e5325d](https://github.com/graasp/graasp-player/commit/7e5325dc6253b23fd9baf8299863912fd84e146c))

## [0.2.0](https://github.com/graasp/graasp-player/compare/v0.1.13...v0.2.0) (2023-01-11)


### Features

* add etherpad view ([#170](https://github.com/graasp/graasp-player/issues/170)) ([4faaf57](https://github.com/graasp/graasp-player/commit/4faaf57ce8273f568ca6deff68b03ed3051c3c32))

### 0.1.13 (2022-12-12)


### Features

* move to ts, add icons in mainmenu ([#163](https://github.com/graasp/graasp-player/issues/163)) ([f6b921a](https://github.com/graasp/graasp-player/commit/f6b921a0484b2aef4bd609dd644a80e66e135f8e))
Expand All @@ -271,21 +242,18 @@ All notable changes to this project will be documented in this file. See [standa

### 0.1.10 (2022-11-18)


### Features

* auto-resize apps ([#156](https://github.com/graasp/graasp-player/issues/156)) ([a125edb](https://github.com/graasp/graasp-player/commit/a125edbc8492f11865b8e49276f8017f965134eb))

### 0.1.9 (2022-11-14)


### Features

* update workflows ([#152](https://github.com/graasp/graasp-player/issues/152)) ([f7942bd](https://github.com/graasp/graasp-player/commit/f7942bda97130775abd0be4c135caba41e542aac))

### 0.1.8 (2022-11-03)


### Bug Fixes

* change page title for GA ([#146](https://github.com/graasp/graasp-player/issues/146)) ([0b08115](https://github.com/graasp/graasp-player/commit/0b081151e36a584bb364c65b7e8b7a08cfea14d0))
Expand All @@ -302,7 +270,6 @@ All notable changes to this project will be documented in this file. See [standa

### [0.1.2](https://github.com/graasp/graasp-player/compare/v0.1.1...v0.1.2) (2022-08-17)


### Features

* integrate H5P apps display ([#99](https://github.com/graasp/graasp-player/issues/99)) ([4e7e505](https://github.com/graasp/graasp-player/commit/4e7e505f9c66656a7df7500c6987dfeb911259f4))
Expand All @@ -311,10 +278,9 @@ All notable changes to this project will be documented in this file. See [standa

## 0.1.0 (2022-07-21)


### Features

* add ci caller workflow to graasp-deploy ([624d5c4](https://github.com/graasp/graasp-player/commit/624d5c472bf6f06dfe28c21e0ddb3469c90b2d15))
* add ci caller workflow to graasp-deploy ([624d5c4](https://github.com/graasp/graasp-player/commit/624d5c472bf6f06dfe28c21e0ddb3469c90b2d15))
* add aasa ([a0b700b](https://github.com/graasp/graasp-player/commit/a0b700bd61963a0dc13703d9f3df11aeb01e50ca)), closes [#34](https://github.com/graasp/graasp-player/issues/34)
* add basic layout ([eb65335](https://github.com/graasp/graasp-player/commit/eb6533504dc9011446323c23a88a5151ec45d756))
* add cdelivery caller workflow to graasp-deploy ([f48f09b](https://github.com/graasp/graasp-player/commit/f48f09b3bb58bd5731be866dcb673fb7be147ae1))
Expand Down Expand Up @@ -347,7 +313,6 @@ All notable changes to this project will be documented in this file. See [standa
* update staging versions in graasp deploy ([d0ae758](https://github.com/graasp/graasp-player/commit/d0ae7586397f12cc3d03356be76583bd88fbda9e))
* visualize Collapse component ([#82](https://github.com/graasp/graasp-player/issues/82)) ([5b0efa8](https://github.com/graasp/graasp-player/commit/5b0efa855f7daa62eedf56ce7f6158e7ed1536eb))


### Bug Fixes

* add team id prefix ([dca002b](https://github.com/graasp/graasp-player/commit/dca002b3e92d2075e6668d802cba4a76917e6c74))
Expand All @@ -374,14 +339,12 @@ All notable changes to this project will be documented in this file. See [standa
* update yarn.lock ([6ed5125](https://github.com/graasp/graasp-player/commit/6ed5125f00f82c41f7791d43b03a76735447349a))
* wrong secret names ([1238711](https://github.com/graasp/graasp-player/commit/123871119915f251abe8504bd7eeec5bf2b5a7f6))


### Build System

* init commit ([37cf8b9](https://github.com/graasp/graasp-player/commit/37cf8b9db535b733abb0ea814ca2a15dfee83247))
* merge main, update dependencies ([8d61a1b](https://github.com/graasp/graasp-player/commit/8d61a1b6bba02932814d8d87c460b6cf5343b38c))
* update dependencies ([af2fc93](https://github.com/graasp/graasp-player/commit/af2fc93789eaba6e7105bda33cea4de9cc0dfccb))


### Tests

* add main layout tests ([7e70f52](https://github.com/graasp/graasp-player/commit/7e70f523adb571a3a4c7797810f4681e49f38cb7))
Expand All @@ -395,7 +358,6 @@ All notable changes to this project will be documented in this file. See [standa
* fix websocket tests, use 41/rollup on ui ([62ee09b](https://github.com/graasp/graasp-player/commit/62ee09b954b2db9f9d238baf2b9bf181b6df0a83))
* update tests to take into account display changes ([f28f61f](https://github.com/graasp/graasp-player/commit/f28f61fd79fc310018507dfef49f47d156b4a400))


### Continuous Integration

* fix tests in CI ([62a11de](https://github.com/graasp/graasp-player/commit/62a11dec4d2fca2b4a53eb36077d13c576e55ad9))
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
"@emotion/react": "11.11.1",
"@emotion/styled": "11.11.0",
"@graasp/chatbox": "3.0.0",
"@graasp/query-client": "2.0.3",
"@graasp/query-client": "2.1.0",
"@graasp/sdk": "3.3.0",
"@graasp/translations": "1.20.1",
"@graasp/translations": "1.21.0",
"@graasp/ui": "4.1.0",
"@mui/icons-material": "5.14.18",
"@mui/lab": "5.0.0-alpha.151",
Expand Down
11 changes: 9 additions & 2 deletions src/modules/common/ItemCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import CardActionArea from '@mui/material/CardActionArea';
import CardContent from '@mui/material/CardContent';
import Typography from '@mui/material/Typography';

import { DiscriminatedItem, ItemType } from '@graasp/sdk';
import { DiscriminatedItem, ItemType, Triggers } from '@graasp/sdk';
import { ItemIcon } from '@graasp/ui';

import { mutations } from '@/config/queryClient';

import { buildMainPath } from '../../config/paths';
import { HIDDEN_STYLE } from './HiddenWrapper';

Expand All @@ -24,9 +26,14 @@ const SimpleCard = ({ item, isHidden = false }: Props): JSX.Element => {
? item.extra
: undefined;

const { mutate: triggerAction } = mutations.usePostItemAction();
const handleCardClick = () => {
// trigger player Action for item view
triggerAction({ itemId: item.id, payload: { type: Triggers.ItemView } });
};
return (
<Card style={isHidden ? HIDDEN_STYLE : undefined}>
<CardActionArea component={Link} to={link}>
<CardActionArea component={Link} to={link} onClick={handleCardClick}>
<CardContent>
<Stack direction="row" alignItems="center">
<ItemIcon
Expand Down
22 changes: 20 additions & 2 deletions src/modules/item/Item.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Fragment, useEffect } from 'react';
import { Fragment, useCallback, useEffect } from 'react';
import { useInView } from 'react-intersection-observer';

import { Alert, Box, Container, Skeleton, Typography } from '@mui/material';
Expand All @@ -18,6 +18,7 @@ import {
PermissionLevel,
S3FileItemType,
ShortcutItemType,
Triggers,
} from '@graasp/sdk';
import { FAILURE_MESSAGES } from '@graasp/translations';
import {
Expand All @@ -40,7 +41,7 @@ import {
} from '@/config/constants';
import { API_HOST, H5P_INTEGRATION_URL } from '@/config/env';
import { useMessagesTranslation, usePlayerTranslation } from '@/config/i18n';
import { axios, hooks } from '@/config/queryClient';
import { axios, hooks, mutations } from '@/config/queryClient';
import {
FOLDER_NAME_TITLE_CLASS,
buildAppId,
Expand Down Expand Up @@ -121,6 +122,15 @@ const FileContent = ({ item }: FileContentProps) => {
isLoading: isFileContentLoading,
isError: isFileError,
} = useFileContentUrl(item.id);
const { mutate: triggerAction } = mutations.usePostItemAction();

const onDownloadClick = useCallback(() => {
triggerAction({
itemId: item.id,
payload: { type: Triggers.ItemDownload },
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [item.id]);

if (isFileContentLoading) {
return (
Expand All @@ -146,6 +156,7 @@ const FileContent = ({ item }: FileContentProps) => {
maxHeight={SCREEN_MAX_HEIGHT}
showCollapse={item.settings?.isCollapsible}
pdfViewerLink={PDF_VIEWER_LINK}
onClick={onDownloadClick}
/>
);

Expand All @@ -154,6 +165,12 @@ const FileContent = ({ item }: FileContentProps) => {

const LinkContent = ({ item }: { item: EmbeddedLinkItemType }): JSX.Element => {
const { data: member } = useCurrentMemberContext();

const { mutate: triggerAction } = mutations.usePostItemAction();
const handleLinkClick = () => {
// trigger player Action for link click
triggerAction({ itemId: item.id, payload: { type: Triggers.LinkOpen } });
};
const linkItem = (
<LinkItem
item={item}
Expand All @@ -163,6 +180,7 @@ const LinkContent = ({ item }: { item: EmbeddedLinkItemType }): JSX.Element => {
showButton={item.settings?.showLinkButton}
showIframe={item.settings?.showLinkIframe}
showCollapse={item.settings?.isCollapsible}
onClick={handleLinkClick}
/>
);

Expand Down
Loading

0 comments on commit bdd3a4a

Please sign in to comment.