Skip to content

Commit

Permalink
Replace selector usage
Browse files Browse the repository at this point in the history
  • Loading branch information
DaryaLari committed Dec 17, 2024
1 parent cc9245a commit e9c22a1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
24 changes: 16 additions & 8 deletions src/ui/units/wizard/components/Dialogs/DialogColor/DialogColor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ import {ALLOWED_FOR_NULL_MODE_VISUALIZATIONS} from 'ui/units/wizard/constants/di
import {setDialogColorPaletteState} from 'units/wizard/actions/dialogColor';
import {selectDataset, selectParameters} from 'units/wizard/selectors/dataset';
import {selectUpdates} from 'units/wizard/selectors/preview';
import {selectDashboardParameters, selectFilters} from 'units/wizard/selectors/visualization';
import {
selectDashboardParameters,
selectFilters,
selectVisualization,
} from 'units/wizard/selectors/visualization';

import {
isGradientDialog,
selectDialogColorGradientState,
selectDialogColorPaletteState,
selectDialogColorVisualizationId,
} from '../../../selectors/dialogColor';

import ColorSettingsContainer from './ColorSettingsContainer/ColorSettingsContainer';
Expand Down Expand Up @@ -90,20 +93,25 @@ class DialogColorComponent extends React.Component<Props, State> {
}

render() {
const {item, items, dataset, isColorModeChangeAvailable, colorSectionFields} = this.props;
const {
item,
items,
dataset,
isColorModeChangeAvailable,
colorSectionFields,
visualization,
} = this.props;
const {mountedColors = {}} = this.props.paletteState;
const {validationStatus} = this.props.gradientState;
const {colorMode} = this.state;

if (!item || !dataset) {
if (!item || !dataset || !visualization) {
return null;
}

const canSetNullMode =
this.props.canSetNullMode &&
(ALLOWED_FOR_NULL_MODE_VISUALIZATIONS as (string | undefined)[]).includes(
this.props.visualizationId,
);
(ALLOWED_FOR_NULL_MODE_VISUALIZATIONS as string[]).includes(visualization.id);

return (
<Dialog open={true} onClose={this.onClose} disableFocusTrap={true}>
Expand Down Expand Up @@ -240,7 +248,7 @@ const mapStateToProps = (state: DatalensGlobalState) => {
dataset: selectDataset(state),
gradientState: selectDialogColorGradientState(state),
paletteState: selectDialogColorPaletteState(state),
visualizationId: selectDialogColorVisualizationId(state),
visualization: selectVisualization(state),
};
};

Expand Down
3 changes: 0 additions & 3 deletions src/ui/units/wizard/selectors/dialogColor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ export const selectDialogColorPaletteState = (state: DatalensGlobalState) =>
export const selectDialogColorGradientState = (state: DatalensGlobalState) =>
state.wizard.dialogColor.gradientState;

export const selectDialogColorVisualizationId = (state: DatalensGlobalState) =>
state.wizard.visualization.visualization?.id;

export const selectClientPaletteColors = (state: DatalensGlobalState) => {
const {palette} = state.wizard.dialogColor.paletteState;
const {colorPalettes} = state.colorPaletteEditor;
Expand Down

0 comments on commit e9c22a1

Please sign in to comment.