Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update field selection table row actions #1506

Merged
merged 25 commits into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a1e2115
Update field selection table row actions
kiahna-tucker Mar 11, 2025
973ac3e
Reorder row actions
kiahna-tucker Mar 12, 2025
2b20faf
Reorder row actions
kiahna-tucker Mar 12, 2025
3b972c3
Merge branch 'main' into kiahna-tucker/field-selection/redesign-row-a…
kiahna-tucker Mar 13, 2025
90d1169
Merge branch 'main' into kiahna-tucker/field-selection/redesign-row-a…
kiahna-tucker Mar 19, 2025
b887a22
Track field selection interactions in LogRocket
kiahna-tucker Mar 19, 2025
d8ed07e
Placeholder: refactor OutlinedToggleButton component
kiahna-tucker Mar 20, 2025
0cb4cf6
Merge branch 'main' into kiahna-tucker/field-selection/redesign-row-a…
kiahna-tucker Mar 21, 2025
612e2e4
Remove field selection-specific style objects
kiahna-tucker Mar 21, 2025
189ec31
Share click handler
kiahna-tucker Mar 24, 2025
086ded9
Display tooltip on disabled row action
kiahna-tucker Mar 24, 2025
2fe9686
Position tooltip for select action
kiahna-tucker Mar 24, 2025
918e6c7
Merge branch 'main' into kiahna-tucker/field-selection/redesign-row-a…
kiahna-tucker Mar 24, 2025
33de216
Merge branch 'main' into kiahna-tucker/field-selection/redesign-row-a…
kiahna-tucker Mar 25, 2025
91d8ee1
Remove alpha material util from theme
kiahna-tucker Mar 25, 2025
5f35de9
Merge branch 'main' into kiahna-tucker/field-selection/redesign-row-a…
kiahna-tucker Mar 25, 2025
4c19c89
Replace instances of FormattedMessage in StatTypeSelector
kiahna-tucker Mar 25, 2025
d81627b
Pass entire css selector to OutlinedToggleButtonGroup
kiahna-tucker Mar 25, 2025
16cdfe1
Store custom toggle button class in a constant
kiahna-tucker Mar 25, 2025
5ab4ddd
Change how colorKey evaluated to determine the hover border color
kiahna-tucker Mar 25, 2025
541e94b
Pass tooltip props to FieldActionButton component
kiahna-tucker Mar 25, 2025
9f53f4e
Create object which stores constraint message ids
kiahna-tucker Mar 25, 2025
68cc884
Remove types and functions from field selection component files
kiahna-tucker Mar 25, 2025
d7b6860
Prevent custom toggle button group prop from being forwarded to compo…
kiahna-tucker Mar 26, 2025
d2aafd6
Do not update draft if field selection mode has not changed
kiahna-tucker Mar 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ function BackfillButton({

<Stack direction="row" spacing={2}>
<BooleanToggleButton
size={bindingIndex === -1 ? 'large' : undefined}
size="small"
selected={Boolean(selected || reversioned)}
disabled={disabled || reversioned}
onClick={(event, checked: string) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { optionalColumnIntlKeys } from 'components/tables/FieldSelection';
import { optionalColumnIntlKeys } from 'components/tables/FieldSelection/shared';
import SelectColumnMenu from 'components/tables/SelectColumnMenu';
import { useDisplayTableColumns } from 'context/TableSettings';
import { SyntheticEvent } from 'react';
import { TablePrefixes } from 'stores/Tables/hooks';
import { TableColumns } from 'types';
import { WithRequiredNonNullProperty } from 'types/utils';
import { hasLength } from 'utils/misc-utils';
import { TableColumnSelectorProps } from './types';

interface Props {
columns: TableColumns[];
loading: boolean;
}

export default function TableColumnSelector({ columns, loading }: Props) {
export default function TableColumnSelector({
columns,
loading,
}: TableColumnSelectorProps) {
const { tableSettings, setTableSettings } = useDisplayTableColumns();

const optionalColumns = columns.filter(
Expand Down
14 changes: 3 additions & 11 deletions src/components/editor/Bindings/FieldSelection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ import {
} from 'stores/FormState/hooks';
import { FormStatus } from 'stores/FormState/types';
import { Schema } from 'types';
import {
getBindingIndex,
isExcludeOnlyField,
isRequireOnlyField,
} from 'utils/workflow-utils';
import { getBindingIndex } from 'utils/workflow-utils';
import RefreshStatus from './RefreshStatus';

interface Props {
Expand Down Expand Up @@ -82,12 +78,8 @@ const mapConstraintsToProjections = (
selectionMetadata = require[field];
} else if (exclude?.includes(field)) {
selectionType = 'exclude';
} else if (!recommended && constraint) {
selectionType = isRequireOnlyField(constraint.type)
? 'require'
: isExcludeOnlyField(constraint.type)
? 'exclude'
: null;
} else if (typeof recommended === 'boolean' && !recommended) {
selectionType = null;
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/components/editor/Bindings/FieldSelection/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Schema } from 'types';
import { Schema, TableColumns } from 'types';

export interface Projection {
field: string;
Expand Down Expand Up @@ -71,3 +71,8 @@ export interface CompositeProjection extends Projection {
selectionType: FieldSelectionType | null;
selectionMetadata?: Schema;
}

export interface TableColumnSelectorProps {
columns: TableColumns[];
loading: boolean;
}
19 changes: 8 additions & 11 deletions src/components/graphs/DataByHourGraph/StatTypeSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
import { ToggleButtonGroup } from '@mui/material';
import OutlinedToggleButton from 'components/shared/buttons/OutlinedToggleButton';
import { outlinedToggleButtonGroupStyling } from 'context/Theme';
import { FormattedMessage } from 'react-intl';
import OutlinedToggleButtonGroup from 'components/shared/OutlinedToggleButtonGroup';
import { useIntl } from 'react-intl';
import { useDetailsUsageStore } from 'stores/DetailsUsage/useDetailsUsageStore';

function StatTypeSelector() {
const intl = useIntl();

const [statType, setStatType] = useDetailsUsageStore((store) => [
store.statType,
store.setStatType,
]);

return (
<ToggleButtonGroup
size="small"
exclusive
sx={outlinedToggleButtonGroupStyling}
>
<OutlinedToggleButtonGroup size="small" exclusive>
<OutlinedToggleButton
size="small"
value="bytes"
selected={statType === 'bytes'}
onClick={() => setStatType('bytes')}
>
<FormattedMessage id="data.data" />
{intl.formatMessage({ id: 'data.data' })}
</OutlinedToggleButton>

<OutlinedToggleButton
Expand All @@ -31,9 +28,9 @@ function StatTypeSelector() {
selected={statType === 'docs'}
onClick={() => setStatType('docs')}
>
<FormattedMessage id="data.docs" />
{intl.formatMessage({ id: 'data.docs' })}
</OutlinedToggleButton>
</ToggleButtonGroup>
</OutlinedToggleButtonGroup>
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box, ToggleButtonGroup } from '@mui/material';
import { Box } from '@mui/material';
import OutlinedToggleButton from 'components/shared/buttons/OutlinedToggleButton';
import { outlinedToggleButtonGroupStyling } from 'context/Theme';
import OutlinedToggleButtonGroup from 'components/shared/OutlinedToggleButtonGroup';
import { useIntl } from 'react-intl';
import { useEntityStatusStore } from 'stores/EntityStatus/Store';

Expand All @@ -12,11 +12,7 @@ export default function SectionFormatter() {

return (
<Box style={{ paddingTop: 4 }}>
<ToggleButtonGroup
size="small"
exclusive
sx={outlinedToggleButtonGroupStyling}
>
<OutlinedToggleButtonGroup size="small" exclusive>
<OutlinedToggleButton
size="small"
value="dashboard"
Expand All @@ -36,7 +32,7 @@ export default function SectionFormatter() {
>
{intl.formatMessage({ id: 'details.ops.status.cta.raw' })}
</OutlinedToggleButton>
</ToggleButtonGroup>
</OutlinedToggleButtonGroup>
</Box>
);
}
14 changes: 5 additions & 9 deletions src/components/shared/Entity/Details/Spec/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Grid, Stack, ToggleButtonGroup, Typography } from '@mui/material';
import { Grid, Stack, Typography } from '@mui/material';
import LiveSpecEditor from 'components/editor/LiveSpec';
import ExternalLink from 'components/shared/ExternalLink';
import OutlinedToggleButton from 'components/shared/buttons/OutlinedToggleButton';
import ExternalLink from 'components/shared/ExternalLink';
import OutlinedToggleButtonGroup from 'components/shared/OutlinedToggleButtonGroup';
import { useEntityType } from 'context/EntityContext';
import { outlinedToggleButtonGroupStyling } from 'context/Theme';
import { useCallback, useMemo, useState } from 'react';
import { FormattedMessage } from 'react-intl';
import CollectionSpecViews from './CollectionViews';
Expand Down Expand Up @@ -61,11 +61,7 @@ function Spec() {
</Stack>

{entityType === 'collection' ? (
<ToggleButtonGroup
size="small"
exclusive
sx={outlinedToggleButtonGroupStyling}
>
<OutlinedToggleButtonGroup size="small" exclusive>
<OutlinedToggleButton
size="small"
value="table"
Expand All @@ -87,7 +83,7 @@ function Spec() {
>
<FormattedMessage id="details.spec.cta.raw" />
</OutlinedToggleButton>
</ToggleButtonGroup>
</OutlinedToggleButtonGroup>
) : null}
</Stack>

Expand Down
31 changes: 31 additions & 0 deletions src/components/shared/OutlinedToggleButtonGroup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {
styled,
ToggleButtonGroup,
ToggleButtonGroupProps,
} from '@mui/material';

const OutlinedToggleButtonGroup = styled(ToggleButtonGroup, {
shouldForwardProp: (props) => props !== 'buttonSelector',
})<ToggleButtonGroupProps & { buttonSelector?: string }>(
({ buttonSelector }) => ({
[`${buttonSelector ?? '& .MuiToggleButton-root'}`]: {
'&:not(:first-of-type), &:not(:last-of-type)': {
borderRadius: 0,
},
'&:first-of-type': {
borderTopLeftRadius: 4,
borderBottomLeftRadius: 4,
borderTopRightRadius: 0,
borderBottomRightRadius: 0,
},
'&:last-of-type': {
borderTopLeftRadius: 0,
borderBottomLeftRadius: 0,
borderTopRightRadius: 4,
borderBottomRightRadius: 4,
},
},
})
);

export default OutlinedToggleButtonGroup;
110 changes: 39 additions & 71 deletions src/components/shared/buttons/OutlinedToggleButton.tsx
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should eventually live somewhere else. We probably want to put all the styled stuff in a single spot near the theme (and break that thing up). We should also probably just use our own ToggleButton that can be outlined or not and then stop using the MUI one all together.

Original file line number Diff line number Diff line change
@@ -1,85 +1,53 @@
import {
SxProps,
Theme,
ToggleButton,
toggleButtonClasses,
useTheme,
} from '@mui/material';
import { styled, ToggleButton, toggleButtonClasses } from '@mui/material';
import {
defaultOutline,
defaultOutline_hovered,
disabledButtonText,
disabledButtonText_primary,
intensifiedOutline,
outlinedButtonBackground,
outlinedButtonBackground_disabled,
primaryColoredOutline,
primaryColoredOutline_disabled,
primaryColoredOutline_hovered,
} from 'context/Theme';
import { OutlinedToggleButtonProps } from './types';

function OutlinedToggleButton({
children,
defaultStateSx,
disabled,
disabledStateSx,
selectedStateSx,
const OutlinedToggleButton = styled(ToggleButton)(({
color,
selected,
value,
onChange,
onClick,
...props
}: OutlinedToggleButtonProps) {
const theme = useTheme();

const defaultDisabledStateSx: SxProps<Theme> = selected
? {
backgroundColor:
outlinedButtonBackground_disabled[theme.palette.mode],
border: primaryColoredOutline_disabled[theme.palette.mode],
color: disabledButtonText_primary[theme.palette.mode],
}
: {
backgroundColor: 'none',
border: defaultOutline[theme.palette.mode],
color: disabledButtonText[theme.palette.mode],
};
theme,
}) => {
const colorKey = color ?? 'primary';

let sx: SxProps<Theme> = {
px: '9px',
py: '3px',
border: intensifiedOutline[theme.palette.mode],
borderRadius: 2,
[`&.${toggleButtonClasses.selected}`]: selectedStateSx ?? {
'backgroundColor': outlinedButtonBackground[theme.palette.mode],
'border': primaryColoredOutline[theme.palette.mode],
'color': theme.palette.primary.main,
return {
'padding': '3px 9px',
'border': intensifiedOutline[theme.palette.mode],
'borderRadius': 4,
'&:hover': {
border: defaultOutline_hovered[theme.palette.mode],
},
[`&.${toggleButtonClasses.selected}`]: {
'backgroundColor': theme.palette[colorKey].alpha_12,
'border': `1px solid ${theme.palette[colorKey].alpha_50}`,
'color':
theme.palette.mode === 'light'
? theme.palette[colorKey].dark
: theme.palette[colorKey].main,
'&:hover': {
border: primaryColoredOutline_hovered[theme.palette.mode],
border: `1px solid ${
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We eventually might need to look at not using the shorthand settings when doing more complex settings and just break the properties up.

theme.palette.mode === 'light' &&
['success', 'info'].includes(colorKey)
? theme.palette[colorKey].dark
: theme.palette[colorKey].main
}`,
},
},
[`&.${toggleButtonClasses.disabled}`]:
disabledStateSx ?? defaultDisabledStateSx,
[`&.${toggleButtonClasses.disabled}`]: selected
? {
backgroundColor: theme.palette[colorKey].alpha_05,
border: `1px solid ${theme.palette[colorKey].alpha_12}`,
color: theme.palette[colorKey].alpha_26,
}
: {
backgroundColor: 'none',
border: defaultOutline[theme.palette.mode],
color: disabledButtonText[theme.palette.mode],
},
};

if (defaultStateSx) {
sx = { ...sx, ...defaultStateSx };
}

return (
<ToggleButton
size="small"
{...props}
value={value}
selected={selected}
disabled={disabled}
onChange={onChange}
onClick={onClick}
sx={sx}
>
{children}
</ToggleButton>
);
}
});

export default OutlinedToggleButton;
Loading