Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 0a1fda4

Browse files
committed
fix: issue #125
1 parent 295aecb commit 0a1fda4

File tree

6 files changed

+56
-2
lines changed

6 files changed

+56
-2
lines changed

src/components/FormField/index.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const FormField = ({ field }) => {
6464
<MarkdownEditor
6565
placeholder={field.placeholder}
6666
value={input?.value ?? ""}
67+
disabled={field.disabled}
6768
onChange={input.onChange}
6869
onBlur={input.onBlur}
6970
onFocus={input.onFocus}

src/components/MarkdownEditor/index.jsx

+11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import React, { useCallback, useRef } from "react";
66
import PropTypes from "prop-types";
77
import cn from "classnames";
88
import TuiEditor from "../TuiEditor";
9+
import MarkdownEditorViewer from "../MarkdownEditorViewer";
910
import styles from "./styles.module.scss";
11+
import { DISABLED_DESCRIPTION_MESSAGE } from "constants";
1012

1113
const MarkdownEditor = (props) => {
1214
const editorElement = useRef(null);
@@ -15,6 +17,14 @@ const MarkdownEditor = (props) => {
1517
const markdown = editorElement.current.editorInst.getMarkdown();
1618
props.onChange(markdown);
1719
}, [props.onChange]);
20+
if (props.disabled) {
21+
return (
22+
<div styleName="editor-viewer">
23+
<MarkdownEditorViewer {...props} />
24+
<div styleName="message">{DISABLED_DESCRIPTION_MESSAGE}</div>
25+
</div>
26+
);
27+
}
1828

1929
return (
2030
<div className={cn(styles["editor-container"], props.className)}>
@@ -30,6 +40,7 @@ const MarkdownEditor = (props) => {
3040

3141
MarkdownEditor.propTypes = {
3242
value: PropTypes.string,
43+
disabled: PropTypes.bool,
3344
className: PropTypes.string,
3445
onChange: PropTypes.func,
3546
onFocus: PropTypes.func,

src/components/MarkdownEditor/styles.module.scss

+26
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,31 @@
11
@import "styles/include";
22

3+
.editor-viewer {
4+
> div:first-child {
5+
border: 1px solid #aaaaab;
6+
border-radius: 4px;
7+
overflow: hidden;
8+
box-sizing: border-box;
9+
padding: 16px 25px 0px 25px;
10+
height: 280px;
11+
overflow-y: auto;
12+
}
13+
.message {
14+
@include font-roboto;
15+
16+
width: 100%;
17+
text-align: center;
18+
min-height: 40px;
19+
line-height: 20px;
20+
padding: 9px 10px;
21+
margin: 10px 0 5px;
22+
font-size: 14px;
23+
color: #ff5b52;
24+
border: 1px solid #ffd5d1;
25+
cursor: auto;
26+
outline: none;
27+
}
28+
}
329
.editor-container {
430
:global {
531
// reset style for heading list in headings selection popup

src/constants/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,9 @@ export const STATUS_OPTIONS = [
276276
{ value: "closed", label: "closed" },
277277
{ value: "cancelled", label: "cancelled" },
278278
];
279+
280+
/*
281+
* show error message below the markdown editor when the markedown editor is disabled
282+
*/
283+
export const DISABLED_DESCRIPTION_MESSAGE =
284+
"You may not edit a Job Description that is currently posted to Topcoder.com. Please contact [email protected].";

src/routes/JobForm/index.jsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ const JobForm = ({ teamId, jobId }) => {
105105
/>
106106
<div styleName="job-modification-details">
107107
<TCForm
108-
configuration={getEditJobConfig(options, onSubmit)}
108+
configuration={getEditJobConfig(
109+
options,
110+
job.isApplicationPageActive,
111+
onSubmit
112+
)}
109113
initialValue={job}
110114
submitButton={{ text: isEdit ? "Save" : "Create" }}
111115
backButton={{

src/routes/JobForm/utils.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,14 @@ const EDIT_JOB_ROWS = [
2626
/**
2727
* return edit job configuration
2828
* @param {any} skillOptions skill options
29+
* @param {boolean} isMarkdownEditorDisabled is markedownEditor disabled
2930
* @param {func} onSubmit submit callback
3031
*/
31-
export const getEditJobConfig = (skillOptions, onSubmit) => {
32+
export const getEditJobConfig = (
33+
skillOptions,
34+
isMarkdownEditorDisabled,
35+
onSubmit
36+
) => {
3237
return {
3338
fields: [
3439
{
@@ -44,6 +49,7 @@ export const getEditJobConfig = (skillOptions, onSubmit) => {
4449
label: "Job Description",
4550
type: FORM_FIELD_TYPE.MARKDOWNEDITOR,
4651
name: "description",
52+
disabled: isMarkdownEditorDisabled,
4753
placeholder: "Job Description",
4854
},
4955
{

0 commit comments

Comments
 (0)