fix: Color consistency (#17089)

* Update label colors on the fly

* Clean up

* Improve getFormDataWithExtraFilters

* Improve code structure

* Remove labelColors from formData

* Exclude label_colors from URL

* Refactor color scheme implementation

* Clean up

* Refactor and simplify

* Fix lint

* Remove unnecessary ColorMapControl

* Lint

* Give json color scheme precedence

* Add label_colors prop in metadata

* Separate owners and dashboard meta requests

* Remove label_colors control

* bump superset-ui 0.18.19

* Fix end of file

* Update tests

* Fix lint

* Update Cypress

* Update setColorScheme method

* Use Antd modal body
This commit is contained in:
Geido
2021-11-03 19:22:38 +02:00
committed by GitHub
parent 85a19a9cc2
commit 59a6502efe
26 changed files with 488 additions and 500 deletions

View File

@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import React, { useMemo, useState, useEffect, useCallback } from 'react';
import React, { useMemo, useState, useCallback, useEffect } from 'react';
import Modal from 'src/components/Modal';
import { Row, Col, Input, TextArea } from 'src/common/components';
import Button from 'src/components/Button';
@@ -33,6 +33,8 @@ type PropertiesModalProps = {
show: boolean;
onHide: () => void;
onSave: (chart: Chart) => void;
permissionsError?: string;
existingOwners?: SelectValue;
};
export default function PropertiesModal({
@@ -42,16 +44,15 @@ export default function PropertiesModal({
show,
}: PropertiesModalProps) {
const [submitting, setSubmitting] = useState(false);
const [selectedOwners, setSelectedOwners] = useState<SelectValue | null>(
null,
);
// values of form inputs
const [name, setName] = useState(slice.slice_name || '');
const [description, setDescription] = useState(slice.description || '');
const [cacheTimeout, setCacheTimeout] = useState(
slice.cache_timeout != null ? slice.cache_timeout : '',
);
const [selectedOwners, setSelectedOwners] = useState<SelectValue | null>(
null,
);
function showError({ error, statusText, message }: any) {
let errorText = error || statusText || t('An error has occurred');
@@ -65,8 +66,8 @@ export default function PropertiesModal({
});
}
const fetchChartData = useCallback(
async function fetchChartData() {
const fetchChartOwners = useCallback(
async function fetchChartOwners() {
try {
const response = await SupersetClient.get({
endpoint: `/api/v1/chart/${slice.slice_id}`,
@@ -143,8 +144,8 @@ export default function PropertiesModal({
// get the owners of this slice
useEffect(() => {
fetchChartData();
}, [fetchChartData]);
fetchChartOwners();
}, [fetchChartOwners]);
// update name after it's changed in another modal
useEffect(() => {
@@ -242,8 +243,8 @@ export default function PropertiesModal({
mode="multiple"
name="owners"
value={selectedOwners || []}
options={loadOptions}
onChange={setSelectedOwners}
options={loadOptions}
disabled={!selectedOwners}
allowClear
/>