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

feat: Table with feature overview cell #6713

Merged
merged 2 commits into from
Mar 27, 2024
Merged

Conversation

kwasniew
Copy link
Contributor

@kwasniew kwasniew commented Mar 27, 2024

About the changes

This PR is only 80 LOC. 500 LOC is copy paste of the old table component that will be removed soon. I renamed the previous version to keep the history for the evolving component.

Old table:
Screenshot 2024-03-27 at 11 37 24

New table:
Screenshot 2024-03-27 at 11 37 42

Improved flag type tooltip
Screenshot 2024-03-27 at 11 39 46

Tooltip for long tag names
Screenshot 2024-03-27 at 11 39 25

Adjusted row selector and favourite spacing
Screenshot 2024-03-27 at 11 39 19

Important files

Discussion points

Copy link

vercel bot commented Mar 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 27, 2024 10:43am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Mar 27, 2024 10:43am

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a comment

Choose a reason for hiding this comment

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

Code Health Quality Gates: FAILED

  • Declining Code Health: 1 findings(s) 🚩
  • Improving Code Health: 0 findings(s) ✅
  • Affected Hotspots: 0 files(s) 🔥

Recommended Review Level: Detailed -- Inspect the code that degrades in code health.
View detailed results in CodeScene

🚩 Declining Code Health (highest to lowest):

Comment on lines +130 to +337
featureEnvironment.variantCount &&
featureEnvironment.variantCount > 0 &&
featureEnvironment.enabled,
) || false,
}),
{
id: formatEnvironmentColumnId(name),
header: name,
meta: {
align: 'center',
width: 90,
},
cell: ({ getValue }) => {
const {
featureId,
environment,
someEnabledEnvironmentHasVariants,
} = getValue();

return (
<FeatureToggleCell
value={environment?.enabled || false}
featureId={featureId}
someEnabledEnvironmentHasVariants={
someEnabledEnvironmentHasVariants
}
environment={environment}
projectId={projectId}
environmentName={name}
isChangeRequestEnabled={
isChangeRequestEnabled
}
refetch={refetch}
onFeatureToggleSwitch={onFeatureToggle}
/>
);
},
},
);
}),
columnHelper.display({
id: 'actions',
header: '',
cell: ({ row }) => (
<ActionsCell
row={row}
projectId={projectId}
onOpenArchiveDialog={setFeatureArchiveState}
onOpenStaleDialog={setFeatureStaleDialogState}
/>
),
enableSorting: false,
enableHiding: false,
meta: {
align: 'right',
width: '1%',
},
}),
],
[projectId, environments, tableState.favoritesFirst, refetch],
);

const placeholderData = useMemo(
() =>
Array(tableState.limit)
.fill(null)
.map((_, index) => ({
id: index,
type: '-',
name: `Feature name ${index}`,
createdAt: new Date().toISOString(),
dependencyType: null,
favorite: false,
impressionData: false,
project: 'project',
segments: [],
stale: false,
environments: [
{
name: 'production',
enabled: false,
},
{
name: 'production',
enabled: false,
},
],
})),
[tableState.limit],
);

const isPlaceholder = Boolean(initialLoad || (loading && total));
const bodyLoadingRef = useLoading(isPlaceholder);

const data = useMemo(() => {
if (isPlaceholder) {
return placeholderData;
}
return features;
}, [isPlaceholder, features]);

Choose a reason for hiding this comment

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

❌ New issue: Complex Method
OldProjectFeatureToggles.columns has a cyclomatic complexity of 16, threshold = 10

Why does this problem occur?

This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring. Read more.

To ignore this warning click here.

@@ -28,8 +28,7 @@ const HeaderCell = <T extends object>(header: Header<T, unknown>) => {
onClick={() => column.toggleSorting()}
styles={{
borderRadius: '0px',
paddingTop: 0,
paddingBottom: 0,
padding: 0,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

previously we had 16px padding from left and right that other components had to compensate for

@@ -5,12 +5,12 @@ import StarBorderIcon from '@mui/icons-material/StarBorder';
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';

const StyledCell = styled(Box)(({ theme }) => ({
paddingLeft: theme.spacing(1.25),
paddingRight: theme.spacing(0.5),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

there was too much spacing around the star icon

@@ -59,25 +59,40 @@ const CappedDescription: FC<{ text: string; searchQuery: string }> = ({
placement='bottom-start'
arrow
>
<StyledDescription data-loading>
<StyledDescription>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

loader moved onto the parent so those data-loading attributes had no effect

<Highlighter search={searchQuery}>{text}</Highlighter>
</StyledDescription>
}
/>
);
};

const CappedTag: FC<{ tag: string }> = ({ tag }) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

tags get tooltip when they are long

const { featureTypes } = useFeatureTypes();
const IconComponent = getFeatureTypeIcons(type);
const typeName = featureTypes.find(
(featureType) => featureType.id === type,
)?.name;
const title = `This is a "${typeName || type}" flag`;
const title = `${typeName || type} flag`;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

simplified message

data-loading
/>
</Tooltip>
<HtmlTooltip arrow title={title} describeChild>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is nicely styled with a white background

);

return (
<FeatureNameAndType>
<FeatureNameAndType data-loading>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

loading on the parent

show={
<Box
sx={(theme) => ({ display: 'flex', gap: theme.spacing(1) })}
>
<DependencyBadge
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved dependency onto the first row

@@ -7,24 +7,21 @@ interface IRowSelectCellProps {
onChange: (_?: unknown) => void;
checked: boolean;
title: string;
noPadding?: boolean;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was probably a hack and I'n removing it now because I fixed the underlying issue with extra padding

}

const StyledBoxCell = styled(Box)(({ theme }) => ({
display: 'flex',
justifyContent: 'center',
paddingLeft: theme.spacing(2),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

row selector has predictable with without special case noPadding

@kwasniew kwasniew changed the title Table with feature overview cell feat: Table with feature overview cell Mar 27, 2024
@kwasniew kwasniew requested a review from sjaanus March 27, 2024 10:48
@kwasniew kwasniew merged commit 6a0135a into main Mar 27, 2024
14 of 15 checks passed
@kwasniew kwasniew deleted the table-with-feature-overview-cell branch March 27, 2024 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants