Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove debug output to console. #112

Open
wants to merge 1 commit into
base: legacy
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"react/no-find-dom-node": "off",
"react/no-string-refs": "off",
"strict": 0,
"no-console": "off",
"no-console": ["error", { allow: [ "error"] }],
"no-unused-vars": 1
},
"settings": {
Expand Down
1 change: 0 additions & 1 deletion src/app/components/Info.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class InfoBox extends Component {
href="#"
className="link"
onClick={() => {
console.log("CLICK", description);
this.props.show({ title, description });
}}
>
Expand Down
1 change: 0 additions & 1 deletion src/app/components/InfoBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class InfoBox extends Component {
{ info__box__visible: visible }
]);

console.log("CLASSNAME", className);
return (
<div className={className}>
<div className="info__box__body">
Expand Down
7 changes: 1 addition & 6 deletions src/app/components/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,15 @@ class Display extends Component {
let anyTouched = appForm.anyTouched ? appForm.anyTouched : false;
let errorsObj = appForm.syncErrors ? appForm.syncErrors : null;
let errors = null;
console.log(errorsObj);

if (anyTouched && errorsObj) {
errors = Object.keys(errorsObj).map((k, i) => {
try {
let val = errorsObj[k];
// console.log(k, val);
let msg = val;
if (_.isArray(val)) {
// console.log("ARRAY");
msg = "multiple errors";
} else if (_.isObject(val)) {
// console.log("OBJ");
if (val._error) msg = val._error;
else msg = "multiple errors";
}
Expand All @@ -49,14 +46,12 @@ class Display extends Component {
</div>
);
} catch (e) {
console.log("skipped error", e);
return null;
}
});
}
return <div className="text-danger">{errors}</div>;
} catch (e) {
console.log(" error", e);
return null;
}
}
Expand Down
6 changes: 0 additions & 6 deletions src/app/components/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ class Index extends Component {

async initData(country = null) {
//has state
console.log("initData");
let { elements, blocks, allFields } = await getData(country);
this.setState({ elements, blocks, country, allFields });
this.initBootstrap();
Expand Down Expand Up @@ -115,7 +114,6 @@ class Index extends Component {
// if (currentLanguage) currentValues = values[currentLanguage];

//UPDATE STATE
console.log('update state');
this.setState({
yaml,
languages,
Expand Down Expand Up @@ -197,7 +195,6 @@ class Index extends Component {
//VALIDATE TYPES AND SUBOBJECT
let objs_n_arrays = fv.validateSubTypes(contents, elements);
errors = Object.assign(required, objs_n_arrays);
// console.log(errors);

//UPDATE STATE
values[currentLanguage] = contents;
Expand Down Expand Up @@ -356,10 +353,7 @@ class Index extends Component {
let diff = currentScroll - offset;

if (diff > 0) {
console.info("diff", diff);
document.getElementById(`content__main`).scrollTop = offset;
} else {
console.warn("inviewport");
}
this.setState({ activeSection: activeSection });
}
Expand Down
1 change: 0 additions & 1 deletion src/app/components/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class head extends Component {
}

updateGen(lastGen) {
console.log("UPDATE GEN");
let info = null;
if (lastGen) {
info = moment(lastGen).fromNow();
Expand Down
11 changes: 2 additions & 9 deletions src/app/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,10 @@ class Index extends Component {

async componentDidMount() {
let versions = await getReleases();
console.log("VERSIONS", versions);
this.getSchema(versions);
}

getSchema(versions) {
console.log(versions);
let customMeta = {
definitions: {
publiccodeYamlVersion: {
Expand Down Expand Up @@ -148,20 +146,16 @@ class Index extends Component {
});
data = u(customMeta, data);

console.log("DATA", data);
let obj = jsyaml.load(JSON.stringify(data));

schema = compileSchema(obj);
console.log("COMPILED SCHEMA", obj);
this.setState({ loading: false });
}

submit(data) {
this.notify();
console.log("SUBMIT");

data = cleanDeep(data);
console.log(data);
//REFORMAT CUSTOM FIELDS DATA
try {
let yaml = jsyaml.dump(data);
Expand All @@ -172,7 +166,6 @@ class Index extends Component {
}

onLoad(formData, yaml) {
console.log("loaded", yaml, formData);
this.setState({ formData, yaml });
}

Expand Down Expand Up @@ -205,7 +198,7 @@ class Index extends Component {
renderForm() {
const { loading } = this.state;
if (loading) return <div>Loading...</div>;
console.log("COMPILED SCHEMA", schema);

const initialValues = Schema.initialValues;
const MyForm = reduxForm({
form: APP_FORM,
Expand All @@ -229,7 +222,7 @@ class Index extends Component {
if (!data) {
data = Schema.initialValues;
}
console.log("RESET", data);

this.props.initialize(APP_FORM, data);
}

Expand Down
1 change: 0 additions & 1 deletion src/app/components/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class sidebar extends Component {
yaml = await getRemoteYml(remoteYml);
onLoad(yaml);
} catch (error) {
console.error(error);
alert("error parsing remote yaml");
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/app/contents/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,13 @@ const getAllFields = (generic, countryFields = null) => {

// eslint-disable-next-line no-unused-vars
const flatAll = allFields => {
console.log("flatAll", allFields);
return allFields.reduce((list, f) => {
let items = flatField(f);
return [...list, ...items];
}, []);
};

const flatField = field => {
console.log("flatField", field.title, field.type);
let items = [];
if (field.type === "object") {
items = flatObject(field);
Expand All @@ -95,15 +93,13 @@ const flatField = field => {
};

const flatArray = field => {
console.log("flatArray", field.title, field.type);
return field.items.reduce((list, f) => {
let items = flatField(f);
return [...list, ...items];
}, []);
};

const flatObject = field => {
console.log("flatObject", field.title, field.type);
return field.properties.reduce((list, f) => {
let items = flatField(f);
return [...list, ...items];
Expand Down
1 change: 0 additions & 1 deletion src/app/form/buildSyncValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ const findTypeInSchema = (schema, dataPath) => {
};

const buildSyncValidation = (schema, ajvParam = null) => {
console.log("SYNC VALIDATION");
let ajv = ajvParam;
if (ajv === null) {
ajv = new Ajv({
Expand Down
1 change: 0 additions & 1 deletion src/app/form/widgets/ChoiceMultipleExpandedWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const zipObject = (props, values) =>
);

const changeValue = (checked, item, onChange, currentValue = []) => {
console.log("CURRENT ITEM", item, "CURRENT VALUE", currentValue);
if (checked) {
if (currentValue.indexOf(checked) === -1) {
return onChange([...currentValue, item]);
Expand Down
5 changes: 1 addition & 4 deletions src/app/form/widgets/EditorWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MyEditor extends Component {

onChange(val) {
let { text } = this.state;
console.log("onChange");

if (this.props.onChange) {
if (val == null) this.props.onChange("");
else this.props.onChange(val.toString("markdown"));
Expand All @@ -41,12 +41,9 @@ class MyEditor extends Component {

componentWillReceiveProps(next) {
if (!next.value) {
console.log("RESET ");
this.setState({ text: emptyVal, reset: true });
} else {
if (next.pristine && next.initial) {
console.log("INITIAL ");

let next_html = RichTextEditor.createValueFromString(
next.initial,
"markdown"
Expand Down
2 changes: 1 addition & 1 deletion src/app/form/widgets/RemoteSearchWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class RSComponent extends Component {

handleChange(event) {
const val = event.target.value;
console.log(val, event)

if (this._localProps.input.onChange) {
if (val == null) this._localProps.input.onChange("");
else this._localProps.input.onChange(val);
Expand Down
1 change: 0 additions & 1 deletion src/app/store/infobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const initialState = {
const reducer = handleActions(
{
SHOW_INFO: (state, action) => {
console.log(action);
return {
...state,
title: action.payload.title,
Expand Down
14 changes: 1 addition & 13 deletions src/app/utils/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@ const editorJsonSchema = require("../editor_generator_schema.json");

export const trnsformSchema = values => {
return new Promise((resolve, reject) => {
console.log("values", values);
console.log("editorJsonSchema", editorJsonSchema);
delete yamlJsonSchema.$schema;
delete yamlJsonSchema.id;

const schema = compileSchema(yamlJsonSchema);
if (!schema) reject(null);

console.log("compiled schema", schema);
resolve(schema);
});
};
Expand All @@ -32,18 +29,15 @@ export const validatePubliccodeYml = values => {

// eslint-disable-next-line no-unused-vars
return new Promise((resolve, reject) => {
console.log("validatePubliccodeYml", yamlJsonSchema);
delete yamlJsonSchema.$schema;
delete yamlJsonSchema.id;
const schema = compileSchema(yamlJsonSchema);
console.log("compiled schema", schema);

const valid = ajv.validate(schema, values);
if (valid) {
console.log("schema is valid");
resolve(null);
}
const errors = ajv.errors;
console.log("errors", errors);
resolve(errors);
});
};
Expand All @@ -55,7 +49,6 @@ const strip = html => {
};

export const checkField = (field, obj, value, required) => {
// console.log(`checkField=${field} type=${obj.type} widget=${obj.widget}`);
if (required && !value) return "This property is required.";

//TODO CHECK ARRAY OF OBJECTS AND OBJ WITH PROPS
Expand Down Expand Up @@ -145,7 +138,6 @@ export const validateRequired = (contents, elements) => {

let child = elements.find(item => item.title == el.title);
if (child) {
// console.log(el, child, contents[field], el.values, contents[child.title])
if (el.values.includes(contents[field]) &&
(!contents[child.title] || contents[child.title].length == 0)
) {
Expand All @@ -168,8 +160,6 @@ export const validateRequired = (contents, elements) => {
};

const validateObj = (schema, values) => {
console.log("VALIDATE OBJ", schema.title);

const valid = ajv.validate(schema, values);
const errors = ajv.errors;
if (valid) {
Expand All @@ -180,7 +170,6 @@ const validateObj = (schema, values) => {

export const validateAll = (contents, elements) => {
if (!elements) return;
console.log("VALIDATE ALL");

let errors = elements.reduce((e, schema) => {
if (schema.required && schema.required == true) {
Expand All @@ -192,7 +181,6 @@ export const validateAll = (contents, elements) => {

return e;
}, {});
console.log("ERRORS", errors);
};

// eslint-disable-next-line no-unused-vars
Expand Down