diff --git a/app/assets/javascripts/components/story/ExpandedStory/index.jsx b/app/assets/javascripts/components/story/ExpandedStory/index.jsx index cf0a48820..896315f60 100644 --- a/app/assets/javascripts/components/story/ExpandedStory/index.jsx +++ b/app/assets/javascripts/components/story/ExpandedStory/index.jsx @@ -1,81 +1,96 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import ExpandedStoryControls from './ExpandedStoryControls'; -import ExpandedStoryDefault from './ExpandedStoryDefault'; -import ExpandedStoryRelease from './ExpandedStoryRelease'; -import { editStory, saveStory, deleteStory, cloneStory, showHistory } from '../../../actions/story'; -import { connect } from 'react-redux'; -import * as Story from '../../../models/beta/story'; -import ProjectPropTypes from '../../shapes/project'; +import React, { useEffect, useRef } from "react"; +import classNames from "classnames"; +import PropTypes from "prop-types"; +import ExpandedStoryControls from "./ExpandedStoryControls"; +import ExpandedStoryDefault from "./ExpandedStoryDefault"; +import ExpandedStoryRelease from "./ExpandedStoryRelease"; +import { + editStory, + saveStory, + deleteStory, + cloneStory, + showHistory, +} from "../../../actions/story"; +import { connect } from "react-redux"; +import * as Story from "../../../models/beta/story"; +import ProjectPropTypes from "../../shapes/project"; -export class ExpandedStory extends React.Component { - constructor(props) { - super(props); +export function ExpandedStory({ + story, + onToggle, + editStory, + saveStory, + cloneStory, + showHistory, + deleteStory, + project, + className, + title, + from, +}) { + const titleRef = useRef(); - this.titleRef = React.createRef(); - } + const loading = story._editing.loading; + const disabled = !Story.canEdit(story); - componentDidMount() { - this.titleRef.current.focus(); - } + const handleEditStory = (newAttributes) => { + editStory(story.id, newAttributes, from); + }; - render() { - const { - story, - onToggle, - editStory, - saveStory, - cloneStory, - showHistory, - deleteStory, - project, - className, - title, - from - } = this.props; + const handleSaveStory = () => { + saveStory(story.id, project.id, from); + }; - const loading = story._editing.loading ? "Story__enable-loading" : ""; - const disabled = !Story.canEdit(story); + const handleDeleteStory = () => { + deleteStory(story.id, project.id, from); + }; - return ( -