Skip to content

Commit

Permalink
chore: removed deprecated flag
Browse files Browse the repository at this point in the history
  • Loading branch information
AhtishamShahid committed Dec 1, 2023
1 parent a479f5a commit d57726e
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 42 deletions.
3 changes: 1 addition & 2 deletions src/discussions/common/AlertBanner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const AlertBanner = ({
const userHasModerationPrivileges = useSelector(selectUserHasModerationPrivileges);
const userIsGroupTa = useSelector(selectUserIsGroupTa);
const userIsGlobalStaff = useSelector(selectUserIsStaff);
const { reasonCodesEnabled } = useSelector(selectModerationSettings);
const userIsContentAuthor = getAuthenticatedUser().username === author;
const canSeeReportedBanner = abuseFlagged;
const canSeeLastEditOrClosedAlert = (userHasModerationPrivileges || userIsGroupTa
Expand All @@ -45,7 +44,7 @@ const AlertBanner = ({
{intl.formatMessage(messages.abuseFlaggedMessage)}
</Alert>
)}
{reasonCodesEnabled && canSeeLastEditOrClosedAlert && (
{ canSeeLastEditOrClosedAlert && (
<>
{lastEdit?.reason && (
<AlertBar
Expand Down
1 change: 0 additions & 1 deletion src/discussions/common/AlertBanner.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ describe.each([
store = initializeStore({
config: {
hasModerationPrivileges: true,
reasonCodesEnabled: true,
},
});
const content = buildTestContent(type, props);
Expand Down
1 change: 0 additions & 1 deletion src/discussions/common/EndorsedAlertBanner.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ describe.each([
store = initializeStore({
config: {
hasModerationPrivileges: true,
reasonCodesEnabled: true,
},
});
const content = buildTestContent(type, props);
Expand Down
3 changes: 1 addition & 2 deletions src/discussions/data/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,12 @@ export const useAlertBannerVisible = (
) => {
const userHasModerationPrivileges = useSelector(selectUserHasModerationPrivileges);
const userIsGroupTa = useSelector(selectUserIsGroupTa);
const { reasonCodesEnabled } = useSelector(selectModerationSettings);
const userIsContentAuthor = getAuthenticatedUser().username === author;
const canSeeLastEditOrClosedAlert = (userHasModerationPrivileges || userIsContentAuthor || userIsGroupTa);
const canSeeReportedBanner = abuseFlagged;

return (
(reasonCodesEnabled && canSeeLastEditOrClosedAlert && (lastEdit?.reason || closed)) || (canSeeReportedBanner)
(canSeeLastEditOrClosedAlert && (lastEdit?.reason || closed)) || (canSeeReportedBanner)
);
};

Expand Down
1 change: 0 additions & 1 deletion src/discussions/data/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export const selectIsPostingEnabled = state => state.config.isPostingEnabled;
export const selectModerationSettings = state => ({
postCloseReasons: state.config.postCloseReasons,
editReasons: state.config.editReasons,
reasonCodesEnabled: state.config.reasonCodesEnabled,
});

export const selectDiscussionProvider = state => state.config.provider;
Expand Down
1 change: 0 additions & 1 deletion src/discussions/data/slices.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const configSlice = createSlice({
dividedInlineDiscussions: [],
dividedCourseWideDiscussions: [],
},
reasonCodesEnabled: false,
editReasons: [],
postCloseReasons: [],
enableInContext: false,
Expand Down
26 changes: 3 additions & 23 deletions src/discussions/post-comments/PostCommentsView.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,10 @@ async function getThreadAPIResponse(attr = null) {
await executeThunk(fetchThread(discussionPostId), store.dispatch, store.getState);
}

async function setupCourseConfig(reasonCodesEnabled = true) {
async function setupCourseConfig() {
axiosMock.onGet(`${courseConfigApiUrl}${courseId}/`).reply(200, {
has_moderation_privileges: true,
isPostingEnabled: true,
reason_codes_enabled: reasonCodesEnabled,
editReasons: [
{ code: 'reason-1', label: 'reason 1' },
{ code: 'reason-2', label: 'reason 2' },
Expand Down Expand Up @@ -392,29 +391,10 @@ describe('ThreadView', () => {
assertLastUpdateData({ edit_reason_code: 'reason-1' });
});

it('should close the post directly if reason codes are not enabled', async () => {
await setupCourseConfig(false);
await waitFor(() => renderComponent(discussionPostId));

const post = await screen.findByTestId('post-thread-1');
const hoverCard = within(post).getByTestId('hover-card-thread-1');
await act(async () => {
fireEvent.click(
within(hoverCard).getByRole('button', { name: /actions menu/i }),
);
});
expect(screen.queryByRole('dialog', { name: /close post/i })).not.toBeInTheDocument();
await act(async () => {
fireEvent.click(screen.getByRole('button', { name: /close/i }));
});
expect(screen.queryByRole('dialog', { name: /close post/i })).not.toBeInTheDocument();
assertLastUpdateData({ closed: true });
});

it.each([true, false])(
'should reopen the post directly when reason codes enabled=%s',
async (reasonCodesEnabled) => {
await setupCourseConfig(reasonCodesEnabled);
async () => {
await setupCourseConfig();
renderComponent(closedPostId);

const post = screen.getByTestId('post-thread-2');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ const CommentEditor = ({
const userHasModerationPrivileges = useSelector(selectUserHasModerationPrivileges);
const userIsGroupTa = useSelector(selectUserIsGroupTa);
const userIsStaff = useSelector(selectUserIsStaff);
const { reasonCodesEnabled, editReasons } = useSelector(selectModerationSettings);
const { editReasons } = useSelector(selectModerationSettings);
const [submitting, dispatch] = useDispatchWithState();

const canDisplayEditReason = (reasonCodesEnabled && edit
const canDisplayEditReason = (edit
&& (userHasModerationPrivileges || userIsGroupTa || userIsStaff)
&& author !== authenticatedUser.username
);
Expand Down
4 changes: 2 additions & 2 deletions src/discussions/posts/post-editor/PostEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ const PostEditor = ({
const userIsGroupTa = useSelector(selectUserIsGroupTa);
const settings = useSelector(selectDivisionSettings);
const { allowAnonymous, allowAnonymousToPeers } = useSelector(selectAnonymousPostingConfig);
const { reasonCodesEnabled, editReasons } = useSelector(selectModerationSettings);
const { editReasons } = useSelector(selectModerationSettings);
const userIsStaff = useSelector(selectUserIsStaff);
const archivedTopics = useSelector(selectArchivedTopics);
const postEditorId = `post-editor-${editExisting ? postId : 'new'}`;

const canDisplayEditReason = (reasonCodesEnabled && editExisting
const canDisplayEditReason = (editExisting
&& (userHasModerationPrivileges || userIsGroupTa || userIsStaff)
&& post?.author !== authenticatedUser.username
);
Expand Down
1 change: 0 additions & 1 deletion src/discussions/posts/post-editor/PostEditor.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ describe('PostEditor', () => {
config: {
provider: 'legacy',
hasModerationPrivileges: true,
reasonCodesEnabled: true,
editReasons: [
{
code: 'reason-1',
Expand Down
9 changes: 3 additions & 6 deletions src/discussions/posts/post/Post.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { AlertBanner, Confirmation } from '../../common';
import { DiscussionContext } from '../../common/context';
import HoverCard from '../../common/HoverCard';
import { ContentTypes } from '../../data/constants';
import { selectModerationSettings, selectUserHasModerationPrivileges } from '../../data/selectors';
import { selectUserHasModerationPrivileges } from '../../data/selectors';
import { selectTopic } from '../../topics/data/selectors';
import { selectThread } from '../data/selectors';
import { removeThread, updateExistingThread } from '../data/thunks';
Expand All @@ -41,7 +41,6 @@ const Post = ({ handleAddResponseButton }) => {
const topic = useSelector(selectTopic(topicId));
const getTopicSubsection = useSelector(selectorForUnitSubsection);
const topicContext = useSelector(selectTopicContext(topicId));
const { reasonCodesEnabled } = useSelector(selectModerationSettings);
const [isDeleting, showDeleteConfirmation, hideDeleteConfirmation] = useToggle(false);
const [isReporting, showReportConfirmation, hideReportConfirmation] = useToggle(false);
const [isClosing, showClosePostModal, hideClosePostModal] = useToggle(false);
Expand Down Expand Up @@ -70,12 +69,10 @@ const Post = ({ handleAddResponseButton }) => {
const handlePostClose = useCallback(() => {
if (closed) {
dispatch(updateExistingThread(postId, { closed: false }));
} else if (reasonCodesEnabled) {
showClosePostModal();
} else {
dispatch(updateExistingThread(postId, { closed: true }));
showClosePostModal();
}
}, [closed, postId, reasonCodesEnabled, showClosePostModal]);
}, [closed, postId, showClosePostModal]);

const handlePostCopyLink = useCallback(() => {
const postURL = new URL(`${getConfig().PUBLIC_PATH}${courseId}/posts/${postId}`, window.location.origin);
Expand Down

0 comments on commit d57726e

Please sign in to comment.