Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: openedx/frontend-app-discussions
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: e899784f30b7468106297b24346306fa4b686ca7
Choose a base ref
..
head repository: openedx/frontend-app-discussions
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 51aadf006797794271e2ef037e1b964cac051a7a
Choose a head ref
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -9,17 +9,16 @@ on:
jobs:
tests:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Nodejs Env
run: echo "NODE_VER=`cat .nvmrc`" >> $GITHUB_ENV
- name: Setup Nodejs
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VER }}
node-version-file: '.nvmrc'
- name: Install dependencies
run: npm ci
- name: Validate package-lock.json changes
2 changes: 1 addition & 1 deletion .github/workflows/lockfileversion-check.yml
Original file line number Diff line number Diff line change
@@ -10,4 +10,4 @@ on:

jobs:
version-check:
uses: openedx/.github/.github/workflows/lockfile-check.yml@master
uses: openedx/.github/.github/workflows/lockfileversion-check-v3.yml@master
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
20
1 change: 1 addition & 0 deletions catalog-info.yaml
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ metadata:
icon: "Web"
annotations:
openedx.org/arch-interest-groups: ""
openedx.org/release: "master"
spec:
owner: group:edx-infinity
type: 'website'
11 changes: 0 additions & 11 deletions openedx.yaml

This file was deleted.

21,030 changes: 10,231 additions & 10,799 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -34,8 +34,8 @@
},
"dependencies": {
"@edx/brand": "npm:@openedx/brand-openedx@^1.2.2",
"@edx/frontend-component-header": "^5.0.2",
"@edx/frontend-platform": "^7.1.0",
"@edx/frontend-component-header": "^5.6.0",
"@edx/frontend-platform": "8.0.0",
"@edx/openedx-atlas": "^0.6.0",
"@openedx/frontend-slot-footer": "^1.0.2",
"@openedx/paragon": "^22.1.1",
@@ -64,7 +64,7 @@
"devDependencies": {
"@edx/browserslist-config": "1.2.0",
"@edx/reactifex": "1.1.0",
"@openedx/frontend-build": "^13.0.28",
"@openedx/frontend-build": "^14.1.0",
"@testing-library/jest-dom": "5.17.0",
"@testing-library/react": "12.1.5",
"@testing-library/user-event": "13.5.0",
@@ -74,7 +74,7 @@
"eslint-plugin-simple-import-sort": "7.0.0",
"glob": "7.2.0",
"husky": "7.0.4",
"jest": "27.5.1",
"jest": "29.7.0",
"rosie": "2.1.1"
}
}
20 changes: 10 additions & 10 deletions run-build-for-gh-deps.sh
Original file line number Diff line number Diff line change
@@ -37,16 +37,16 @@ run_command "cd ../../.."
log "Current directory: $(pwd)"

# frontend-build
log "Processing frontend-build"
run_command "cd node_modules/@openedx/" || exit
log "Current directory: $(pwd)"
run_command "rm -rf frontend-build"
run_command "git clone -b dcoa/design-tokens-support --single-branch https://github.com/eduNEXT/frontend-build.git"
run_command "cd frontend-build" || exit
log "Current directory: $(pwd)"
run_command "npm ci"
run_command "cd ../../.." || exit
log "Current directory: $(pwd)"
# log "Processing frontend-build"
# run_command "cd node_modules/@openedx/" || exit
# log "Current directory: $(pwd)"
# run_command "rm -rf frontend-build"
# run_command "git clone -b dcoa/design-tokens-support --single-branch https://github.com/eduNEXT/frontend-build.git"
# run_command "cd frontend-build" || exit
# log "Current directory: $(pwd)"
# run_command "npm ci"
# run_command "cd ../../.." || exit
# log "Current directory: $(pwd)"

# # paragon
# log "Processing paragon"
74 changes: 74 additions & 0 deletions src/components/PostHelpPanel.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import React, { useState } from 'react';

import {
Hyperlink, Icon, IconButton, IconButtonWithTooltip,
} from '@openedx/paragon';
import { Close, HelpOutline } from '@openedx/paragon/icons';

import { useIntl } from '@edx/frontend-platform/i18n';

import messages from '../discussions/posts/post-editor/messages';

const PostHelpPanel = () => {
const intl = useIntl();
const [showHelpPane, setShowHelpPane] = useState(false);

return (
<>
<div className="d-flex justify-content-end">
<IconButtonWithTooltip
onClick={() => setShowHelpPane(true)}
alt={intl.formatMessage(messages.showHelpIcon)}
tooltipContent={<div>{intl.formatMessage(messages.discussionHelpTooltip)}</div>}
src={HelpOutline}
iconAs={Icon}
size="inline"
className="float-right p-3 help-icon"
iconClassNames="help-icon-size"
data-testid="help-button"
invertColors
isActive
/>
</div>
{showHelpPane && (
<div
className="w-100 p-2 bg-light-200 rounded box-shadow-down-1 post-preview overflow-auto my-3"
style={{ minHeight: '200px', wordBreak: 'break-word' }}
>
<IconButton
onClick={() => setShowHelpPane(false)}
alt={intl.formatMessage(messages.actionsAlt)}
src={Close}
iconAs={Icon}
size="inline"
className="float-right p-3"
iconClassNames="icon-size"
data-testid="hide-help-button"
/>
<div className="pt-2 px-3">
<h4 className="font-weight-bold">{intl.formatMessage(messages.discussionHelpHeader)}</h4>
<p className="pt-2">{intl.formatMessage(messages.discussionHelpDescription)}</p>
<Hyperlink
target="_blank"
className="w-100"
destination="https://support.edx.org/hc/en-us/sections/115004169687-Participating-in-Course-Discussions"
showLaunchIcon={false}
>
{intl.formatMessage(messages.discussionHelpCourseParticipation)}
</Hyperlink>
<Hyperlink
target="_blank"
className="w-100"
destination="https://support.edx.org/hc/en-us/articles/360000035267-Entering-math-expressions-in-course-discussions"
showLaunchIcon={false}
>
{intl.formatMessage(messages.discussionHelpMathExpressions)}
</Hyperlink>
</div>
</div>
)}
</>
);
};

export default React.memo(PostHelpPanel);
8 changes: 1 addition & 7 deletions src/discussions/data/hooks.js
Original file line number Diff line number Diff line change
@@ -33,14 +33,11 @@ import { ContentSelectors } from './constants';
import {
selectAreThreadsFiltered,
selectEnableInContext,
selectIsCourseAdmin,
selectIsCourseStaff,
selectIsPostingEnabled,
selectIsUserLearner,
selectPostThreadCount,
selectUserHasModerationPrivileges,
selectUserIsGroupTa,
selectUserIsStaff,
} from './selectors';
import fetchCourseConfig from './thunks';

@@ -220,12 +217,9 @@ export const useCurrentDiscussionTopic = () => {

export const useUserPostingEnabled = () => {
const isPostingEnabled = useSelector(selectIsPostingEnabled);
const isUserAdmin = useSelector(selectUserIsStaff);
const userHasModerationPrivileges = useSelector(selectUserHasModerationPrivileges);
const isUserGroupTA = useSelector(selectUserIsGroupTa);
const isCourseAdmin = useSelector(selectIsCourseAdmin);
const isCourseStaff = useSelector(selectIsCourseStaff);
const isPrivileged = isUserAdmin || userHasModerationPrivileges || isUserGroupTA || isCourseAdmin || isCourseStaff;
const isPrivileged = userHasModerationPrivileges || isUserGroupTA;

return (isPostingEnabled || isPrivileged);
};
8 changes: 4 additions & 4 deletions src/discussions/data/hooks.test.jsx
Original file line number Diff line number Diff line change
@@ -19,11 +19,11 @@ const courseConfigApiUrl = getCourseConfigApiUrl();
let store;
let axiosMock;

const generateApiResponse = (isPostingEnabled, isCourseAdmin = false) => ({
const generateApiResponse = (isPostingEnabled, hasModerationPrivileges = false) => ({
isPostingEnabled,
hasModerationPrivileges: false,
hasModerationPrivileges,
isGroupTa: false,
isCourseAdmin,
isCourseAdmin: false,
isCourseStaff: false,
isUserAdmin: false,
});
@@ -160,7 +160,7 @@ describe('Hooks', () => {
expect(queryByText('false')).toBeInTheDocument();
});

test('when posting is not disabled and Role is not Learner return true', async () => {
test('when posting is disabled and Role is not Learner return true', async () => {
axiosMock.onGet(`${courseConfigApiUrl}${courseId}/`)
.reply(200, generateApiResponse(false, true));
await executeThunk(fetchCourseConfig(courseId), store.dispatch, store.getState);
2 changes: 1 addition & 1 deletion src/discussions/post-comments/comments/comment/Reply.jsx
Original file line number Diff line number Diff line change
@@ -129,7 +129,7 @@ const Reply = ({ responseId }) => {
</div>
<div
className="bg-light-300 pl-4 pt-2.5 pr-2.5 pb-10px flex-fill"
style={{ borderRadius: '0rem 0.375rem 0.375rem' }}
style={{ borderRadius: '0rem 0.375rem 0.375rem', maxWidth: 'calc(100% - 50px)' }}
>
<div className="d-flex flex-row justify-content-between">
<AuthorLabel
2 changes: 2 additions & 0 deletions src/discussions/posts/post-editor/PostEditor.jsx
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ import { AppContext } from '@edx/frontend-platform/react';

import { TinyMCEEditor } from '../../../components';
import FormikErrorFeedback from '../../../components/FormikErrorFeedback';
import PostHelpPanel from '../../../components/PostHelpPanel';
import PostPreviewPanel from '../../../components/PostPreviewPanel';
import useDispatchWithState from '../../../data/hooks';
import selectCourseCohorts from '../../cohorts/data/selectors';
@@ -409,6 +410,7 @@ const PostEditor = ({
onEditorChange={formikCompatibleHandler(handleChange, 'comment')}
onBlur={formikCompatibleHandler(handleBlur, 'comment')}
/>
<PostHelpPanel />
<FormikErrorFeedback name="comment" />
</div>
<PostPreviewPanel htmlNode={values.comment} isPost editExisting={editExisting} />
29 changes: 29 additions & 0 deletions src/discussions/posts/post-editor/PostEditor.test.jsx
Original file line number Diff line number Diff line change
@@ -368,5 +368,34 @@ describe('PostEditor', () => {
expect(container.querySelector('[data-testid="hide-preview-button"]')).not.toBeInTheDocument();
});
});

it('should show Help Panel', async () => {
await renderComponent(true, `/${courseId}/posts/${threadId}/edit`);

await act(async () => {
fireEvent.click(container.querySelector('[data-testid="help-button"]'));
});

await waitFor(() => {
expect(container.querySelector('[data-testid="hide-help-button"]')).toBeInTheDocument();
});
});

it('should hide Help Panel', async () => {
await renderComponent(true, `/${courseId}/posts/${threadId}/edit`);

await act(async () => {
fireEvent.click(container.querySelector('[data-testid="help-button"]'));
});

await act(async () => {
fireEvent.click(container.querySelector('[data-testid="hide-help-button"]'));
});

await waitFor(() => {
expect(container.querySelector('[data-testid="help-button"]')).toBeInTheDocument();
expect(container.querySelector('[data-testid="hide-help-button"]')).not.toBeInTheDocument();
});
});
});
});
30 changes: 30 additions & 0 deletions src/discussions/posts/post-editor/messages.js
Original file line number Diff line number Diff line change
@@ -116,6 +116,36 @@ const messages = defineMessages({
defaultMessage: 'Show preview',
description: 'show preview button text to allow user to see their post content.',
},
showHelpIcon: {
id: 'discussions.editor.posts.showHelp.icon',
defaultMessage: 'Show Help',
description: 'show help icon to allow user to see important documentation.',
},
discussionHelpHeader: {
id: 'discussions.editor.posts.discussionHelpHeader',
defaultMessage: 'Discussions help',
description: 'header text for post help section.',
},
discussionHelpDescription: {
id: 'discussions.editor.posts.discussionHelpDescription',
defaultMessage: 'Course discussions give you the opportunity to start conversations, ask questions, and interact with other learners. See the links below to learn more:',
description: 'description message for post help section.',
},
discussionHelpCourseParticipation: {
id: 'discussions.editor.posts.discussionHelpCourseParticipation',
defaultMessage: 'Participating in course discussions',
description: 'Documentation link title for participating in course discussions.',
},
discussionHelpMathExpressions: {
id: 'discussions.editor.posts.discussionHelpMathExpressions',
defaultMessage: 'Entering math expressions in course discussions',
description: 'Documentation link title for entering math expressions in course discussions.',
},
discussionHelpTooltip: {
id: 'discussions.editor.posts.discussionHelpTooltip',
defaultMessage: 'Learn more about MathJax & LaTeX',
description: 'Tooltip help message for documentation help.',
},
actionsAlt: {
id: 'discussions.actions.label',
defaultMessage: 'Actions menu',
18 changes: 15 additions & 3 deletions src/index.scss
Original file line number Diff line number Diff line change
@@ -593,6 +593,15 @@ th, td {
white-space: nowrap;
}

.help-icon {
margin: -47px -3px 0px 0px;
}

.help-icon-size {
height: 16px !important;
width: 16px !important;
}

@media only screen and (max-width: 367px) {

.discussion-comments h5,
@@ -603,7 +612,8 @@ th, td {
.pgn__modal,
.pgn__form-label,
.dropdown-menu,
.tox-tbtn {
.tox-tbtn,
.tooltip {
font-size: 10px !important;
}

@@ -640,7 +650,8 @@ th, td {
.pgn__form-label,
.pgn__modal,
.dropdown-menu,
.tox-tbtn {
.tox-tbtn,
.tooltip {
font-size: 12px !important;
}

@@ -659,7 +670,8 @@ th, td {
@media only screen and (min-width: 769px) {

body,
#main {
#main,
.tooltip {
font-size: 14px;
}
}