Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…nto add-classNames-to-superset-filter-buttons
  • Loading branch information
Nithin Philips authored and Nithin Philips committed Nov 26, 2021
2 parents fea4144 + 2e29f36 commit f190247
Show file tree
Hide file tree
Showing 74 changed files with 959 additions and 226 deletions.
20 changes: 20 additions & 0 deletions docs/src/pages/docs/Connecting to Databases/elasticsearch.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,23 @@ POST /_aliases
```

Then register your table with the alias name logstasg_all

**Time zone**

By default, Superset uses UTC time zone for elasticsearch query. If you need to specify a time zone,
please edit your Database and enter the settings of your specified time zone in the Other > ENGINE PARAMETERS:


```
{
"connect_args": {
"time_zone": "Asia/Shanghai"
}
}
```

Another issue to note about the time zone problem is that before elasticsearch7.8, if you want to convert a string into a `DATETIME` object,
you need to use the `CAST` function,but this function does not support our `time_zone` setting. So it is recommended to upgrade to the version after elasticsearch7.8.
After elasticsearch7.8, you can use the `DATETIME_PARSE` function to solve this problem.
The DATETIME_PARSE function is to support our `time_zone` setting, and here you need to fill in your elasticsearch version number in the Other > VERSION setting.
the superset will use the `DATETIME_PARSE` function for conversion.
2 changes: 2 additions & 0 deletions superset-frontend/src/components/ListView/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,6 @@ export enum FilterOperator {
between = 'between',
dashboardIsFav = 'dashboard_is_favorite',
chartIsFav = 'chart_is_favorite',
chartIsCertified = 'chart_is_certified',
dashboardIsCertified = 'dashboard_is_certified',
}
17 changes: 16 additions & 1 deletion superset-frontend/src/components/ListViewCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { styled, useTheme } from '@superset-ui/core';
import { AntdCard, Skeleton, ThinSkeleton } from 'src/common/components';
import { Tooltip } from 'src/components/Tooltip';
import ImageLoader, { BackgroundPosition } from './ImageLoader';
import CertifiedIcon from '../CertifiedIcon';

const ActionsWrapper = styled.div`
width: 64px;
Expand Down Expand Up @@ -161,6 +162,8 @@ interface CardProps {
rows?: number | string;
avatar?: React.ReactElement | null;
cover?: React.ReactNode | null;
certifiedBy?: string;
certificationDetails?: string;
}

function ListViewCard({
Expand All @@ -178,6 +181,8 @@ function ListViewCard({
loading,
imgPosition = 'top',
cover,
certifiedBy,
certificationDetails,
}: CardProps) {
const Link = url && linkComponent ? linkComponent : AnchorLink;
const theme = useTheme();
Expand Down Expand Up @@ -249,7 +254,17 @@ function ListViewCard({
<TitleContainer>
<Tooltip title={title}>
<TitleLink>
<Link to={url!}>{title}</Link>
<Link to={url!}>
{certifiedBy && (
<>
<CertifiedIcon
certifiedBy={certifiedBy}
details={certificationDetails}
/>{' '}
</>
)}
{title}
</Link>
</TitleLink>
</Tooltip>
{titleRight && <TitleRight>{titleRight}</TitleRight>}
Expand Down
11 changes: 11 additions & 0 deletions superset-frontend/src/dashboard/components/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { styled, t } from '@superset-ui/core';
import ButtonGroup from 'src/components/ButtonGroup';
import CertifiedIcon from 'src/components/CertifiedIcon';

import {
LOG_ACTIONS_PERIODIC_RENDER_DASHBOARD,
Expand Down Expand Up @@ -498,6 +499,14 @@ class Header extends React.PureComponent {
data-test-id={`${dashboardInfo.id}`}
>
<div className="dashboard-component-header header-large">
{dashboardInfo.certified_by && (
<>
<CertifiedIcon
certifiedBy={dashboardInfo.certified_by}
details={dashboardInfo.certification_details}
/>{' '}
</>
)}
<EditableTitle
title={dashboardTitle}
canEdit={userCanEdit && editMode}
Expand Down Expand Up @@ -616,6 +625,8 @@ class Header extends React.PureComponent {
dashboardInfoChanged({
slug: updates.slug,
metadata: JSON.parse(updates.jsonMetadata),
certified_by: updates.certifiedBy,
certification_details: updates.certificationDetails,
});
setColorSchemeAndUnsavedChanges(updates.colorScheme);
dashboardTitleChanged(updates.title);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ fetchMock.get(
fetchMock.get('http://localhost/api/v1/dashboard/26', {
body: {
result: {
certified_by: 'John Doe',
certification_details: 'Sample certification',
changed_by: null,
changed_by_name: '',
changed_by_url: '',
Expand Down Expand Up @@ -121,6 +123,8 @@ fetchMock.get('http://localhost/api/v1/dashboard/26', {
});

const createProps = () => ({
certified_by: 'John Doe',
certification_details: 'Sample certification',
dashboardId: 26,
show: true,
colorScheme: 'supersetColors',
Expand Down Expand Up @@ -155,15 +159,18 @@ test('should render - FeatureFlag disabled', async () => {
expect(screen.getByRole('heading', { name: 'Access' })).toBeInTheDocument();
expect(screen.getByRole('heading', { name: 'Colors' })).toBeInTheDocument();
expect(screen.getByRole('heading', { name: 'Advanced' })).toBeInTheDocument();
expect(screen.getAllByRole('heading')).toHaveLength(4);
expect(
screen.getByRole('heading', { name: 'Certification' }),
).toBeInTheDocument();
expect(screen.getAllByRole('heading')).toHaveLength(5);

expect(screen.getByRole('button', { name: 'Close' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Advanced' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Cancel' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Save' })).toBeInTheDocument();
expect(screen.getAllByRole('button')).toHaveLength(4);

expect(screen.getAllByRole('textbox')).toHaveLength(2);
expect(screen.getAllByRole('textbox')).toHaveLength(4);
expect(screen.getByRole('combobox')).toBeInTheDocument();

expect(spyColorSchemeControlWrapper).toBeCalledTimes(4);
Expand Down Expand Up @@ -192,15 +199,18 @@ test('should render - FeatureFlag enabled', async () => {
).toBeInTheDocument();
expect(screen.getByRole('heading', { name: 'Access' })).toBeInTheDocument();
expect(screen.getByRole('heading', { name: 'Advanced' })).toBeInTheDocument();
expect(screen.getAllByRole('heading')).toHaveLength(3);
expect(
screen.getByRole('heading', { name: 'Certification' }),
).toBeInTheDocument();
expect(screen.getAllByRole('heading')).toHaveLength(4);

expect(screen.getByRole('button', { name: 'Close' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Advanced' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Cancel' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Save' })).toBeInTheDocument();
expect(screen.getAllByRole('button')).toHaveLength(4);

expect(screen.getAllByRole('textbox')).toHaveLength(2);
expect(screen.getAllByRole('textbox')).toHaveLength(4);
expect(screen.getAllByRole('combobox')).toHaveLength(2);

expect(spyColorSchemeControlWrapper).toBeCalledTimes(4);
Expand All @@ -220,10 +230,10 @@ test('should open advance', async () => {
await screen.findByTestId('dashboard-edit-properties-form'),
).toBeInTheDocument();

expect(screen.getAllByRole('textbox')).toHaveLength(2);
expect(screen.getAllByRole('textbox')).toHaveLength(4);
expect(screen.getAllByRole('combobox')).toHaveLength(2);
userEvent.click(screen.getByRole('button', { name: 'Advanced' }));
expect(screen.getAllByRole('textbox')).toHaveLength(3);
expect(screen.getAllByRole('textbox')).toHaveLength(5);
expect(screen.getAllByRole('combobox')).toHaveLength(2);
});

Expand Down Expand Up @@ -319,3 +329,18 @@ test('submitting with onlyApply:true', async () => {
expect(props.onSubmit).toBeCalledTimes(1);
});
});

test('Empty "Certified by" should clear "Certification details"', async () => {
const props = createProps();
const noCertifiedByProps = {
...props,
certified_by: '',
};
render(<PropertiesModal {...noCertifiedByProps} />, {
useRedux: true,
});

expect(
screen.getByRole('textbox', { name: 'Certification details' }),
).toHaveValue('');
});
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ class PropertiesModal extends React.PureComponent {
roles: [],
json_metadata: '',
colorScheme: props.colorScheme,
certified_by: '',
certification_details: '',
},
isDashboardLoaded: false,
isAdvancedOpen: false,
Expand Down Expand Up @@ -221,6 +223,8 @@ class PropertiesModal extends React.PureComponent {
? jsonStringify(jsonMetadataObj)
: '',
colorScheme: jsonMetadataObj.color_scheme,
certified_by: dashboard.certified_by || '',
certification_details: dashboard.certification_details || '',
},
}));
const initialSelectedOwners = dashboard.owners.map(owner => ({
Expand Down Expand Up @@ -260,6 +264,8 @@ class PropertiesModal extends React.PureComponent {
slug,
dashboard_title: dashboardTitle,
colorScheme,
certified_by: certifiedBy,
certification_details: certificationDetails,
owners: ownersValue,
roles: rolesValue,
},
Expand Down Expand Up @@ -294,6 +300,8 @@ class PropertiesModal extends React.PureComponent {
jsonMetadata,
ownerIds: owners,
colorScheme: currentColorScheme,
certifiedBy,
certificationDetails,
...moreProps,
});
this.props.onHide();
Expand All @@ -306,6 +314,9 @@ class PropertiesModal extends React.PureComponent {
slug: slug || null,
json_metadata: jsonMetadata || null,
owners,
certified_by: certifiedBy || null,
certification_details:
certifiedBy && certificationDetails ? certificationDetails : null,
...morePutProps,
}),
}).then(({ json: { result } }) => {
Expand All @@ -321,6 +332,8 @@ class PropertiesModal extends React.PureComponent {
jsonMetadata: result.json_metadata,
ownerIds: result.owners,
colorScheme: currentColorScheme,
certifiedBy: result.certified_by,
certificationDetails: result.certification_details,
...moreResultProps,
});
this.props.onHide();
Expand Down Expand Up @@ -515,6 +528,45 @@ class PropertiesModal extends React.PureComponent {
{isFeatureEnabled(FeatureFlag.DASHBOARD_RBAC)
? this.getRowsWithRoles()
: this.getRowsWithoutRoles()}
<Row>
<Col xs={24} md={24}>
<h3>{t('Certification')}</h3>
</Col>
</Row>
<Row gutter={16}>
<Col xs={24} md={12}>
<FormItem label={t('Certified by')}>
<Input
aria-label={t('Certified by')}
name="certified_by"
type="text"
value={values.certified_by}
onChange={this.onChange}
disabled={!isDashboardLoaded}
/>
<p className="help-block">
{t('Person or group that has certified this dashboard.')}
</p>
</FormItem>
</Col>
<Col xs={24} md={12}>
<FormItem label={t('Certification details')}>
<Input
aria-label={t('Certification details')}
name="certification_details"
type="text"
value={values.certification_details || ''}
onChange={this.onChange}
disabled={!isDashboardLoaded}
/>
<p className="help-block">
{t(
'Any additional detail to show in the certification tooltip.',
)}
</p>
</FormItem>
</Col>
</Row>
<Row>
<Col xs={24} md={24}>
<h3 style={{ marginTop: '1em' }}>
Expand Down
58 changes: 0 additions & 58 deletions superset-frontend/src/dashboard/components/dnd/DragHandle.jsx

This file was deleted.

Loading

0 comments on commit f190247

Please sign in to comment.