CollaborationDetailsPane.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. "use strict";
  2. /**
  3. * Licensed Materials - Property of IBM
  4. * IBM Cognos Products: Cognos Analytics
  5. * Copyright IBM Corp. 2018
  6. * US Government Users Restricted Rights - Use, duplication or disclosure
  7. * restricted by GSA ADP Schedule Contract with IBM Corp.
  8. */
  9. define(['underscore', 'bi/glass/app/ContentView', 'bi/admin/nls/StringResource', 'react-dom', 'react', 'ba-react-admin/ba-react-admin.min', 'collaboration/messaging/connectors/slack/SlackClient'], function (_, ContentView, StringResource, ReactDOM, React, AdminReact, SlackClient) {
  10. 'use strict'; //NOSONAR: meant to be strict
  11. var CollaborationDetailsPane = ContentView.extend({
  12. /**
  13. * @constructs CollaborationDetailsPane
  14. *
  15. * @param options - View options
  16. * @param options.$el - JQuery container node for React view
  17. * @param options.reactViewProps - React props for CollaborationDetailsView
  18. */
  19. init: function init(options) {
  20. CollaborationDetailsPane.inherited('init', this, arguments);
  21. _.extend(this, options);
  22. this.$el.addClass("collaboration-details-view");
  23. },
  24. /**
  25. * Render the view.
  26. * @instance
  27. */
  28. render: function render() {
  29. // FIXME: consume SlackClient in ba-react-admin
  30. this.reactViewProps.SlackClient = SlackClient;
  31. this.reactViewProps.parent = this;
  32. this.reactViewProps.openAddMembersSlideout = this.openAddMembersSlideout.bind(this);
  33. this.reactViewProps.closeAddMembersSlideout = this.closeAddMembersSlideout.bind(this);
  34. ReactDOM.unmountComponentAtNode(this.$el[0]);
  35. var reactElement = React.createElement(AdminReact.CollaborationDetailsView, this.reactViewProps);
  36. this.reactView = ReactDOM.render(reactElement, this.$el[0]);
  37. },
  38. /**
  39. * @override canHide in the parent ContentView.
  40. */
  41. canHide: function canHide(options) {
  42. return !this.reactView || this.reactView.canHide(options);
  43. },
  44. openAddMembersSlideout: function openAddMembersSlideout(options) {
  45. if (!this.slideout.child) {
  46. this.glassContext.appController.showSlideOut({
  47. 'parent': this.slideout,
  48. 'width': '450',
  49. // temporary adjustment for R10 until panel size is unified,
  50. onHide: options.onHideAddMembers,
  51. 'content': {
  52. 'module': 'bi/admin/account/slideout/SecurityObjectSelectorPane',
  53. 'parentView': this,
  54. 'title': StringResource.get('selectAccountGroupOrRole'),
  55. 'allowedSelectionTypes': ['group', 'role', 'account'],
  56. 'multiSelectCallback': options.multiSelectCallback
  57. }
  58. });
  59. }
  60. },
  61. closeAddMembersSlideout: function closeAddMembersSlideout(options) {
  62. if (this.slideout.child) {
  63. this.slideout.child.hide();
  64. }
  65. },
  66. remove: function remove() {
  67. if (this.$el) {
  68. ReactDOM.unmountComponentAtNode(this.$el[0]);
  69. }
  70. return CollaborationDetailsPane.inherited('remove', this, arguments);
  71. }
  72. });
  73. return CollaborationDetailsPane;
  74. });