You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Watermarks.js 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. /* @flow */
  2. import React, { Component } from 'react';
  3. import { connect } from 'react-redux';
  4. import { translate } from '../../../i18n';
  5. declare var interfaceConfig: Object;
  6. /**
  7. * The CSS style of the element with CSS class {@code rightwatermark}.
  8. *
  9. * @private
  10. */
  11. const _RIGHT_WATERMARK_STYLE = {
  12. backgroundImage: 'url(images/rightwatermark.png)'
  13. };
  14. /**
  15. * The type of the React {@code Component} props of {@link Watermarks}.
  16. */
  17. type Props = {
  18. /**
  19. * Whether or not the current user is logged in through a JWT.
  20. */
  21. _isGuest: boolean,
  22. /**
  23. * Invoked to obtain translated strings.
  24. */
  25. t: Function
  26. };
  27. /**
  28. * The type of the React {@code Component} state of {@link Watermarks}.
  29. */
  30. type State = {
  31. /**
  32. * The url to open when clicking the brand watermark.
  33. */
  34. brandWatermarkLink: string,
  35. /**
  36. * The url to open when clicking the Jitsi watermark.
  37. */
  38. jitsiWatermarkLink: string,
  39. /**
  40. * Whether or not the brand watermark should be displayed.
  41. */
  42. showBrandWatermark: boolean,
  43. /**
  44. * Whether or not the Jitsi watermark should be displayed.
  45. */
  46. showJitsiWatermark: boolean,
  47. /**
  48. * Whether or not the Jitsi watermark should be displayed for users not
  49. * logged in through a JWT.
  50. */
  51. showJitsiWatermarkForGuests: boolean,
  52. /**
  53. * Whether or not the show the "powered by Jitsi.org" link.
  54. */
  55. showPoweredBy: boolean
  56. };
  57. /**
  58. * A Web Component which renders watermarks such as Jits, brand, powered by,
  59. * etc.
  60. */
  61. class Watermarks extends Component<Props, State> {
  62. /**
  63. * Initializes a new Watermarks instance.
  64. *
  65. * @param {Object} props - The read-only properties with which the new
  66. * instance is to be initialized.
  67. */
  68. constructor(props: Props) {
  69. super(props);
  70. let showBrandWatermark;
  71. let showJitsiWatermark;
  72. let showJitsiWatermarkForGuests;
  73. if (interfaceConfig.filmStripOnly) {
  74. showBrandWatermark = false;
  75. showJitsiWatermark = false;
  76. showJitsiWatermarkForGuests = false;
  77. } else {
  78. showBrandWatermark = interfaceConfig.SHOW_BRAND_WATERMARK;
  79. showJitsiWatermark = interfaceConfig.SHOW_JITSI_WATERMARK;
  80. showJitsiWatermarkForGuests
  81. = interfaceConfig.SHOW_WATERMARK_FOR_GUESTS;
  82. }
  83. this.state = {
  84. brandWatermarkLink:
  85. showBrandWatermark ? interfaceConfig.BRAND_WATERMARK_LINK : '',
  86. jitsiWatermarkLink:
  87. showJitsiWatermark || showJitsiWatermarkForGuests
  88. ? interfaceConfig.JITSI_WATERMARK_LINK : '',
  89. showBrandWatermark,
  90. showJitsiWatermark,
  91. showJitsiWatermarkForGuests,
  92. showPoweredBy: interfaceConfig.SHOW_POWERED_BY
  93. };
  94. }
  95. /**
  96. * Implements React's {@link Component#render()}.
  97. *
  98. * @inheritdoc
  99. * @returns {ReactElement}
  100. */
  101. render() {
  102. return (
  103. <div>
  104. {
  105. this._renderJitsiWatermark()
  106. }
  107. {
  108. this._renderBrandWatermark()
  109. }
  110. {
  111. this._renderPoweredBy()
  112. }
  113. </div>
  114. );
  115. }
  116. /**
  117. * Renders a brand watermark if it is enabled.
  118. *
  119. * @private
  120. * @returns {ReactElement|null} Watermark element or null.
  121. */
  122. _renderBrandWatermark() {
  123. let reactElement = null;
  124. if (this.state.showBrandWatermark) {
  125. reactElement = (
  126. <div
  127. className = 'watermark rightwatermark'
  128. style = { _RIGHT_WATERMARK_STYLE } />
  129. );
  130. const { brandWatermarkLink } = this.state;
  131. if (brandWatermarkLink) {
  132. reactElement = (
  133. <a
  134. href = { brandWatermarkLink }
  135. target = '_new'>
  136. { reactElement }
  137. </a>
  138. );
  139. }
  140. }
  141. return reactElement;
  142. }
  143. /**
  144. * Renders a Jitsi watermark if it is enabled.
  145. *
  146. * @private
  147. * @returns {ReactElement|null}
  148. */
  149. _renderJitsiWatermark() {
  150. let reactElement = null;
  151. if (this.state.showJitsiWatermark
  152. || (this.props._isGuest
  153. && this.state.showJitsiWatermarkForGuests)) {
  154. reactElement = <div className = 'watermark leftwatermark' />;
  155. const { jitsiWatermarkLink } = this.state;
  156. if (jitsiWatermarkLink) {
  157. reactElement = (
  158. <a
  159. href = { jitsiWatermarkLink }
  160. target = '_new'>
  161. { reactElement }
  162. </a>
  163. );
  164. }
  165. }
  166. return reactElement;
  167. }
  168. /**
  169. * Renders a powered by block if it is enabled.
  170. *
  171. * @private
  172. * @returns {ReactElement|null}
  173. */
  174. _renderPoweredBy() {
  175. if (this.state.showPoweredBy) {
  176. const { t } = this.props;
  177. return (
  178. <a
  179. className = 'poweredby'
  180. href = 'http://jitsi.org'
  181. target = '_new'>
  182. <span>{ t('poweredby') } jitsi.org</span>
  183. </a>
  184. );
  185. }
  186. return null;
  187. }
  188. }
  189. /**
  190. * Maps parts of Redux store to component prop types.
  191. *
  192. * @param {Object} state - Snapshot of Redux store.
  193. * @returns {{
  194. * _isGuest: boolean
  195. * }}
  196. */
  197. function _mapStateToProps(state) {
  198. const { isGuest } = state['features/base/jwt'];
  199. return {
  200. /**
  201. * The indicator which determines whether the local participant is a
  202. * guest in the conference.
  203. *
  204. * @private
  205. * @type {boolean}
  206. */
  207. _isGuest: isGuest
  208. };
  209. }
  210. export default connect(_mapStateToProps)(translate(Watermarks));