<commit_before>/* eslint "max-len": 0 */

import React from 'react';
import Paper from 'material-ui/Paper';
import RaisedButton from 'material-ui/RaisedButton';
import TextField from 'material-ui/TextField';
import PropTypes from 'prop-types';

import theme from '../theme';

import PermissionField from './PermissionField';

export default class EditPage extends React.Component {
    static propTypes = {
        viewer: PropTypes.object,
        slug: PropTypes.string,
        title: PropTypes.string,
        summary: PropTypes.string,
        mdtext: PropTypes.string,
        permissions: PropTypes.array,
        savePage: PropTypes.func,
    }

    state = {
        slug: this.props.slug,
        title: this.props.title,
        summary: this.props.summary,
        mdtext: this.props.mdtext,
        permissions: this.props.permissions,
    }

    onChangeSlug = (event, slug) => {
        this.setState({ slug });
    }

    onChangeTitle = (event, title) => {
        this.setState({ title });
    }

    onChangeSummary = (event, summary) => {
        this.setState({ summary });
    }

    onChangeContent = (event, mdtext) => {
        this.setState({ mdtext });
    }

    onPermissionChange = (permissions) => {
        this.setState({ permissions });
    }

    savePage = (event) => {
        event.preventDefault();
        this.props.savePage(this.state);
    }

    render() {
        const { desktopGutterLess } = theme.spacing;
        return (
            <section>
                <form onSubmit={this.savePage}>
                    <h1>Rediger sideinnhold</h1>
                    <div>
                        <TextField
                            id="mdtext"
                            value={this.state.mdtext}
                            floatingLabelText="Sideinnhold"
                            multiLine
                            fullWidth
                            onChange={this.onChangeContent}
                            style={{ width: '100%' }}
                        />
                    </div>
                    <Paper style={{ padding: desktopGutterLess }}>
                        <h2>Forsidesnutt</h2>
                        <p>Tittel og introduksjon til bruk på forsida. Det er ennå ikke automatikk i legge snutten til på forsida.</p>
                        <TextField
                            id="title"
                            value={this.state.title}<commit_msg>Fix bug where id was not sent on page edit<commit_after>/* eslint "max-len": 0 */

import React from 'react';
import Paper from 'material-ui/Paper';
import RaisedButton from 'material-ui/RaisedButton';
import TextField from 'material-ui/TextField';
import PropTypes from 'prop-types';

import theme from '../theme';

import PermissionField from './PermissionField';

export default class EditPage extends React.Component {
    static propTypes = {
        viewer: PropTypes.object,
        id: PropTypes.string.required,
        slug: PropTypes.string,
        title: PropTypes.string,
        summary: PropTypes.string,
        mdtext: PropTypes.string,
        permissions: PropTypes.array,
        savePage: PropTypes.func,
    }

    state = {
        slug: this.props.slug,
        title: this.props.title,
        summary: this.props.summary,
        mdtext: this.props.mdtext,
        permissions: this.props.permissions,
    }

    onChangeSlug = (event, slug) => {
        this.setState({ slug });
    }

    onChangeTitle = (event, title) => {
        this.setState({ title });
    }

    onChangeSummary = (event, summary) => {
        this.setState({ summary });
    }

    onChangeContent = (event, mdtext) => {
        this.setState({ mdtext });
    }

    onPermissionChange = (permissions) => {
        this.setState({ permissions });
    }

    savePage = (event) => {
        event.preventDefault();
        this.props.savePage({
            id: this.props.id,
            slug: this.state.slug,
            mdtext: this.state.mdtext,
            title: this.state.title,
            summary: this.state.summary,
            permissions: this.state.permissions,
        });
    }

    render() {
        const { desktopGutterLess } = theme.spacing;
        return (
            <section>
                <form onSubmit={this.savePage}>
                    <h1>Rediger sideinnhold</h1>
                    <div>
                        <TextField
                            id="mdtext"
                            value={this.state.mdtext}
                            floatingLabelText="Sideinnhold"
                            multiLine
                            fullWidth
                            onChange={this.onChangeContent}
                            style={{ width: '100%' }}
                        />
                    </div>
                    <Paper style={{ padding: desktopGutterLess }}>
                        <h2>Forsidesnutt</h2>
                        <p>Tittel og introduksjon til bruk på forsida. Det er ennå ikke automatikk i legge snutten til på forsida.</p>
                        <TextField
                            id="title"
                            value={this.state.title}
{'fraction_non_alphanumeric': 0.10694256430090891, 'fraction_numerical': 0.003094179075614001, 'mean_word_length': 1.505813953488372, 'pattern_counts': {'":': 2, '<': 29, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7299867', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1360, 'n_words': 304}