Skip to content

Commit 61acc38

Browse files
committed
Fix editor component
1 parent 383c63f commit 61acc38

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

services/app/apps/codebattle/assets/js/widgets/components/ExtendedEditor.jsx

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
/* eslint-disable no-bitwise */
2-
// import React from 'react';
3-
4-
// import cn from 'classnames';
5-
// import { registerRulesForLanguage } from 'monaco-ace-tokenizer';
6-
// import PropTypes from 'prop-types';
7-
// import MonacoEditor from 'react-monaco-editor';
1+
import React, { Component } from 'react';
82

93
import PropTypes from 'prop-types';
104
import { connect } from 'react-redux';
@@ -17,28 +11,30 @@ import {
1711
} from '../selectors/index';
1812
import { actions } from '../slices';
1913

20-
class ExtendedEditor {
14+
class ExtendedEditor extends Component {
2115
static propTypes = {
2216
monacoTheme: PropTypes.string,
23-
fontFamly: PropTypes.string || undefined,
17+
fontFamily: PropTypes.string, // corrected prop name
2418
};
2519

2620
static defaultProps = {
2721
monacoTheme: 'default',
28-
fontFamly: undefined,
29-
}
22+
fontFamily: undefined,
23+
};
3024

3125
constructor(props) {
32-
// super(props);
33-
26+
super(props);
3427
this.options = {
3528
fontFamily: props.fontFamily,
3629
...this.options,
3730
};
3831
}
3932

4033
async componentDidMount() {
41-
super.componentDidMount();
34+
// If there's a need to call the parent method, ensure it exists.
35+
if (super.componentDidMount) {
36+
super.componentDidMount();
37+
}
4238

4339
const { monacoTheme } = this.props;
4440
const { monaco } = this;
@@ -60,18 +56,22 @@ class ExtendedEditor {
6056
}
6157

6258
async componentDidUpdate(prevProps, prevState) {
63-
super.componentDidUpdate(prevProps, prevState);
59+
if (super.componentDidUpdate) {
60+
super.componentDidUpdate(prevProps, prevState);
61+
}
6462

6563
const { monacoTheme } = this.props;
6664
const { monaco } = this;
6765

68-
if (monacoTheme
66+
if (
67+
monacoTheme
6968
&& monacoTheme !== prevProps.monacoTheme
7069
&& monacoTheme === 'custom'
7170
) {
7271
monaco.editor.defineTheme(monacoTheme, customTheme);
7372
monaco.editor.setTheme(monacoTheme);
74-
} else if (monacoTheme
73+
} else if (
74+
monacoTheme
7575
&& monacoTheme !== prevProps.monacoTheme
7676
&& monacoTheme !== 'default'
7777
) {
@@ -88,7 +88,14 @@ class ExtendedEditor {
8888
}
8989

9090
componentWillUnmount() {
91-
super.componentWillUnmount();
91+
if (super.componentWillUnmount) {
92+
super.componentWillUnmount();
93+
}
94+
}
95+
96+
render() {
97+
// Implement your render method here
98+
return null;
9299
}
93100
}
94101

services/app/apps/codebattle/lib/codebattle_web/controllers/api/v1/task_controller.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ defmodule CodebattleWeb.Api.V1.TaskController do
7171

7272
{:error, %Ecto.Changeset{} = changeset} ->
7373
conn
74-
|> put_status(:failure)
74+
|> put_status(:unprocessable_entity)
7575
|> json(%{error: "failure", changeset: changeset})
7676
end
7777
end

services/app/config/dev.exs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,6 @@ config :codebattle, Codebattle.Plugs, rollbar_api_key: System.get_env("ROLLBAR_A
6262
config :codebattle, Codebattle.Invite,
6363
timeout: :timer.minutes(15),
6464
lifetime: :timer.minutes(15)
65+
66+
config :codebattle, checker_executor: Codebattle.CodeCheck.Executor.Local
67+
config :codebattle, asserts_executor: Codebattle.CodeCheck.Executor.Local

0 commit comments

Comments
 (0)