diff --git a/.env b/.env index 2fa791447..273646442 100644 --- a/.env +++ b/.env @@ -20,6 +20,5 @@ SEGMENT_KEY='' SITE_NAME='' USER_INFO_COOKIE_NAME='' SUPPORT_URL='' -TA_FEEDBACK_FORM= '' -STAFF_FEEDBACK_FORM= '' -DISPLAY_FEEDBACK_BANNER='false' +LEARNER_FEEDBACK_URL='' +STAFF_FEEDBACK_URL='' diff --git a/.env.development b/.env.development index 3c85d691a..ae4b3cee5 100644 --- a/.env.development +++ b/.env.development @@ -21,6 +21,5 @@ SEGMENT_KEY='' SITE_NAME=localhost USER_INFO_COOKIE_NAME='edx-user-info' SUPPORT_URL='https://support.edx.org' -TA_FEEDBACK_FORM='https://learner-form.test' -STAFF_FEEDBACK_FORM='https://staff-form.test' -DISPLAY_FEEDBACK_BANNER='false' +LEARNER_FEEDBACK_URL='' +STAFF_FEEDBACK_URL='' diff --git a/.env.test b/.env.test index abbd6339f..84bc122cd 100644 --- a/.env.test +++ b/.env.test @@ -19,6 +19,5 @@ SEGMENT_KEY='' SITE_NAME='localhost' USER_INFO_COOKIE_NAME='edx-user-info' SUPPORT_URL='https://support.edx.org' -TA_FEEDBACK_FORM='https://learner-form.test' -STAFF_FEEDBACK_FORM='https://staff-form.test' -DISPLAY_FEEDBACK_BANNER='false' +LEARNER_FEEDBACK_URL='' +STAFF_FEEDBACK_URL='' diff --git a/.jest/setEnvVars.js b/.jest/setEnvVars.js deleted file mode 100644 index e31f19e60..000000000 --- a/.jest/setEnvVars.js +++ /dev/null @@ -1,2 +0,0 @@ -process.env.TA_FEEDBACK_FORM= 'https://learner-form.test'; -process.env.STAFF_FEEDBACK_FORM= 'https://staff-form.test'; \ No newline at end of file diff --git a/jest.config.js b/jest.config.js index fe3adf370..31737d3c3 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,9 +1,9 @@ const { createConfig } = require('@edx/frontend-build'); module.exports = createConfig('jest', { - // setupFilesAfterEnv is used after the jest environment has been loaded. In general this is what you want. + // setupFilesAfterEnv is used after the jest environment has been loaded. In general this is what you want. // If you want to add config BEFORE jest loads, use setupFiles instead. - setupFiles: ['/.jest/setEnvVars.js'], + setupFiles: ['/.env.test'], setupFilesAfterEnv: [ '/src/setupTest.js', ], diff --git a/src/discussions/discussions-home/DiscussionsHome.jsx b/src/discussions/discussions-home/DiscussionsHome.jsx index 9f667f6f4..31bb658fe 100644 --- a/src/discussions/discussions-home/DiscussionsHome.jsx +++ b/src/discussions/discussions-home/DiscussionsHome.jsx @@ -8,7 +8,6 @@ import { } from 'react-router'; import { LearningHeader as Header } from '@edx/frontend-component-header'; -import { getConfig } from '@edx/frontend-platform'; import { Spinner } from '../../components'; import { selectCourseTabs } from '../../components/NavigationBar/data/selectors'; @@ -33,7 +32,6 @@ const DiscussionsProductTour = lazy(() => import('../tours/DiscussionsProductTou const DiscussionsRestrictionBanner = lazy(() => import('./DiscussionsRestrictionBanner')); const DiscussionContent = lazy(() => import('./DiscussionContent')); const DiscussionSidebar = lazy(() => import('./DiscussionSidebar')); -const InformationBanner = lazy(() => import('./InformationBanner')); const DiscussionsHome = () => { const location = useLocation(); @@ -48,7 +46,6 @@ const DiscussionsHome = () => { const isOnDesktop = useIsOnDesktop(); let displaySidebar = useSidebarVisible(); const enableInContextSidebar = Boolean(new URLSearchParams(location.search).get('inContextSidebar') !== null); - const isFeedbackBannerVisible = getConfig().DISPLAY_FEEDBACK_BANNER === 'true'; const { courseId, postId, topicId, category, learnerUsername, } = params; @@ -95,7 +92,6 @@ const DiscussionsHome = () => { )} - {isFeedbackBannerVisible && } {provider === DiscussionProvider.LEGACY && ( diff --git a/src/discussions/discussions-home/FeedbackWrapper.jsx b/src/discussions/discussions-home/FeedbackWrapper.jsx index 74d668bb0..1627f869a 100644 --- a/src/discussions/discussions-home/FeedbackWrapper.jsx +++ b/src/discussions/discussions-home/FeedbackWrapper.jsx @@ -2,6 +2,7 @@ import { useEffect } from 'react'; import { useSelector } from 'react-redux'; +import { getConfig } from '@edx/frontend-platform'; import { logError } from '@edx/frontend-platform/logging'; import { RequestStatus } from '../../data/constants'; @@ -22,9 +23,9 @@ export default function useFeedbackWrapper() { useEffect(() => { if (configStatus === RequestStatus.SUCCESSFUL) { - let url = '//w.usabilla.com/9e6036348fa1.js'; + let url = getConfig().LEARNER_FEEDBACK_URL; if (isStaff || isUserGroupTA || isCourseAdmin || isCourseStaff) { - url = '//w.usabilla.com/767740a06856.js'; + url = getConfig().STAFF_FEEDBACK_URL; } try { // eslint-disable-next-line no-undef diff --git a/src/discussions/discussions-home/InformationBanner.jsx b/src/discussions/discussions-home/InformationBanner.jsx deleted file mode 100644 index 254a7a32a..000000000 --- a/src/discussions/discussions-home/InformationBanner.jsx +++ /dev/null @@ -1,63 +0,0 @@ -import React, { useCallback, useState } from 'react'; - -import { useSelector } from 'react-redux'; - -import { useIntl } from '@edx/frontend-platform/i18n'; -import { Hyperlink, PageBanner } from '@edx/paragon'; - -import { selectUserIsStaff, selectUserRoles } from '../data/selectors'; -import messages from '../messages'; - -const InformationBanner = () => { - const intl = useIntl(); - const [showBanner, setShowBanner] = useState(true); - const userRoles = useSelector(selectUserRoles); - const isAdmin = useSelector(selectUserIsStaff); - const learnMoreLink = 'https://openedx.atlassian.net/wiki/spaces/COMM/pages/3509551260/Overview+New+discussions+experience'; - const TAFeedbackLink = process.env.TA_FEEDBACK_FORM; - const staffFeedbackLink = process.env.STAFF_FEEDBACK_FORM; - const hideLearnMoreButton = ((userRoles.includes('Student') && userRoles.length === 1) || !userRoles.length) && !isAdmin; - const showStaffLink = isAdmin || userRoles.includes('Moderator') || userRoles.includes('Administrator'); - - const handleDismiss = useCallback(() => { - setShowBanner(false); - }, []); - - return ( - -
- {intl.formatMessage(messages.bannerMessage)} - {!hideLearnMoreButton - && ( - - {intl.formatMessage(messages.learnMoreBannerLink)} - - )} - - {intl.formatMessage(messages.shareFeedback)} - -
-
- ); -}; - -export default InformationBanner; diff --git a/src/discussions/discussions-home/InformationBanner.test.jsx b/src/discussions/discussions-home/InformationBanner.test.jsx deleted file mode 100644 index 05af082c3..000000000 --- a/src/discussions/discussions-home/InformationBanner.test.jsx +++ /dev/null @@ -1,136 +0,0 @@ -import { render, screen } from '@testing-library/react'; -import { IntlProvider } from 'react-intl'; - -import { initializeMockApp } from '@edx/frontend-platform'; -import { AppProvider } from '@edx/frontend-platform/react'; - -import { initializeStore } from '../../store'; -import { DiscussionContext } from '../common/context'; -import { fetchConfigSuccess } from '../data/slices'; -import messages from '../messages'; -import InformationBanner from './InformationBanner'; - -import '../posts/data/__factories__'; - -let store; -let container; -const courseId = 'course-v1:edX+DemoX+Demo_Course'; - -const getConfigData = (isAdmin = true, roles = []) => ({ - id: 'course-v1:edX+DemoX+Demo_Course', - userRoles: roles, - hasModerationPrivileges: false, - isGroupTa: false, - isUserAdmin: isAdmin, -}); - -function renderComponent() { - const wrapper = render( - - - - - - - , - ); - container = wrapper.container; - return container; -} - -describe('Information Banner learner view', () => { - let element; - beforeEach(async () => { - initializeMockApp({ - authenticatedUser: { - userId: 3, - username: 'abc123', - administrator: false, - roles: ['Student'], - }, - }); - store = initializeStore(); - store.dispatch(fetchConfigSuccess(getConfigData(false, ['Student']))); - renderComponent(true); - element = await screen.findByRole('alert'); - }); - - test('Test Banner is visible on app load', async () => { - expect(element).toHaveTextContent(messages.bannerMessage.defaultMessage); - }); - - test('Test Banner do not have learn more button', async () => { - expect(element).not.toHaveTextContent(messages.learnMoreBannerLink.defaultMessage); - }); - test('Test Banner has share feedback button', async () => { - expect(element).toHaveTextContent(messages.shareFeedback.defaultMessage); - }); -}); - -describe('Information Banner moderators/staff/admin view', () => { - let element; - beforeEach(async () => { - initializeMockApp({ - authenticatedUser: { - userId: 3, - username: 'abc123', - administrator: true, - roles: [], - }, - }); - - store = initializeStore(); - store.dispatch(fetchConfigSuccess(getConfigData(true, ['Student', 'Moderator']))); - renderComponent(true); - element = await screen.findByRole('alert'); - }); - - test('Test Banner is visible on app load', async () => { - expect(element).toHaveTextContent(messages.bannerMessage.defaultMessage); - }); - - test('Test Banner has learn more button', async () => { - expect(element).toHaveTextContent(messages.learnMoreBannerLink.defaultMessage); - }); - test('Test Banner has share feedback button', async () => { - expect(element).toHaveTextContent(messages.shareFeedback.defaultMessage); - }); -}); - -describe('User is redirected according to url according to role', () => { - beforeEach(async () => { - initializeMockApp({ - authenticatedUser: { - userId: 3, - username: 'abc123', - administrator: true, - roles: [], - }, - }); - store = initializeStore(); - }); - - test('TAs are redirected to learners feedback form', async () => { - store.dispatch(fetchConfigSuccess(getConfigData(false, ['Student', 'Community TA']))); - renderComponent(true); - expect(screen.getByText(messages.shareFeedback.defaultMessage) - .closest('a')) - .toHaveAttribute('href', process.env.TA_FEEDBACK_FORM); - }); - - test('moderators/administrators are redirected to moderators feedback form', async () => { - store.dispatch(fetchConfigSuccess(getConfigData(false, ['Student', 'Moderator', 'Administrator']))); - renderComponent(true); - expect(screen.getByText(messages.shareFeedback.defaultMessage) - .closest('a')) - .toHaveAttribute('href', process.env.STAFF_FEEDBACK_FORM); - }); - - test('user with only isAdmin true are redirected to moderators feedback form', async () => { - store.dispatch(fetchConfigSuccess(getConfigData(true, ['Student']))); - renderComponent(true); - expect(screen.getByText(messages.shareFeedback.defaultMessage) - .closest('a')) - .toHaveAttribute('href', process.env.STAFF_FEEDBACK_FORM); - }); -}); diff --git a/src/discussions/messages.js b/src/discussions/messages.js index a23276f2b..555f9df71 100644 --- a/src/discussions/messages.js +++ b/src/discussions/messages.js @@ -168,21 +168,6 @@ const messages = defineMessages({ defaultMessage: 'anonymous', description: 'Author name displayed when a post is anonymous', }, - bannerMessage: { - id: 'discussion.banner.welcomeMessage', - defaultMessage: '🎉 Welcome to the new and improved discussions experience!', - description: 'Information banner welcome text', - }, - learnMoreBannerLink: { - id: 'discussion.banner.learnMore', - defaultMessage: 'Learn more', - description: 'learn more button to redirect users to know more about new discussion experience ', - }, - shareFeedback: { - id: 'discussion.banner.shareFeedback', - defaultMessage: 'Share feedback', - description: 'Share feedback button to open feedback forms', - }, blackoutDiscussionInformation: { id: 'discussion.blackoutBanner.information', defaultMessage: 'Posting in discussions is disabled by the course team', diff --git a/src/index.jsx b/src/index.jsx index 37e917a77..8c5737b01 100755 --- a/src/index.jsx +++ b/src/index.jsx @@ -37,7 +37,8 @@ initialize({ config: () => { mergeConfig({ LEARNING_BASE_URL: process.env.LEARNING_BASE_URL, - DISPLAY_FEEDBACK_BANNER: process.env.DISPLAY_FEEDBACK_BANNER || 'false', + LEARNER_FEEDBACK_URL: process.env.LEARNER_FEEDBACK_URL, + STAFF_FEEDBACK_URL: process.env.STAFF_FEEDBACK_URL, }, 'DiscussionsConfig'); }, },