diff --git a/client/app/components/AutocompleteToggle.jsx b/client/app/components/AutocompleteToggle.jsx index e74e0a9047..5a4c9bff20 100644 --- a/client/app/components/AutocompleteToggle.jsx +++ b/client/app/components/AutocompleteToggle.jsx @@ -2,7 +2,7 @@ import React from 'react'; import Tooltip from 'antd/lib/tooltip'; import PropTypes from 'prop-types'; import '@/redash-font/style.less'; -import recordEvent from '@/lib/recordEvent'; +import recordEvent from '@/services/recordEvent'; export default function AutocompleteToggle({ state, disabled, onToggle }) { let tooltipMessage = 'Live Autocomplete Enabled'; diff --git a/client/app/components/DateInput.jsx b/client/app/components/DateInput.jsx index 695a2a1997..ff7812ed8e 100644 --- a/client/app/components/DateInput.jsx +++ b/client/app/components/DateInput.jsx @@ -3,12 +3,11 @@ import React from 'react'; import PropTypes from 'prop-types'; import { react2angular } from 'react2angular'; import DatePicker from 'antd/lib/date-picker'; +import { clientConfig } from '@/services/auth'; export function DateInput({ value, onSelect, - // eslint-disable-next-line react/prop-types - clientConfig, className, }) { const format = clientConfig.dateFormat || 'YYYY-MM-DD'; @@ -46,7 +45,7 @@ DateInput.defaultProps = { }; export default function init(ngModule) { - ngModule.component('dateInput', react2angular(DateInput, null, ['clientConfig'])); + ngModule.component('dateInput', react2angular(DateInput)); } init.init = true; diff --git a/client/app/components/DateRangeInput.jsx b/client/app/components/DateRangeInput.jsx index 1b1454bbb5..d8ccef48f7 100644 --- a/client/app/components/DateRangeInput.jsx +++ b/client/app/components/DateRangeInput.jsx @@ -4,14 +4,13 @@ import React from 'react'; import PropTypes from 'prop-types'; import { react2angular } from 'react2angular'; import DatePicker from 'antd/lib/date-picker'; +import { clientConfig } from '@/services/auth'; const { RangePicker } = DatePicker; export function DateRangeInput({ value, onSelect, - // eslint-disable-next-line react/prop-types - clientConfig, className, }) { const format = clientConfig.dateFormat || 'YYYY-MM-DD'; @@ -53,7 +52,7 @@ DateRangeInput.defaultProps = { }; export default function init(ngModule) { - ngModule.component('dateRangeInput', react2angular(DateRangeInput, null, ['clientConfig'])); + ngModule.component('dateRangeInput', react2angular(DateRangeInput)); } init.init = true; diff --git a/client/app/components/DateTimeInput.jsx b/client/app/components/DateTimeInput.jsx index d95fd60884..92fb81f104 100644 --- a/client/app/components/DateTimeInput.jsx +++ b/client/app/components/DateTimeInput.jsx @@ -3,13 +3,12 @@ import React from 'react'; import PropTypes from 'prop-types'; import { react2angular } from 'react2angular'; import DatePicker from 'antd/lib/date-picker'; +import { clientConfig } from '@/services/auth'; export function DateTimeInput({ value, withSeconds, onSelect, - // eslint-disable-next-line react/prop-types - clientConfig, className, }) { const format = (clientConfig.dateFormat || 'YYYY-MM-DD') + @@ -51,7 +50,7 @@ DateTimeInput.defaultProps = { }; export default function init(ngModule) { - ngModule.component('dateTimeInput', react2angular(DateTimeInput, null, ['clientConfig'])); + ngModule.component('dateTimeInput', react2angular(DateTimeInput)); } init.init = true; diff --git a/client/app/components/DateTimeRangeInput.jsx b/client/app/components/DateTimeRangeInput.jsx index d0fa5ecb39..51f6c62ddc 100644 --- a/client/app/components/DateTimeRangeInput.jsx +++ b/client/app/components/DateTimeRangeInput.jsx @@ -4,6 +4,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import { react2angular } from 'react2angular'; import DatePicker from 'antd/lib/date-picker'; +import { clientConfig } from '@/services/auth'; const { RangePicker } = DatePicker; @@ -11,8 +12,6 @@ export function DateTimeRangeInput({ value, withSeconds, onSelect, - // eslint-disable-next-line react/prop-types - clientConfig, className, }) { const format = (clientConfig.dateFormat || 'YYYY-MM-DD') + @@ -58,7 +57,7 @@ DateTimeRangeInput.defaultProps = { }; export default function init(ngModule) { - ngModule.component('dateTimeRangeInput', react2angular(DateTimeRangeInput, null, ['clientConfig'])); + ngModule.component('dateTimeRangeInput', react2angular(DateTimeRangeInput)); } init.init = true; diff --git a/client/app/components/Footer.jsx b/client/app/components/Footer.jsx index bd1f06efda..7e45562fe1 100644 --- a/client/app/components/Footer.jsx +++ b/client/app/components/Footer.jsx @@ -1,11 +1,10 @@ import React from 'react'; -import PropTypes from 'prop-types'; - import { react2angular } from 'react2angular'; +import { clientConfig, currentUser } from '@/services/auth'; import frontendVersion from '../version.json'; -export function Footer({ clientConfig, currentUser }) { +export function Footer() { const backendVersion = clientConfig.version; const newVersionAvailable = clientConfig.newVersionAvailable && currentUser.isAdmin; const separator = ' \u2022 '; @@ -31,18 +30,8 @@ export function Footer({ clientConfig, currentUser }) { ); } -Footer.propTypes = { - clientConfig: PropTypes.shape({ - version: PropTypes.string, - newVersionAvailable: PropTypes.bool, - }).isRequired, - currentUser: PropTypes.shape({ - isAdmin: PropTypes.bool, - }).isRequired, -}; - export default function init(ngModule) { - ngModule.component('footer', react2angular(Footer, [], ['clientConfig', 'currentUser'])); + ngModule.component('footer', react2angular(Footer)); } init.init = true; diff --git a/client/app/components/Footer.test.js b/client/app/components/Footer.test.js index 81a157ebfc..519a9e5732 100644 --- a/client/app/components/Footer.test.js +++ b/client/app/components/Footer.test.js @@ -1,16 +1,19 @@ +import { extend } from 'lodash'; import React from 'react'; import renderer from 'react-test-renderer'; +import { clientConfig, currentUser } from '../services/auth'; import { Footer } from './Footer'; test('Footer renders', () => { - const clientConfig = { + // TODO: Properly mock this + extend(clientConfig, { version: '5.0.1', newVersionAvailable: true, - }; - const currentUser = { - isAdmin: true, - }; - const component = renderer.create(