Skip to content

Commit

Permalink
feat(toolbar): Iterate on feature-flags panel styles (#74910)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan953 committed Jul 24, 2024
1 parent 6be923a commit 0c81115
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import {useRef, useState} from 'react';

import useEnabledFeatureFlags from 'sentry/components/devtoolbar/components/featureFlags/useEnabledFeatureFlags';
import {
infiniteListScrollableWindowCss,
panelScrollableCss,
} from 'sentry/components/devtoolbar/styles/infiniteList';
import {inlineLinkCss} from 'sentry/components/devtoolbar/styles/link';
import EmptyStateWarning from 'sentry/components/emptyStateWarning';
import Input from 'sentry/components/input';
import ExternalLink from 'sentry/components/links/externalLink';
import {PanelTable} from 'sentry/components/panels/panelTable';
import {Cell} from 'sentry/components/replays/virtualizedGrid/bodyCell';

import useConfiguration from '../../hooks/useConfiguration';
import {panelInsetContentCss, panelSectionCss} from '../../styles/panel';
import {resetFlexColumnCss} from '../../styles/reset';
import {smallCss} from '../../styles/typography';
import PanelLayout from '../panelLayout';

Expand All @@ -22,30 +19,45 @@ export default function FeatureFlagsPanel() {
const [searchTerm, setSearchTerm] = useState('');
const searchInput = useRef<HTMLInputElement>(null);

const filteredItems = featureFlags
?.filter(s => s.toLowerCase().includes(searchTerm))
.sort();

return (
<PanelLayout title="Feature Flags">
<div css={[smallCss, panelSectionCss, panelInsetContentCss]}>
<Input
ref={searchInput}
size="sm"
placeholder="Search flags"
onChange={e => setSearchTerm(e.target.value.toLowerCase())}
/>
<span>Flags enabled for {organizationSlug}</span>
</div>

<PanelTable
headers={[<span key="Flags">Flags enabled for {organizationSlug}</span>]}
css={[resetFlexColumnCss, infiniteListScrollableWindowCss, panelScrollableCss]}
headers={[
<div key="column">
<Input
ref={searchInput}
size="sm"
placeholder="Search flags"
onChange={e => setSearchTerm(e.target.value.toLowerCase())}
/>
</div>,
]}
stickyHeaders
css={[
{
border: 'none',
padding: 0,
'&>:first-child': {
minHeight: 'unset',
padding: 'var(--space50) var(--space150)',
},
},
]}
>
{featureFlags
?.filter(s => s.toLowerCase().includes(searchTerm))
.sort()
.map(flag => {
{filteredItems?.length ? (
filteredItems.map(flag => {
return (
<Cell key={flag} style={{alignItems: 'flex-start'}}>
<Cell key={flag} css={[panelInsetContentCss, {alignItems: 'flex-start'}]}>
{featureFlagTemplateUrl?.(flag) ? (
<ExternalLink
style={{textDecoration: 'inherit', color: 'inherit'}}
css={[smallCss, inlineLinkCss]}
href={featureFlagTemplateUrl(flag)}
onClick={() => {
trackAnalytics?.({
Expand All @@ -61,7 +73,10 @@ export default function FeatureFlagsPanel() {
)}
</Cell>
);
})}
})
) : (
<EmptyStateWarning small>No items to show</EmptyStateWarning>
)}
</PanelTable>
</PanelLayout>
);
Expand Down
2 changes: 1 addition & 1 deletion static/app/components/devtoolbar/styles/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ export const panelSectionCss = css`
`;

export const panelInsetContentCss = css`
padding-inline: var(--space100);
padding-inline: var(--space150);
`;

0 comments on commit 0c81115

Please sign in to comment.