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

fix: issue #125 #134

Merged
merged 1 commit into from
Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/FormField/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const FormField = ({ field }) => {
<MarkdownEditor
placeholder={field.placeholder}
value={input?.value ?? ""}
disabled={field.disabled}
onChange={input.onChange}
onBlur={input.onBlur}
onFocus={input.onFocus}
Expand Down
11 changes: 11 additions & 0 deletions src/components/MarkdownEditor/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import React, { useCallback, useRef } from "react";
import PropTypes from "prop-types";
import cn from "classnames";
import TuiEditor from "../TuiEditor";
import MarkdownEditorViewer from "../MarkdownEditorViewer";
import styles from "./styles.module.scss";
import { DISABLED_DESCRIPTION_MESSAGE } from "constants";

const MarkdownEditor = (props) => {
const editorElement = useRef(null);
Expand All @@ -15,6 +17,14 @@ const MarkdownEditor = (props) => {
const markdown = editorElement.current.editorInst.getMarkdown();
props.onChange(markdown);
}, [props.onChange]);
if (props.disabled) {
return (
<div styleName="editor-viewer">
<MarkdownEditorViewer {...props} />
<div styleName="message">{DISABLED_DESCRIPTION_MESSAGE}</div>
</div>
);
}

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

MarkdownEditor.propTypes = {
value: PropTypes.string,
disabled: PropTypes.bool,
className: PropTypes.string,
onChange: PropTypes.func,
onFocus: PropTypes.func,
Expand Down
26 changes: 26 additions & 0 deletions src/components/MarkdownEditor/styles.module.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
@import "styles/include";

.editor-viewer {
> div:first-child {
border: 1px solid #aaaaab;
border-radius: 4px;
overflow: hidden;
box-sizing: border-box;
padding: 16px 25px 0px 25px;
height: 280px;
overflow-y: auto;
}
.message {
@include font-roboto;

width: 100%;
text-align: center;
min-height: 40px;
line-height: 20px;
padding: 9px 10px;
margin: 10px 0 5px;
font-size: 14px;
color: #ff5b52;
border: 1px solid #ffd5d1;
cursor: auto;
outline: none;
}
}
.editor-container {
:global {
// reset style for heading list in headings selection popup
Expand Down
6 changes: 6 additions & 0 deletions src/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,9 @@ export const STATUS_OPTIONS = [
{ value: "closed", label: "closed" },
{ value: "cancelled", label: "cancelled" },
];

/*
* show error message below the markdown editor when the markedown editor is disabled
*/
export const DISABLED_DESCRIPTION_MESSAGE =
"You may not edit a Job Description that is currently posted to Topcoder.com. Please contact [email protected].";
6 changes: 5 additions & 1 deletion src/routes/JobForm/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ const JobForm = ({ teamId, jobId }) => {
/>
<div styleName="job-modification-details">
<TCForm
configuration={getEditJobConfig(options, onSubmit)}
configuration={getEditJobConfig(
options,
job.isApplicationPageActive,
onSubmit
)}
initialValue={job}
submitButton={{ text: isEdit ? "Save" : "Create" }}
backButton={{
Expand Down
8 changes: 7 additions & 1 deletion src/routes/JobForm/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ const EDIT_JOB_ROWS = [
/**
* return edit job configuration
* @param {any} skillOptions skill options
* @param {boolean} isMarkdownEditorDisabled is markedownEditor disabled
* @param {func} onSubmit submit callback
*/
export const getEditJobConfig = (skillOptions, onSubmit) => {
export const getEditJobConfig = (
skillOptions,
isMarkdownEditorDisabled,
onSubmit
) => {
return {
fields: [
{
Expand All @@ -44,6 +49,7 @@ export const getEditJobConfig = (skillOptions, onSubmit) => {
label: "Job Description",
type: FORM_FIELD_TYPE.MARKDOWNEDITOR,
name: "description",
disabled: isMarkdownEditorDisabled,
placeholder: "Job Description",
},
{
Expand Down