Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/apache/superset into upda…
Browse files Browse the repository at this point in the history
…te-pre-commit
  • Loading branch information
hughhhh committed Mar 13, 2023
2 parents ddb79a8 + d415eed commit a5d61fa
Show file tree
Hide file tree
Showing 30 changed files with 505 additions and 778 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ describe('Dashboard load', () => {
cy.get('#app-menu').should('not.exist');
});

it('should send log data', () => {
// TODO flaky test. skipping to unblock CI
it.skip('should send log data', () => {
interceptLog();
cy.visit(WORLD_HEALTH_DASHBOARD);
cy.wait('@logs', { timeout: 15000 });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@ import { PostProcessingContribution } from '@superset-ui/core';
import { PostProcessingFactory } from './types';

/* eslint-disable @typescript-eslint/no-unused-vars */
export const contributionOperator: PostProcessingFactory<
PostProcessingContribution
> = (formData, queryObject) => {
if (formData.contributionMode) {
return {
operation: 'contribution',
options: {
orientation: formData.contributionMode,
},
};
}
return undefined;
};
export const contributionOperator: PostProcessingFactory<PostProcessingContribution> =
(formData, queryObject) => {
if (formData.contributionMode) {
return {
operation: 'contribution',
options: {
orientation: formData.contributionMode,
},
};
}
return undefined;
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,25 @@ import { ComparisonType, PostProcessingCompare } from '@superset-ui/core';
import { getMetricOffsetsMap, isTimeComparison } from './utils';
import { PostProcessingFactory } from './types';

export const timeCompareOperator: PostProcessingFactory<
PostProcessingCompare
> = (formData, queryObject) => {
const comparisonType = formData.comparison_type;
const metricOffsetMap = getMetricOffsetsMap(formData, queryObject);
export const timeCompareOperator: PostProcessingFactory<PostProcessingCompare> =
(formData, queryObject) => {
const comparisonType = formData.comparison_type;
const metricOffsetMap = getMetricOffsetsMap(formData, queryObject);

if (
isTimeComparison(formData, queryObject) &&
comparisonType !== ComparisonType.Values
) {
return {
operation: 'compare',
options: {
source_columns: Array.from(metricOffsetMap.values()),
compare_columns: Array.from(metricOffsetMap.keys()),
compare_type: comparisonType,
drop_original_columns: true,
},
};
}
if (
isTimeComparison(formData, queryObject) &&
comparisonType !== ComparisonType.Values
) {
return {
operation: 'compare',
options: {
source_columns: Array.from(metricOffsetMap.values()),
compare_columns: Array.from(metricOffsetMap.keys()),
compare_type: comparisonType,
drop_original_columns: true,
},
};
}

return undefined;
};
return undefined;
};
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,31 @@ import {
import { getMetricOffsetsMap, isTimeComparison } from './utils';
import { PostProcessingFactory } from './types';

export const timeComparePivotOperator: PostProcessingFactory<
PostProcessingPivot
> = (formData, queryObject) => {
const metricOffsetMap = getMetricOffsetsMap(formData, queryObject);
const xAxisLabel = getXAxisLabel(formData);
const columns = queryObject.series_columns || queryObject.columns;
export const timeComparePivotOperator: PostProcessingFactory<PostProcessingPivot> =
(formData, queryObject) => {
const metricOffsetMap = getMetricOffsetsMap(formData, queryObject);
const xAxisLabel = getXAxisLabel(formData);
const columns = queryObject.series_columns || queryObject.columns;

if (isTimeComparison(formData, queryObject) && xAxisLabel) {
const aggregates = Object.fromEntries(
[...metricOffsetMap.values(), ...metricOffsetMap.keys()].map(metric => [
metric,
// use the 'mean' aggregates to avoid drop NaN
{ operator: 'mean' as NumpyFunction },
]),
);
if (isTimeComparison(formData, queryObject) && xAxisLabel) {
const aggregates = Object.fromEntries(
[...metricOffsetMap.values(), ...metricOffsetMap.keys()].map(metric => [
metric,
// use the 'mean' aggregates to avoid drop NaN
{ operator: 'mean' as NumpyFunction },
]),
);

return {
operation: 'pivot',
options: {
index: [xAxisLabel],
columns: ensureIsArray(columns).map(getColumnLabel),
drop_missing_columns: !formData?.show_empty_columns,
aggregates,
},
};
}
return {
operation: 'pivot',
options: {
index: [xAxisLabel],
columns: ensureIsArray(columns).map(getColumnLabel),
drop_missing_columns: !formData?.show_empty_columns,
aggregates,
},
};
}

return undefined;
};
return undefined;
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import React, { useMemo } from 'react';
import ReactMarkdown from 'react-markdown';
import rehypeSanitize, { defaultSchema } from 'rehype-sanitize';
import rehypeRaw from 'rehype-raw';
import { merge } from 'lodash';
import { mergeWith, isArray } from 'lodash';
import { FeatureFlag, isFeatureEnabled } from '../utils';

interface SafeMarkdownProps {
Expand All @@ -29,6 +29,15 @@ interface SafeMarkdownProps {
htmlSchemaOverrides?: typeof defaultSchema;
}

export function getOverrideHtmlSchema(
originalSchema: typeof defaultSchema,
htmlSchemaOverrides: SafeMarkdownProps['htmlSchemaOverrides'],
) {
return mergeWith(originalSchema, htmlSchemaOverrides, (objValue, srcValue) =>
isArray(objValue) ? objValue.concat(srcValue) : undefined,
);
}

function SafeMarkdown({
source,
htmlSanitization = true,
Expand All @@ -42,7 +51,10 @@ function SafeMarkdown({
if (displayHtml && !escapeHtml) {
rehypePlugins.push(rehypeRaw);
if (htmlSanitization) {
const schema = merge(defaultSchema, htmlSchemaOverrides);
const schema = getOverrideHtmlSchema(
defaultSchema,
htmlSchemaOverrides,
);
rehypePlugins.push([rehypeSanitize, schema]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,24 @@
* specific language governing permissions and limitations
* under the License.
*/
import { FormInstance } from 'src/components';
import { getOverrideHtmlSchema } from '../../src/components/SafeMarkdown';

// eslint-disable-next-line import/prefer-default-export
export const setCrossFilterFieldValues = (
form: FormInstance,
values: object,
) => {
form.setFieldsValue({
...values,
describe('getOverrideHtmlSchema', () => {
it('should append the override items', () => {
const original = {
attributes: {
'*': ['size'],
},
clobberPrefix: 'original-prefix',
tagNames: ['h1', 'h2', 'h3'],
};
const result = getOverrideHtmlSchema(original, {
attributes: { '*': ['src'], h1: ['style'] },
clobberPrefix: 'custom-prefix',
tagNames: ['iframe'],
});
expect(result.clobberPrefix).toEqual('custom-prefix');
expect(result.attributes).toEqual({ '*': ['size', 'src'], h1: ['style'] });
expect(result.tagNames).toEqual(['h1', 'h2', 'h3', 'iframe']);
});
};
});
5 changes: 3 additions & 2 deletions superset-frontend/src/assets/images/icons/filter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion superset-frontend/src/assets/staticPages/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
under the License.
-->

<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/assets/staticPages/500.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
under the License.
-->

<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand Down
31 changes: 15 additions & 16 deletions superset-frontend/src/components/DeprecatedSelect/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,22 +92,21 @@ export type ThemeConfig = {

export type PartialThemeConfig = RecursivePartial<ThemeConfig>;

export const defaultTheme: (
theme: SupersetTheme,
) => PartialThemeConfig = theme => ({
borderRadius: theme.borderRadius,
zIndex: 11,
colors: colors(theme),
spacing: {
baseUnit: 3,
menuGutter: 0,
controlHeight: 34,
lineHeight: 19,
fontSize: 14,
minWidth: '6.5em',
},
weights: theme.typography.weights,
});
export const defaultTheme: (theme: SupersetTheme) => PartialThemeConfig =
theme => ({
borderRadius: theme.borderRadius,
zIndex: 11,
colors: colors(theme),
spacing: {
baseUnit: 3,
menuGutter: 0,
controlHeight: 34,
lineHeight: 19,
fontSize: 14,
minWidth: '6.5em',
},
weights: theme.typography.weights,
});

// let styles accept serialized CSS, too
type CSSStyles = CSSProperties | SerializedStyles;
Expand Down
5 changes: 2 additions & 3 deletions superset-frontend/src/components/TableSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,7 @@ const TableSelector: FunctionComponent<TableSelectorProps> = ({
);
};

export const TableSelectorMultiple: FunctionComponent<
TableSelectorProps
> = props => <TableSelector tableSelectMode="multiple" {...props} />;
export const TableSelectorMultiple: FunctionComponent<TableSelectorProps> =
props => <TableSelector tableSelectMode="multiple" {...props} />;

export default TableSelector;
31 changes: 15 additions & 16 deletions superset-frontend/src/components/UiConfigContext/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,19 @@ export const UiConfigContext = createContext<UiConfigType>({

export const useUiConfig = () => useContext(UiConfigContext);

export const EmbeddedUiConfigProvider: React.FC<
EmbeddedUiConfigProviderProps
> = ({ children }) => {
const config = getUrlParam(URL_PARAMS.uiConfig) || 0;
const [embeddedConfig] = useState({
hideTitle: (config & 1) !== 0,
hideTab: (config & 2) !== 0,
hideNav: (config & 4) !== 0,
hideChartControls: (config & 8) !== 0,
});
export const EmbeddedUiConfigProvider: React.FC<EmbeddedUiConfigProviderProps> =
({ children }) => {
const config = getUrlParam(URL_PARAMS.uiConfig) || 0;
const [embeddedConfig] = useState({
hideTitle: (config & 1) !== 0,
hideTab: (config & 2) !== 0,
hideNav: (config & 4) !== 0,
hideChartControls: (config & 8) !== 0,
});

return (
<UiConfigContext.Provider value={embeddedConfig}>
{children}
</UiConfigContext.Provider>
);
};
return (
<UiConfigContext.Provider value={embeddedConfig}>
{children}
</UiConfigContext.Provider>
);
};

This file was deleted.

Loading

0 comments on commit a5d61fa

Please sign in to comment.