SavePageControls.jsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { translate } from 'react-i18next';
  4. import SlackNotification from './SlackNotification';
  5. import GrantSelector from './SavePageControls/GrantSelector';
  6. class SavePageControls extends React.PureComponent {
  7. constructor(props) {
  8. super(props);
  9. this.state = {
  10. pageId: this.props.pageId,
  11. };
  12. }
  13. componentWillMount() {
  14. }
  15. /**
  16. * update pageId of state
  17. * @param {string} pageId
  18. */
  19. setPageId(pageId) {
  20. this.setState({pageId});
  21. }
  22. render() {
  23. const { t } = this.props;
  24. const label = this.state.pageId == null ? t('Create') : t('Update');
  25. return (
  26. <div className="d-flex align-items-center form-inline">
  27. <div className="mr-2">
  28. <SlackNotification
  29. crowi={this.props.crowi}
  30. pageId={this.props.pageId}
  31. pagePath={this.props.pagePath}
  32. isSlackEnabled={false}
  33. slackChannels={this.props.slackChannels}
  34. formName='pageForm' />
  35. </div>
  36. <div className="mr-2">
  37. <GrantSelector crowi={this.props.crowi}
  38. pageGrant={this.props.pageGrant}
  39. pageGrantGroupId={this.props.pageGrantGroupId}
  40. pageGrantGroupName={this.props.pageGrantGroupName} />
  41. </div>
  42. <button className="btn btn-primary btn-submit">{label}</button>
  43. </div>
  44. );
  45. }
  46. }
  47. SavePageControls.propTypes = {
  48. t: PropTypes.func.isRequired, // i18next
  49. crowi: PropTypes.object.isRequired,
  50. pageId: PropTypes.string,
  51. // for SlackNotification
  52. pagePath: PropTypes.string,
  53. slackChannels: PropTypes.string,
  54. // for GrantSelector
  55. pageGrant: PropTypes.number,
  56. pageGrantGroupId: PropTypes.string,
  57. pageGrantGroupName: PropTypes.string,
  58. };
  59. export default translate()(SavePageControls);