From 000ad2ea9e8be293c2ca966e8e3359f77a28bce7 Mon Sep 17 00:00:00 2001 From: Kim Lan Phan Hoang Date: Fri, 11 Aug 2023 11:43:55 +0200 Subject: [PATCH] feat: enable analytics panel (#736) * feat: enable analytics panel * refactor: returns to home for builder icon --- .github/workflows/deploy-dev.yml | 1 + .github/workflows/deploy-prod.yml | 1 + .github/workflows/deploy-stage.yml | 1 + cypress/e2e/item/analytics/analytics.cy.ts | 26 ---------- package.json | 4 +- .../common/AnalyticsDashboardButton.tsx | 48 ------------------- src/components/item/ItemContent.tsx | 3 +- .../item/header/ItemHeaderActions.tsx | 2 - src/components/main/GraaspAnalyzer.tsx | 44 ----------------- src/components/main/ItemScreen.tsx | 4 -- src/components/main/Main.tsx | 5 +- src/config/constants.ts | 1 - src/config/env.ts | 1 + src/config/externalPaths.ts | 2 +- src/config/selectors.ts | 2 - src/enums/index.ts | 1 - src/env.d.ts | 1 + vite.config.ts | 3 -- yarn.lock | 21 +++++--- 19 files changed, 28 insertions(+), 143 deletions(-) delete mode 100644 cypress/e2e/item/analytics/analytics.cy.ts delete mode 100644 src/components/common/AnalyticsDashboardButton.tsx delete mode 100644 src/components/main/GraaspAnalyzer.tsx diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 66a51151d..d37254c77 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -33,6 +33,7 @@ jobs: VITE_GRAASP_LIBRARY_HOST: ${{ vars.VITE_GRAASP_LIBRARY_HOST }} VITE_GRAASP_ANALYZER_HOST: ${{ vars.VITE_GRAASP_ANALYZER_HOST }} VITE_H5P_INTEGRATION_URL: ${{ secrets.VITE_H5P_INTEGRATION_URL }} + VITE_GRAASP_ASSETS_URL: ${{ secrets.VITE_GRAASP_ASSETS_URL }} VITE_SENTRY_ENV: ${{ vars.VITE_SENTRY_ENV }} VITE_SENTRY_DSN: ${{ secrets.VITE_SENTRY_DSN }} # VITE_GA_MEASUREMENT_ID: ${{ secrets.VITE_GA_MEASUREMENT_ID }} diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml index 915e2f787..b01ed15d1 100644 --- a/.github/workflows/deploy-prod.yml +++ b/.github/workflows/deploy-prod.yml @@ -36,6 +36,7 @@ jobs: VITE_GRAASP_LIBRARY_HOST: ${{ vars.VITE_GRAASP_LIBRARY_HOST }} VITE_GRAASP_ANALYZER_HOST: ${{ vars.VITE_GRAASP_ANALYZER_HOST }} VITE_H5P_INTEGRATION_URL: ${{ secrets.VITE_H5P_INTEGRATION_URL }} + VITE_GRAASP_ASSETS_URL: ${{ secrets.VITE_GRAASP_ASSETS_URL }} VITE_SENTRY_ENV: ${{ vars.VITE_SENTRY_ENV }} VITE_SENTRY_DSN: ${{ secrets.VITE_SENTRY_DSN }} VITE_GA_MEASUREMENT_ID: ${{ secrets.VITE_GA_MEASUREMENT_ID }} diff --git a/.github/workflows/deploy-stage.yml b/.github/workflows/deploy-stage.yml index a813e6b2a..bcdcd3b98 100644 --- a/.github/workflows/deploy-stage.yml +++ b/.github/workflows/deploy-stage.yml @@ -36,6 +36,7 @@ jobs: VITE_GRAASP_LIBRARY_HOST: ${{ vars.VITE_GRAASP_LIBRARY_HOST }} VITE_GRAASP_ANALYZER_HOST: ${{ vars.VITE_GRAASP_ANALYZER_HOST }} VITE_H5P_INTEGRATION_URL: ${{ secrets.VITE_H5P_INTEGRATION_URL }} + VITE_GRAASP_ASSETS_URL: ${{ secrets.VITE_GRAASP_ASSETS_URL }} VITE_SENTRY_ENV: ${{ vars.VITE_SENTRY_ENV }} VITE_SENTRY_DSN: ${{ secrets.VITE_SENTRY_DSN }} # un-comment to enable Google Analytics diff --git a/cypress/e2e/item/analytics/analytics.cy.ts b/cypress/e2e/item/analytics/analytics.cy.ts deleted file mode 100644 index 82f7d2865..000000000 --- a/cypress/e2e/item/analytics/analytics.cy.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { buildItemPath } from '../../../../src/config/paths'; -import { - buildDashboardButtonId, - buildGraaspAnalyzerId, -} from '../../../../src/config/selectors'; -import { SAMPLE_ITEMS } from '../../../fixtures/items'; - -const openAnalyticsDashboard = (itemId: string) => { - cy.get(`#${buildDashboardButtonId(itemId)}`).click(); -}; - -describe('Analytics Scenarios', () => { - it('Send messages in chatbox', () => { - const { id } = SAMPLE_ITEMS.items[0]; - cy.setUpApi(SAMPLE_ITEMS); - cy.visit(buildItemPath(id)); - - // open dashboard - openAnalyticsDashboard(id); - cy.get(`#${buildGraaspAnalyzerId(id)}`) - .should('be.visible') - .then((el) => { - expect(el.attr('src')).to.contain(id); - }); - }); -}); diff --git a/package.json b/package.json index f8bdbdc51..e300b1f04 100644 --- a/package.json +++ b/package.json @@ -13,13 +13,14 @@ "node": ">=16" }, "dependencies": { + "@emotion/cache": "11.11.0", "@emotion/react": "11.11.1", "@emotion/styled": "11.11.0", "@graasp/chatbox": "2.0.0", "@graasp/query-client": "1.3.2", "@graasp/sdk": "1.2.0", "@graasp/translations": "1.18.1", - "@graasp/ui": "3.3.0", + "@graasp/ui": "3.3.1", "@mui/icons-material": "5.14.3", "@mui/lab": "5.0.0-alpha.138", "@mui/material": "5.14.4", @@ -58,6 +59,7 @@ "react-router": "6.14.2", "react-router-dom": "6.14.2", "react-toastify": "9.1.3", + "stylis": "4.3.0", "stylis-plugin-rtl": "2.1.1", "uuid": "9.0.0", "validator": "13.11.0" diff --git a/src/components/common/AnalyticsDashboardButton.tsx b/src/components/common/AnalyticsDashboardButton.tsx deleted file mode 100644 index c76806c03..000000000 --- a/src/components/common/AnalyticsDashboardButton.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import CloseIcon from '@mui/icons-material/Close'; -import PieChartIcon from '@mui/icons-material/PieChart'; -import IconButton from '@mui/material/IconButton'; -import Tooltip from '@mui/material/Tooltip'; - -import { BUILDER } from '@graasp/translations'; - -import { useBuilderTranslation } from '../../config/i18n'; -import { buildDashboardButtonId } from '../../config/selectors'; -import { ItemActionTabs } from '../../enums'; -import { useLayoutContext } from '../context/LayoutContext'; - -type Props = { - id: string; -}; - -const AnalyticsDashboardButton = ({ id }: Props): JSX.Element => { - const { t: translateBuilder } = useBuilderTranslation(); - const { openedActionTabId, setOpenedActionTabId } = useLayoutContext(); - - const onClick = () => { - setOpenedActionTabId( - openedActionTabId === ItemActionTabs.Dashboard - ? null - : ItemActionTabs.Dashboard, - ); - }; - - return ( - - - - {openedActionTabId === ItemActionTabs.Dashboard ? ( - - ) : ( - - )} - - - - ); -}; - -export default AnalyticsDashboardButton; diff --git a/src/components/item/ItemContent.tsx b/src/components/item/ItemContent.tsx index 95f9304d6..340c7e47b 100644 --- a/src/components/item/ItemContent.tsx +++ b/src/components/item/ItemContent.tsx @@ -39,12 +39,11 @@ import { import { List } from 'immutable'; -import { API_HOST, H5P_INTEGRATION_URL } from '@/config/env'; +import { API_HOST, GRAASP_ASSETS_URL, H5P_INTEGRATION_URL } from '@/config/env'; import { DEFAULT_LINK_SHOW_BUTTON, DEFAULT_LINK_SHOW_IFRAME, - GRAASP_ASSETS_URL, ITEM_DEFAULT_HEIGHT, } from '../../config/constants'; import { useCommonTranslation } from '../../config/i18n'; diff --git a/src/components/item/header/ItemHeaderActions.tsx b/src/components/item/header/ItemHeaderActions.tsx index 80fac2c65..3d748c4fb 100644 --- a/src/components/item/header/ItemHeaderActions.tsx +++ b/src/components/item/header/ItemHeaderActions.tsx @@ -14,7 +14,6 @@ import { getHighestPermissionForMemberFromMemberships, isItemUpdateAllowedForUser, } from '../../../utils/membership'; -import AnalyticsDashboardButton from '../../common/AnalyticsDashboardButton'; import EditItemCaptionButton from '../../common/EditItemCaptionButton'; import ItemMetadataButton from '../../common/ItemMetadataButton'; import PublishButton from '../../common/PublishButton'; @@ -78,7 +77,6 @@ const ItemHeaderActions = ({ item }: Props): JSX.Element => { onClick={onClickChatbox} /> {canAdmin && } - {canEdit && } ); diff --git a/src/components/main/GraaspAnalyzer.tsx b/src/components/main/GraaspAnalyzer.tsx deleted file mode 100644 index 6485c3612..000000000 --- a/src/components/main/GraaspAnalyzer.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import { useEffect } from 'react'; - -import { Context } from '@graasp/sdk'; -import { ItemRecord } from '@graasp/sdk/frontend'; - -import { buildGraaspAnalyzerLink } from '@/config/externalPaths'; - -import { DEFAULT_ANALYZER_HEIGHT } from '../../config/constants'; -import { useEnumsTranslation } from '../../config/i18n'; -import { buildGraaspAnalyzerId } from '../../config/selectors'; -import { useLayoutContext } from '../context/LayoutContext'; - -type Props = { - item: ItemRecord; -}; - -// todo: use as component -const GraaspAnalyzer = ({ item }: Props): JSX.Element => { - const { t } = useEnumsTranslation(); - const { setOpenedActionTabId } = useLayoutContext(); - const { id } = item; - - // close tab on unmount - useEffect( - () => () => { - setOpenedActionTabId(null); - }, - // eslint-disable-next-line react-hooks/exhaustive-deps - [], - ); - - return ( -