Compare commits

..

2 Commits

Author SHA1 Message Date
sundasnoreen12
7f9ddda706 test: added test case for navigation bar api 2023-04-04 16:14:33 +05:00
ayesha waris
9b60c68b1d test: added test cases of navigation bar 2023-04-04 16:13:30 +05:00
15 changed files with 30 additions and 65 deletions

View File

@@ -24,7 +24,7 @@ function HTMLLoader({
function typeset(code) {
promise = promise.then(() => {
if (typeof window?.MathJax !== 'undefined' && typeof window?.MathJax.startup !== 'undefined') {
if (typeof window?.MathJax !== 'undefined') {
window.MathJax.startup.defaultPageReady().then((window.MathJax?.typesetPromise(code())));
}
return null;

View File

@@ -55,8 +55,6 @@ export const ContentActions = {
CHANGE_TOPIC: 'topic_id',
CHANGE_TYPE: 'type',
VOTE: 'voted',
ACCEPT_REVIEW: 'accept_review',
REJECT_REVIEW: 'reject_review',
};
/**

View File

@@ -75,7 +75,7 @@ function ActionsDropdown({
placement="bottom-end"
>
<div
className="bg-white shadow d-flex flex-column"
className="bg-white p-1 shadow d-flex flex-column"
data-testid="actions-dropdown-modal-popup"
>
{actions.map(action => (
@@ -91,15 +91,9 @@ function ActionsDropdown({
close();
handleActions(action.action);
}}
className="d-flex justify-content-start actions-dropdown-item"
className="d-flex justify-content-start py-1.5 mr-4"
>
<Icon
src={action.icon}
className="icon-size-24"
/>
<span className="font-weight-normal font-xl ml-2">
{intl.formatMessage(action.label)}
</span>
<Icon src={action.icon} className="mr-1" /> {intl.formatMessage(action.label)}
</Dropdown.Item>
</React.Fragment>
))}

View File

@@ -14,3 +14,7 @@ export const selectUsernameSearch = () => state => state.learners.usernameSearch
export const selectLearnerSorting = () => state => state.learners.sortedBy;
export const selectLearnerNextPage = () => state => state.learners.nextPage;
export const selectLearnerAvatar = author => state => (
state.learners.learnerProfiles[author]?.profileImage?.imageUrlLarge
);

View File

@@ -1,15 +1,20 @@
import React from 'react';
import { useSelector } from 'react-redux';
import { Avatar } from '@edx/paragon';
import { selectLearnerAvatar } from '../data/selectors';
import { learnerShape } from './proptypes';
function LearnerAvatar({ learner }) {
const learnerAvatar = useSelector(selectLearnerAvatar(learner.username));
return (
<div className="mr-3 mt-1">
<Avatar
size="sm"
alt={learner.username}
src={learnerAvatar}
style={{
height: '2rem',
width: '2rem',

View File

@@ -26,16 +26,6 @@ const messages = defineMessages({
defaultMessage: 'Unpin',
description: 'Action to unpin a post',
},
acceptReview: {
id: 'discussions.actions.reviewAccept',
defaultMessage: 'Accept',
description: 'Action to accept content flagged for review',
},
rejectReview: {
id: 'discussions.actions.reviewReject',
defaultMessage: 'Decline',
description: 'Action to reject content flagged for review',
},
deleteAction: {
id: 'discussions.actions.delete',
defaultMessage: 'Delete',

View File

@@ -1,6 +1,7 @@
import React from 'react';
import classNames from 'classnames';
import { useSelector } from 'react-redux';
import { injectIntl } from '@edx/frontend-platform/i18n';
import { Avatar } from '@edx/paragon';
@@ -8,11 +9,13 @@ import { Avatar } from '@edx/paragon';
import { AvatarOutlineAndLabelColors } from '../../../../data/constants';
import { AuthorLabel } from '../../../common';
import { useAlertBannerVisible } from '../../../data/hooks';
import { selectAuthorAvatars } from '../../../posts/data/selectors';
import { commentShape } from './proptypes';
function CommentHeader({
comment,
}) {
const authorAvatars = useSelector(selectAuthorAvatars(comment.author));
const colorClass = AvatarOutlineAndLabelColors[comment.authorLabel];
const hasAnyAlert = useAlertBannerVisible(comment);
@@ -25,6 +28,7 @@ function CommentHeader({
<Avatar
className={`border-0 ml-0.5 mr-2.5 ${colorClass ? `outline-${colorClass}` : 'outline-anonymous'}`}
alt={comment.author}
src={authorAvatars?.imageUrlSmall}
style={{
width: '32px',
height: '32px',

View File

@@ -1,7 +1,7 @@
import React, { useCallback, useMemo, useState } from 'react';
import PropTypes from 'prop-types';
import { useDispatch } from 'react-redux';
import { useDispatch, useSelector } from 'react-redux';
import * as timeago from 'timeago.js';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
@@ -14,6 +14,7 @@ import {
} from '../../../common';
import timeLocale from '../../../common/time-locale';
import { useAlertBannerVisible } from '../../../data/hooks';
import { selectAuthorAvatars } from '../../../posts/data/selectors';
import { editComment, removeComment } from '../../data/thunks';
import messages from '../../messages';
import CommentEditor from './CommentEditor';
@@ -59,6 +60,7 @@ function Reply({
[ContentActions.REPORT]: () => handleAbusedFlag(),
}), [dispatch, handleAbusedFlag, reply.endorsed, reply.id, showDeleteConfirmation]);
const authorAvatars = useSelector(selectAuthorAvatars(reply.author));
const colorClass = AvatarOutlineAndLabelColors[reply.authorLabel];
const hasAnyAlert = useAlertBannerVisible(reply);
@@ -99,6 +101,7 @@ function Reply({
<Avatar
className={`ml-0.5 mt-0.5 border-0 ${colorClass ? `outline-${colorClass}` : 'outline-anonymous'}`}
alt={reply.author}
src={authorAvatars?.imageUrlSmall}
style={{
width: '32px',
height: '32px',

View File

@@ -151,7 +151,6 @@ export async function updateThread(threadId, {
pinned,
editReasonCode,
closeReasonCode,
reviewStatus,
} = {}) {
const url = `${getThreadsApiUrl()}${threadId}/`;
const patchData = snakeCaseObject({
@@ -167,7 +166,6 @@ export async function updateThread(threadId, {
pinned,
editReasonCode,
closeReasonCode,
reviewStatus,
});
const { data } = await getAuthenticatedHttpClient()
.patch(url, patchData, { headers: { 'Content-Type': 'application/merge-patch+json' } });

View File

@@ -44,3 +44,7 @@ export const selectThreadSorting = () => state => state.threads.sortedBy;
export const selectThreadFilters = () => state => state.threads.filters;
export const selectThreadNextPage = () => state => state.threads.nextPage;
export const selectAuthorAvatars = author => state => (
state.threads.avatars?.[author]?.profile.image
);

View File

@@ -239,7 +239,6 @@ export function createNewThread({
export function updateExistingThread(threadId, {
flagged, voted, read, topicId, type, title, content, following, closed, pinned, closeReasonCode, editReasonCode,
reviewStatus,
}) {
return async (dispatch) => {
try {
@@ -257,7 +256,6 @@ export function updateExistingThread(threadId, {
pinned,
editReasonCode,
closeReasonCode,
reviewStatus,
}));
const data = await updateThread(threadId, {
flagged,
@@ -272,7 +270,6 @@ export function updateExistingThread(threadId, {
pinned,
editReasonCode,
closeReasonCode,
reviewStatus,
});
dispatch(updateThreadSuccess(camelCaseObject(data)));
} catch (error) {

View File

@@ -44,7 +44,6 @@ function Post({
const userHasModerationPrivileges = useSelector(selectUserHasModerationPrivileges);
const displayPostFooter = post.following || post.voteCount || post.closed
|| (post.groupId && userHasModerationPrivileges);
const displayReviewContentLabel = post.reviewStatus === "PENDING";
const handleAbusedFlag = useCallback(() => {
if (post.abuseFlagged) {
@@ -86,8 +85,6 @@ function Post({
[ContentActions.COPY_LINK]: () => { navigator.clipboard.writeText(`${window.location.origin}/${courseId}/posts/${post.id}`); },
[ContentActions.PIN]: () => dispatch(updateExistingThread(post.id, { pinned: !post.pinned })),
[ContentActions.REPORT]: () => handleAbusedFlag(),
[ContentActions.ACCEPT_REVIEW]: () => dispatch(updateExistingThread(post.id, { reviewStatus: "ACCEPTED" })),
[ContentActions.REJECT_REVIEW]: () => dispatch(updateExistingThread(post.id, { reviewStatus: "REJECTED" })),
}), [
showDeleteConfirmation,
history,
@@ -147,8 +144,6 @@ function Post({
/>
<AlertBanner content={post} />
<PostHeader post={post} />
{displayReviewContentLabel && <p style= {{ background: "yellow" }}> This content is under review </p>}
<div className="d-flex mt-14px text-break font-style text-primary-500">
<HTMLLoader htmlNode={post.renderedBody} componentId="post" cssClassName="html-loader" testId={post.id} />
</div>

View File

@@ -2,6 +2,7 @@ import React, { useMemo } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import { useSelector } from 'react-redux';
import { injectIntl, intlShape } from '@edx/frontend-platform/i18n';
import { Avatar, Badge, Icon } from '@edx/paragon';
@@ -10,12 +11,14 @@ import { Issue, Question } from '../../../components/icons';
import { AvatarOutlineAndLabelColors, ThreadType } from '../../../data/constants';
import { AuthorLabel } from '../../common';
import { useAlertBannerVisible } from '../../data/hooks';
import { selectAuthorAvatars } from '../data/selectors';
import messages from './messages';
import { postShape } from './proptypes';
export function PostAvatar({
post, authorLabel, fromPostLink, read,
}) {
const authorAvatars = useSelector(selectAuthorAvatars(post.author));
const outlineColor = AvatarOutlineAndLabelColors[authorLabel];
const avatarSize = useMemo(() => {
@@ -60,6 +63,7 @@ export function PostAvatar({
width: avatarSize,
}}
alt={post.author}
src={authorAvatars?.imageUrlSmall}
/>
</div>
);

View File

@@ -5,8 +5,7 @@ import { generatePath, useRouteMatch } from 'react-router';
import { getConfig } from '@edx/frontend-platform';
import {
CheckCircle, CheckCircleOutline, Close, Delete, Done,
Edit, Lock, LockOpen, Pin, Report, Verified, VerifiedOutline,
CheckCircle, CheckCircleOutline, Delete, Edit, Lock, LockOpen, Pin, Report, Verified, VerifiedOutline,
} from '@edx/paragon/icons';
import { InsertLink } from '../components/icons';
@@ -174,20 +173,6 @@ export const ACTIONS_LIST = [
label: messages.deleteAction,
conditions: { canDelete: true },
},
{
id: 'accept-review',
action: ContentActions.ACCEPT_REVIEW,
icon: Done,
label: messages.acceptReview,
conditions: { reviewStatus: 'PENDING' },
},
{
id: 'reject-review',
action: ContentActions.REJECT_REVIEW,
icon: Close,
label: messages.rejectReview,
conditions: { reviewStatus: 'PENDING' },
},
];
export function useActions(content) {

View File

@@ -502,19 +502,3 @@ header {
padding-left: 1rem;
}
}
.icon-size-24 {
width: 1.5rem;
height: 1.5rem;
}
.actions-dropdown-item {
padding: 12px 16px;
height: 48px;
width: 304px;
}
.font-xl {
font-size: 18px;
line-height: 28px;
}