Skip to content

Commit

Permalink
Drop feature flag
Browse files Browse the repository at this point in the history
Signed-off-by: Tushar Goel <tushar.goel.dav@gmail.com>
  • Loading branch information
TG1999 committed Apr 18, 2024
1 parent 833e7ff commit 9a1be24
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 38 deletions.
9 changes: 2 additions & 7 deletions __tests__/Unit/Components/Issues/TaskRequestForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,9 @@ describe('TaskRequestForm Component', () => {
const futureDay = date.getDate().toString().padStart(2, '0');
const sevenDaysFromToday = `${futureYear}-${futureMonth}-${futureDay}`;

test('renders markdown editor with feature flag on', async () => {
test('renders markdown editor', async () => {
const createTaskRequestMock = jest.fn();
render(
<TaskRequestForm
createTaskRequest={createTaskRequestMock}
isMarkDownInTCREnabled={true}
/>
);
render(<TaskRequestForm createTaskRequest={createTaskRequestMock} />);
const previewButton = screen.getByRole('button', {
name: /Preview/i,
});
Expand Down
5 changes: 1 addition & 4 deletions src/components/issues/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import fetch from '@/helperFunctions/fetch';
import { IssueCardProps } from '@/interfaces/issueProps.type';
import { TASKS_URL } from '../../constants/url';
import useUserData from '@/hooks/useUserData';
import { useRouter } from 'next/router';
import { useUpdateTaskMutation } from '@/app/services/tasksApi';
import { TASK_REQUEST_TYPES } from '@/constants/tasks';
import { FEATURE } from '@/constants/task-type';
Expand All @@ -18,8 +17,6 @@ import { useAddOrUpdateMutation } from '@/app/services/taskRequestApi';
const { SUCCESS, ERROR } = ToastTypes;

const Card: FC<IssueCardProps> = ({ issue }) => {
const router = useRouter();
const { dev } = router.query;
const date = new Date(issue.created_at).toDateString();
const [taskExists, setTaskExists] = useState(issue.taskExists ?? false);
const [isLoading, setIsLoading] = useState(false);
Expand Down Expand Up @@ -117,8 +114,8 @@ const Card: FC<IssueCardProps> = ({ issue }) => {
proposedStartDate: data.startedOn,
proposedDeadline: data.endsOn,
description: data.description,
markdownEnabled: true,
};
if (dev === 'true') requestData.markdownEnabled = true;
if (!requestData.description) delete requestData.description;
try {
const response = await addOrUpdateTaskRequest(requestData).unwrap();
Expand Down
4 changes: 0 additions & 4 deletions src/components/issues/TaskManagementModal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { FC, useState } from 'react';
import styles from '@/components/issues/Card.module.scss';
import { REQUEST_TABS } from './constants';
import { useRouter } from 'next/router';
import Modal from '../Modal';
import TaskRequestForm from './TaskRequestForm';
import ActionForm from './ActionForm';
Expand Down Expand Up @@ -33,8 +32,6 @@ const TaskManagementModal: FC<TaskManagementProps> = ({
handleCreateTask,
handleUpdateTask,
}) => {
const router = useRouter();
const { dev } = router.query;
const defaultTaskConversionTab = isUserAuthorized
? REQUEST_TABS.TASK_CREATION
: REQUEST_TABS.CREATION_REQUEST;
Expand Down Expand Up @@ -93,7 +90,6 @@ const TaskManagementModal: FC<TaskManagementProps> = ({
requestId={requestId}
taskId={taskId}
createTaskRequest={handleCreateTaskRequest}
isMarkDownInTCREnabled={dev === 'true'}
/>
)}
{selectedTab === REQUEST_TABS.TASK_CREATION && (
Expand Down
29 changes: 6 additions & 23 deletions src/components/issues/TaskRequestForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ type ActionFormProps = {
requestId?: string;
taskId?: string;
createTaskRequest?: (data: ActionFormReducer) => Promise<void>;
isMarkDownInTCREnabled?: boolean;
};

type TaskRequestSuccessMessage = {
Expand Down Expand Up @@ -95,7 +94,6 @@ const TaskRequestForm: FC<ActionFormProps> = ({
requestId,
createTaskRequest,
taskId,
isMarkDownInTCREnabled,
}) => {
const [state, dispatch] = useReducer(reducer, initialState, undefined);
const [isLoading, setIsLoading] = useState(false);
Expand Down Expand Up @@ -171,27 +169,12 @@ const TaskRequestForm: FC<ActionFormProps> = ({
>
Description:
</label>
{isMarkDownInTCREnabled ? (
<MarkDownEditor
onChange={onChange}
buttonClassName={styles.card__top__button}
editorClassName={`${styles.assign} ${styles.description_box}`}
previewClassName={`${styles.description_box_markdown}`}
/>
) : (
<textarea
name="description"
id="description"
placeholder="Why do you want this task?"
className={`${styles.assign} ${styles.description_box}`}
onChange={(e) =>
dispatch({
type: 'description',
value: e.target.value,
})
}
/>
)}
<MarkDownEditor
onChange={onChange}
buttonClassName={styles.card__top__button}
editorClassName={`${styles.assign} ${styles.description_box}`}
previewClassName={`${styles.description_box_markdown}`}
/>
</div>
</div>
{isLoading && <Loader />}
Expand Down

0 comments on commit 9a1be24

Please sign in to comment.