MoveDialog.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (C) 2015 - present Instructure, Inc.
  3. *
  4. * This file is part of Canvas.
  5. *
  6. * Canvas is free software: you can redistribute it and/or modify it under
  7. * the terms of the GNU Affero General Public License as published by the Free
  8. * Software Foundation, version 3 of the License.
  9. *
  10. * Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
  11. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  13. * details.
  14. *
  15. * You should have received a copy of the GNU Affero General Public License along
  16. * with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. import I18n from 'i18n!react_files'
  19. import React from 'react'
  20. import MoveDialog from 'compiled/react_files/components/MoveDialog'
  21. import Modal from 'jsx/shared/modal'
  22. import ModalContent from 'jsx/shared/modal-content'
  23. import ModalButtons from 'jsx/shared/modal-buttons'
  24. import BBTreeBrowser from 'jsx/files/BBTreeBrowser'
  25. import classnames from 'classnames'
  26. MoveDialog.renderMoveButton = function () {
  27. const buttonClassNames = classnames({
  28. 'disabled': !this.state.destinationFolder,
  29. 'btn': true,
  30. 'btn-primary': true
  31. });
  32. if (this.state.isCopyingFile) {
  33. return (
  34. <button
  35. type='submit'
  36. aria-disabled={!this.state.destinationFolder}
  37. className={buttonClassNames}
  38. data-text-while-loading={I18n.t('Copying...')}
  39. >
  40. {I18n.t('Copy to Folder')}
  41. </button>
  42. );
  43. } else {
  44. return (
  45. <button
  46. type='submit'
  47. aria-disabled={!this.state.destinationFolder}
  48. className={buttonClassNames}
  49. data-text-while-loading={I18n.t('Moving...')}
  50. >
  51. {I18n.t('Move')}
  52. </button>
  53. );
  54. }
  55. };
  56. MoveDialog.render = function () {
  57. return (
  58. <Modal
  59. className='ReactModal__Content--canvas ReactModal__Content--mini-modal'
  60. overlayClassName='ReactModal__Overlay--canvas'
  61. ref='canvasModal'
  62. isOpen={this.state.isOpen}
  63. title={this.getTitle()}
  64. onRequestClose={this.closeDialog}
  65. onSubmit={this.submit}
  66. >
  67. <ModalContent>
  68. <BBTreeBrowser
  69. rootFoldersToShow={this.props.rootFoldersToShow}
  70. onSelectFolder={this.onSelectFolder}
  71. />
  72. </ModalContent>
  73. <ModalButtons>
  74. <button
  75. type='button'
  76. className='btn'
  77. onClick={this.closeDialog}
  78. >
  79. {I18n.t('Cancel')}
  80. </button>
  81. {this.renderMoveButton()}
  82. </ModalButtons>
  83. </Modal>
  84. );
  85. };
  86. export default React.createClass(MoveDialog)