Skip to content

Commit

Permalink
feat(Alerts and Reports): Modal redesign (apache#26202)
Browse files Browse the repository at this point in the history
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: fisjac <[email protected]>
Co-authored-by: Corbin <[email protected]>
Co-authored-by: Lily Kuang <[email protected]>
Co-authored-by: Michael S. Molina <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
6 people authored and sfirke committed Mar 22, 2024
1 parent a8f42f6 commit 3380239
Show file tree
Hide file tree
Showing 18 changed files with 1,799 additions and 1,234 deletions.
1 change: 1 addition & 0 deletions superset-frontend/src/GlobalStyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import React from 'react';
import { css } from '@superset-ui/core';
import { Global } from '@emotion/react';
import { mix } from 'polished';
import 'react-js-cron/dist/styles.css';

export const GlobalStyles = () => (
<Global
Expand Down
11 changes: 3 additions & 8 deletions superset-frontend/src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import React, { Children, ReactElement } from 'react';
import { kebabCase } from 'lodash';
import React, { Children, ReactElement, ReactNode } from 'react';
import { mix } from 'polished';
import cx from 'classnames';
import { AntdButton } from 'src/components';
Expand All @@ -43,7 +42,7 @@ export type ButtonSize = 'default' | 'small' | 'xsmall';

export type ButtonProps = Omit<AntdButtonProps, 'css'> &
Pick<TooltipProps, 'placement'> & {
tooltip?: string;
tooltip?: ReactNode;
className?: string;
buttonSize?: ButtonSize;
buttonStyle?: ButtonStyle;
Expand Down Expand Up @@ -214,11 +213,7 @@ export default function Button(props: ButtonProps) {

if (tooltip) {
return (
<Tooltip
placement={placement}
id={`${kebabCase(tooltip)}-tooltip`}
title={tooltip}
>
<Tooltip placement={placement} title={tooltip}>
{/* wrap the button in a span so that the tooltip shows up
when the button is disabled. */}
{disabled ? (
Expand Down
115 changes: 96 additions & 19 deletions superset-frontend/src/components/CronPicker/CronPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const LOCALE: Locale = {
prefixMonths: t('in'),
prefixMonthDays: t('on'),
prefixWeekDays: t('on'),
prefixWeekDaysForMonthAndYearPeriod: t('and'),
prefixWeekDaysForMonthAndYearPeriod: t('or'),
prefixHours: t('at'),
prefixMinutes: t(':'),
prefixMinutesForHourPeriod: t('at'),
Expand Down Expand Up @@ -110,22 +110,99 @@ export const CronPicker = styled((props: CronProps) => (
<ReactCronPicker locale={LOCALE} {...props} />
</ConfigProvider>
))`
.react-js-cron-field {
margin-bottom: 0px;
}
.react-js-cron-select:not(.react-js-cron-custom-select) > div:first-of-type,
.react-js-cron-custom-select {
border-radius: ${({ theme }) => theme.gridUnit}px;
background-color: ${({ theme }) =>
theme.colors.grayscale.light4} !important;
}
.react-js-cron-custom-select > div:first-of-type {
border-radius: ${({ theme }) => theme.gridUnit}px;
}
.react-js-cron-custom-select .ant-select-selection-placeholder {
flex: auto;
}
.react-js-cron-custom-select .ant-select-selection-overflow-item {
align-self: center;
}
${({ theme }) => `
/* Boilerplate styling for ReactCronPicker imported explicitly in GlobalStyles.tsx */
/* When year period is selected */
:has(.react-js-cron-months) {
display: grid !important;
grid-template-columns: repeat(2, 50%);
column-gap: ${theme.gridUnit}px;
row-gap: ${theme.gridUnit * 2}px;
div:has(.react-js-cron-hours) {
grid-column: span 2;
display: flex;
justify-content: space-between;
.react-js-cron-field {
width: 50%;
}
}
}
/* When month period is selected */
:not(:has(.react-js-cron-months)) {
display: grid;
grid-template-columns: repeat(2, 50%);
column-gap: ${theme.gridUnit}px;
row-gap: ${theme.gridUnit * 2}px;
.react-js-cron-period {
grid-column: span 2;
}
div:has(.react-js-cron-hours) {
grid-column: span 2;
display: flex;
justify-content: space-between;
.react-js-cron-field {
width: 50%;
}
}
}
/* When week period is selected */
:not(:has(.react-js-cron-month-days)) {
.react-js-cron-week-days {
grid-column: span 2;
}
}
/* For proper alignment of inputs and span elements */
:not(div:has(.react-js-cron-hours)) {
display: flex;
flex-wrap: nowrap;
}
div:has(.react-js-cron-hours) {
width: 100%;
}
.react-js-cron-minutes > span {
padding-left: ${theme.gridUnit}px;
}
/* Sizing of select container */
.react-js-cron-select.ant-select {
width: 100%;
.ant-select-selector {
flex-wrap: nowrap;
}
}
.react-js-cron-field {
width: 100%;
margin-bottom: 0px;
> span {
margin-left: 0px;
}
}
.react-js-cron-custom-select .ant-select-selection-placeholder {
flex: auto;
border-radius: ${theme.gridUnit}px;
}
.react-js-cron-custom-select .ant-select-selection-overflow-item {
align-self: center;
}
.react-js-cron-select > div:first-of-type,
.react-js-cron-custom-select {
border-radius: ${theme.gridUnit}px;
}
`}
`;
3 changes: 3 additions & 0 deletions superset-frontend/src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface ModalProps {
className?: string;
children: ReactNode;
disablePrimaryButton?: boolean;
primaryTooltipMessage?: ReactNode;
primaryButtonLoading?: boolean;
onHide: () => void;
onHandledPrimaryAction?: () => void;
Expand Down Expand Up @@ -232,6 +233,7 @@ const defaultResizableConfig = (hideFooter: boolean | undefined) => ({
const CustomModal = ({
children,
disablePrimaryButton = false,
primaryTooltipMessage,
primaryButtonLoading = false,
onHide,
onHandledPrimaryAction,
Expand Down Expand Up @@ -274,6 +276,7 @@ const CustomModal = ({
key="submit"
buttonStyle={primaryButtonType}
disabled={disablePrimaryButton}
tooltip={primaryTooltipMessage}
loading={primaryButtonLoading}
onClick={onHandledPrimaryAction}
cta
Expand Down
Loading

0 comments on commit 3380239

Please sign in to comment.