Skip to content

Commit

Permalink
[bot] migrate files
Browse files Browse the repository at this point in the history
  • Loading branch information
grit-app[bot] committed Nov 22, 2023
1 parent 630734b commit c341c76
Showing 1 changed file with 39 additions and 45 deletions.
84 changes: 39 additions & 45 deletions superset-frontend/src/components/AlteredSliceTag/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
import React from 'react';

import React, { useState, useCallback } from 'react';
import PropTypes from 'prop-types';
import { isEqual, isEmpty } from 'lodash';
import { styled, t } from '@superset-ui/core';
Expand Down Expand Up @@ -62,37 +63,32 @@ function alterForComparison(value) {
return value;
}

export default class AlteredSliceTag extends React.Component {
constructor(props) {
super(props);
const diffs = this.getDiffs(props);
const controlsMap = getControlsForVizType(this.props.origFormData.viz_type);
const rows = this.getRowsFromDiffs(diffs, controlsMap);
const AlteredSliceTag = (props) => {

Check failure on line 66 in superset-frontend/src/components/AlteredSliceTag/index.jsx

View workflow job for this annotation

GitHub Actions / frontend-build

Replace `(props)` with `props`

Check failure on line 66 in superset-frontend/src/components/AlteredSliceTag/index.jsx

View workflow job for this annotation

GitHub Actions / frontend-build

Replace `(props)` with `props`
const diffs = getDiffsHandler(props);

Check failure on line 67 in superset-frontend/src/components/AlteredSliceTag/index.jsx

View workflow job for this annotation

GitHub Actions / frontend-build

Insert `··`

Check failure on line 67 in superset-frontend/src/components/AlteredSliceTag/index.jsx

View workflow job for this annotation

GitHub Actions / frontend-build

'getDiffsHandler' was used before it was defined

Check failure on line 67 in superset-frontend/src/components/AlteredSliceTag/index.jsx

View workflow job for this annotation

GitHub Actions / frontend-build

Insert `··`

Check failure on line 67 in superset-frontend/src/components/AlteredSliceTag/index.jsx

View workflow job for this annotation

GitHub Actions / frontend-build

'getDiffsHandler' was used before it was defined
const controlsMap = getControlsForVizType(props.origFormData.viz_type);

Check failure on line 68 in superset-frontend/src/components/AlteredSliceTag/index.jsx

View workflow job for this annotation

GitHub Actions / frontend-build

Delete `··`

Check failure on line 68 in superset-frontend/src/components/AlteredSliceTag/index.jsx

View workflow job for this annotation

GitHub Actions / frontend-build

Delete `··`
const rows = getRowsFromDiffsHandler(diffs, controlsMap);

Check failure on line 69 in superset-frontend/src/components/AlteredSliceTag/index.jsx

View workflow job for this annotation

GitHub Actions / frontend-build

Delete `··`

Check failure on line 69 in superset-frontend/src/components/AlteredSliceTag/index.jsx

View workflow job for this annotation

GitHub Actions / frontend-build

'getRowsFromDiffsHandler' was used before it was defined

Check failure on line 69 in superset-frontend/src/components/AlteredSliceTag/index.jsx

View workflow job for this annotation

GitHub Actions / frontend-build

Delete `··`

Check failure on line 69 in superset-frontend/src/components/AlteredSliceTag/index.jsx

View workflow job for this annotation

GitHub Actions / frontend-build

'getRowsFromDiffsHandler' was used before it was defined

this.state = { rows, hasDiffs: !isEmpty(diffs), controlsMap };
}
const [hasDiffs, setHasDiffs] = useState(!isEmpty(diffs));

Check failure on line 71 in superset-frontend/src/components/AlteredSliceTag/index.jsx

View workflow job for this annotation

GitHub Actions / frontend-build

Delete `··`

Check failure on line 71 in superset-frontend/src/components/AlteredSliceTag/index.jsx

View workflow job for this annotation

GitHub Actions / frontend-build

'setHasDiffs' is assigned a value but never used

Check failure on line 71 in superset-frontend/src/components/AlteredSliceTag/index.jsx

View workflow job for this annotation

GitHub Actions / frontend-build

Delete `··`

Check failure on line 71 in superset-frontend/src/components/AlteredSliceTag/index.jsx

View workflow job for this annotation

GitHub Actions / frontend-build

'setHasDiffs' is assigned a value but never used

UNSAFE_componentWillReceiveProps(newProps) {
const UNSAFE_componentWillReceivePropsHandler = useCallback((newProps) => {

Check failure on line 73 in superset-frontend/src/components/AlteredSliceTag/index.jsx

View workflow job for this annotation

GitHub Actions / frontend-build

Replace `····const·UNSAFE_componentWillReceivePropsHandler·=·useCallback((newProps)` with `··const·UNSAFE_componentWillReceivePropsHandler·=·useCallback(newProps`

Check failure on line 73 in superset-frontend/src/components/AlteredSliceTag/index.jsx

View workflow job for this annotation

GitHub Actions / frontend-build

'UNSAFE_componentWillReceivePropsHandler' is assigned a value but never used

Check failure on line 73 in superset-frontend/src/components/AlteredSliceTag/index.jsx

View workflow job for this annotation

GitHub Actions / frontend-build

Replace `····const·UNSAFE_componentWillReceivePropsHandler·=·useCallback((newProps)` with `··const·UNSAFE_componentWillReceivePropsHandler·=·useCallback(newProps`

Check failure on line 73 in superset-frontend/src/components/AlteredSliceTag/index.jsx

View workflow job for this annotation

GitHub Actions / frontend-build

'UNSAFE_componentWillReceivePropsHandler' is assigned a value but never used
// Update differences if need be
if (isEqual(this.props, newProps)) {
if (isEqual(props, newProps)) {
return;
}
const diffs = this.getDiffs(newProps);
this.setState(prevState => ({
rows: this.getRowsFromDiffs(diffs, prevState.controlsMap),
const diffs = getDiffsHandler(newProps);
setStateHandler(prevState => ({
rows: getRowsFromDiffsHandler(diffs, prevState.controlsMap),
hasDiffs: !isEmpty(diffs),
}));
}

getRowsFromDiffs(diffs, controlsMap) {
}, []);
const getRowsFromDiffsHandler = useCallback((diffs, controlsMap) => {
return Object.entries(diffs).map(([key, diff]) => ({
control: (controlsMap[key] && controlsMap[key].label) || key,
before: this.formatValue(diff.before, key, controlsMap),
after: this.formatValue(diff.after, key, controlsMap),
before: formatValueHandler(diff.before, key, controlsMap),
after: formatValueHandler(diff.after, key, controlsMap),
}));
}

getDiffs(props) {
}, []);
const getDiffsHandler = useCallback((props) => {
// Returns all properties that differ in the
// current form data and the saved form data
const ofd = sanitizeFormData(props.origFormData);
Expand All @@ -107,18 +103,16 @@ export default class AlteredSliceTag extends React.Component {
if (['filters', 'having', 'where'].includes(fdKey)) {
return;
}
if (!this.isEqualish(ofd[fdKey], cfd[fdKey])) {
if (!isEqualishHandler(ofd[fdKey], cfd[fdKey])) {
diffs[fdKey] = { before: ofd[fdKey], after: cfd[fdKey] };
}
});
return diffs;
}

isEqualish(val1, val2) {
}, []);
const isEqualishHandler = useCallback((val1, val2) => {
return isEqual(alterForComparison(val1), alterForComparison(val2));
}

formatValue(value, key, controlsMap) {
}, []);
const formatValueHandler = useCallback((value, key, controlsMap) => {
// Format display value based on the control type
// or the value type
if (value === undefined) {
Expand Down Expand Up @@ -165,9 +159,8 @@ export default class AlteredSliceTag extends React.Component {
return value;
}
return safeStringify(value);
}

renderModalBody() {
}, []);
const renderModalBodyHandler = useCallback(() => {
const columns = [
{
accessor: 'control',
Expand All @@ -188,39 +181,40 @@ export default class AlteredSliceTag extends React.Component {
return (
<TableView
columns={columns}
data={this.state.rows}
data={rows}
pageSize={50}
className="table-condensed"
columnsForWrapText={columnsForWrapText}
/>
);
}

renderTriggerNode() {
}, []);
const renderTriggerNodeHandler = useCallback(() => {
return (
<Tooltip id="difference-tooltip" title={t('Click to see difference')}>
<StyledLabel className="label">{t('Altered')}</StyledLabel>
</Tooltip>
);
}
}, []);

render() {
// Return nothing if there are no differences
if (!this.state.hasDiffs) {
if (!hasDiffs) {
return null;
}
// Render the label-warning 'Altered' tag which the user may
// click to open a modal containing a table summarizing the
// differences in the slice
return (
<ModalTrigger
triggerNode={this.renderTriggerNode()}
triggerNode={renderTriggerNodeHandler()}
modalTitle={t('Chart changes')}
modalBody={this.renderModalBody()}
modalBody={renderModalBodyHandler()}
responsive
/>
);
}
}
);
};

export default AlteredSliceTag;




AlteredSliceTag.propTypes = propTypes;

0 comments on commit c341c76

Please sign in to comment.