Skip to content

Commit

Permalink
clean feature flags (#1242)
Browse files Browse the repository at this point in the history
* Cleanup homePageRedesign

* cleanup activityDashboardMaintenance

* cleanup activityDashboard

* cleanup s3ToDynamoMigration

* cleanup categoryFilters

* cleanup npe2
  • Loading branch information
codemonkey800 committed Sep 5, 2023
1 parent 8871ad2 commit efaf71a
Show file tree
Hide file tree
Showing 30 changed files with 126 additions and 499 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Text } from '@/components/Text';
import { PREVIEW } from '@/constants/env';
import { usePluginState } from '@/context/plugin';
import { usePluginMetrics } from '@/hooks';
import { useIsFeatureFlagEnabled } from '@/store/featureFlags';

import { ActivityMaintenanceSection } from './ActivityMaintenanceSection';
import { ActivityUsageSection } from './ActivityUsageSection';
Expand All @@ -16,9 +15,6 @@ export function ActivityDashboard() {
const { data: metrics, isLoading } = usePluginMetrics(
PREVIEW ? undefined : plugin?.name,
);
const isMaintenanceVisible = useIsFeatureFlagEnabled(
'activityDashboardMaintenance',
);

const isEmpty = useMemo(() => {
if (isLoading) {
Expand Down Expand Up @@ -50,7 +46,7 @@ export function ActivityDashboard() {
) : (
<>
<ActivityUsageSection />
{isMaintenanceVisible && <ActivityMaintenanceSection />}
<ActivityMaintenanceSection />

<Text variant="bodyS">
<I18n i18nKey="activity:learnMore" />
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/components/AppBar/AppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { useSnapshot } from 'valtio';

import { Menu } from '@/components/icons';
import { MenuPopover } from '@/components/MenuPopover';
import { useIsFeatureFlagEnabled } from '@/store/featureFlags';
import { pageTransitionsStore } from '@/store/pageTransitions';
import { createUrl } from '@/utils';

Expand All @@ -24,7 +23,6 @@ export function AppBar() {
const links = useAppBarLinks();
const [t] = useTranslation(['common']);

const isHomePageRedesign = useIsFeatureFlagEnabled('homePageRedesign');
const router = useRouter();
const { nextUrl } = useSnapshot(pageTransitionsStore);

Expand Down Expand Up @@ -84,7 +82,7 @@ export function AppBar() {
'screen-875:col-span-2 screen-1150:col-span-3',
)}
>
{isHomePageRedesign && !isPluginsPage && <PluginSearchBar />}
{!isPluginsPage && <PluginSearchBar />}

{/* Menu button */}
<div
Expand Down
9 changes: 1 addition & 8 deletions frontend/src/components/AppBar/useMetadataSections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { isArray, isEmpty, isString } from 'lodash';
import { useTranslation } from 'next-i18next';

import { MetadataId, MetadataKeys, usePluginMetadata } from '@/context/plugin';
import { useIsFeatureFlagEnabled } from '@/store/featureFlags';
import { I18nPreviewSection } from '@/types/i18n';

export interface MetadataSectionField {
Expand All @@ -20,7 +19,6 @@ export interface MetadataSection {
export function useMetadataSections(): MetadataSection[] {
const metadata = usePluginMetadata();
const [t] = useTranslation(['preview']);
const isNpe2Enabled = useIsFeatureFlagEnabled('npe2');

function getFields(...keys: MetadataKeys[]) {
return keys.map((key) => {
Expand Down Expand Up @@ -75,12 +73,7 @@ export function useMetadataSections(): MetadataSection[] {
return getSections(
{
section: t('preview:sections.describeWhat'),
fields: [
isNpe2Enabled ? 'displayName' : 'name',
'summary',
'description',
'authors',
],
fields: ['displayName', 'summary', 'description', 'authors'],
},

{
Expand Down
17 changes: 5 additions & 12 deletions frontend/src/components/AppLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import { SitemapPage } from '@/components/SitemapPage';
import { DEFAULT_PLUGIN_DATA, DEFAULT_REPO_DATA } from '@/constants/plugin';
import { LoadingStateProvider } from '@/context/loading';
import { usePageUtils } from '@/hooks/usePageUtils';
import SearchPageV1 from '@/pages/index';
import SearchPageV2 from '@/pages/plugins';
import SearchPage from '@/pages/plugins';
import PluginPage from '@/pages/plugins/[name]';
import { useIsFeatureFlagEnabled } from '@/store/featureFlags';
import { PluginHomePageData, PluginType } from '@/types';

import { HomePage, HomePageProvider } from './HomePage';
Expand All @@ -21,11 +19,10 @@ interface Props {
* Renders the appropriate loader component for a specific page.
*/
export function AppLoader({ nextUrl }: Props) {
const isHomePageRedesign = useIsFeatureFlagEnabled('homePageRedesign');
const pageUtils = usePageUtils();

let homePageLoader: ReactNode;
if (isHomePageRedesign && pageUtils.isHomePage(nextUrl)) {
if (pageUtils.isHomePage(nextUrl)) {
const plugins = Array(3)
.fill(null)
.map(() => DEFAULT_PLUGIN_DATA as unknown as PluginHomePageData);
Expand All @@ -51,13 +48,9 @@ export function AppLoader({ nextUrl }: Props) {

const searchPageLoader = pageUtils.isSearchPage(nextUrl) && (
<LoadingStateProvider loading key="/">
{isHomePageRedesign ? (
<Layout key="/plugins">
<SearchPageV2 />
</Layout>
) : (
<SearchPageV1 index={[]} licenses={[]} />
)}
<Layout key="/plugins">
<SearchPage />
</Layout>
</LoadingStateProvider>
);

Expand Down
4 changes: 1 addition & 3 deletions frontend/src/components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ import { AppBar } from '@/components/AppBar';
import { Banner } from '@/components/Banner';
import { Footer } from '@/components/Footer';
import { SignupForm } from '@/components/SignupForm';
import { useIsFeatureFlagEnabled } from '@/store/featureFlags';

interface Props {
children: ReactNode;
}

export function Layout({ children }: Props) {
const router = useRouter();
const isHomePageRedesign = useIsFeatureFlagEnabled('homePageRedesign');
const isSearchPage = isHomePageRedesign && router.pathname === '/plugins';
const isSearchPage = router.pathname === '/plugins';

return (
<div className="flex flex-col min-h-screen">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { useQuery } from 'react-query';

import { Link } from '@/components/Link';
import { MetadataKeys } from '@/context/plugin';
import { useIsFeatureFlagEnabled } from '@/store/featureFlags';
import { SUPPORTED_PYTHON_VERSIONS } from '@/store/search/filter.store';
import { PARAM_KEY_MAP, PARAM_VALUE_MAP } from '@/store/search/queryParameters';
import { SpdxLicenseResponse } from '@/store/search/types';
Expand Down Expand Up @@ -154,16 +153,12 @@ export function MetadataListMetadataItem({
return result;
}, [isOsiApproved, metadataKey, value]);

const isHomePageRedesign = useIsFeatureFlagEnabled('homePageRedesign');
const url = useMemo(() => {
const paramKey = PARAM_KEY_MAP[metadataKey] ?? metadataKey;
return (
filterValue &&
`${
isHomePageRedesign ? '/plugins' : '/'
}?${paramKey}=${encodeURIComponent(filterValue)}`
filterValue && `/plugins?${paramKey}=${encodeURIComponent(filterValue)}`
);
}, [filterValue, isHomePageRedesign, metadataKey]);
}, [filterValue, metadataKey]);

return (
<MetadataListTextItem>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { Link } from '@/components/Link';
import { SkeletonLoader } from '@/components/SkeletonLoader';
import { usePluginMetadata } from '@/context/plugin';
import { useIsFeatureFlagEnabled } from '@/store/featureFlags';

import styles from './PluginAuthors.module.scss';

export function PluginAuthors() {
const metadata = usePluginMetadata();
const isHomePageRedesign = useIsFeatureFlagEnabled('homePageRedesign');

return (
<SkeletonLoader
Expand All @@ -18,9 +16,7 @@ export function PluginAuthors() {
<li className="inline" key={author}>
<Link
className="underline text-[11px] screen-495:text-[14px] font-semibold"
href={`${
isHomePageRedesign ? '/plugins' : '/'
}?authors=${author.replaceAll(' ', '+')}`}
href={`$plugins?authors=${author.replaceAll(' ', '+')}`}
>
{author}
</Link>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import clsx from 'clsx';
import { useRef } from 'react';

import { PluginPageContent } from '@/components/PluginPage/PluginPageContent';
import { PluginTabs } from '@/components/PluginPage/PluginTabs';
import { usePreviewClickAway } from '@/hooks/usePreviewClickAway';
import { useIsFeatureFlagEnabled } from '@/store/featureFlags';

import { PluginActions } from './PluginActions';
import { PluginAuthors } from './PluginAuthors';
Expand All @@ -15,11 +13,8 @@ import { PluginViewProjectDataLink } from './PluginViewProjectDataLink';

export function PluginCenterColumn() {
const containerRef = useRef<HTMLElement>(null);
const isNpe2Enabled = useIsFeatureFlagEnabled('npe2');
const isActivityDashboardEnabled =
useIsFeatureFlagEnabled('activityDashboard');

usePreviewClickAway(isNpe2Enabled ? 'metadata-displayName' : 'metadata-name');
usePreviewClickAway('metadata-displayName');
usePreviewClickAway('metadata-summary');
usePreviewClickAway('metadata-description');

Expand All @@ -40,11 +35,7 @@ export function PluginCenterColumn() {
<PluginActions />
<PluginViewProjectDataLink />

{isActivityDashboardEnabled ? (
<PluginTabs containerRef={containerRef} />
) : (
<PluginPageContent />
)}
<PluginTabs containerRef={containerRef} />
</article>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import { Tooltip } from 'src/components/Tooltip';
import { Link } from '@/components/Link';
import { SkeletonLoader } from '@/components/SkeletonLoader';
import { usePluginState } from '@/context/plugin';
import { useIsFeatureFlagEnabled } from '@/store/featureFlags';

export function PluginPyPiLink() {
const [t] = useTranslation(['pluginPage']);
const { plugin } = usePluginState();
const isNpe2Enabled = useIsFeatureFlagEnabled('npe2');

if (!isNpe2Enabled || !plugin?.name) {
if (!plugin?.name) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,23 @@ import { MetadataHighlighter } from '@/components/MetadataHighlighter';
import { EmptyMetadataTooltip } from '@/components/MetadataHighlighter/EmptyMetadataTooltip';
import { SkeletonLoader } from '@/components/SkeletonLoader';
import { usePluginState } from '@/context/plugin';
import { useIsFeatureFlagEnabled } from '@/store/featureFlags';

export function PluginTitle() {
const [t] = useTranslation(['pluginData']);
const { plugin } = usePluginState();
const isNpe2Enabled = useIsFeatureFlagEnabled('npe2');

return (
<SkeletonLoader
className="h-12"
render={() => (
<MetadataHighlighter
metadataId={isNpe2Enabled ? 'metadata-displayName' : 'metadata-name'}
metadataId="metadata-displayName"
className="flex justify-between"
highlight={isNpe2Enabled ? !plugin?.display_name : !plugin?.name}
highlight={!plugin?.display_name}
tooltip={
<EmptyMetadataTooltip
className="self-end"
metadataId={
isNpe2Enabled ? 'metadata-displayName' : 'metadata-name'
}
metadataId="metadata-displayName"
/>
}
>
Expand All @@ -35,7 +31,7 @@ export function PluginTitle() {
!plugin?.name && 'text-hub-gray-500',
)}
>
{(isNpe2Enabled ? plugin?.display_name : undefined) ||
{plugin?.display_name ||
plugin?.name ||
t('pluginData:labels.pluginName.label')}
</h1>
Expand Down
34 changes: 14 additions & 20 deletions frontend/src/components/PluginPage/PluginMetadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
usePluginMetadata,
usePluginState,
} from '@/context/plugin';
import { useIsFeatureFlagEnabled } from '@/store/featureFlags';
import { PluginType } from '@/types';

import { MetadataListMetadataItem } from '../MetadataList/MetadataListMetadataItem';
Expand Down Expand Up @@ -132,7 +131,6 @@ export function PluginMetadata({
enableScrollID,
}: PluginMetadataProps) {
const metadata = usePluginMetadata();
const isNpe2Enabled = useIsFeatureFlagEnabled('npe2');

function renderItemList(
key: PickMetadataKeys<string | string[]>,
Expand Down Expand Up @@ -216,25 +214,21 @@ export function PluginMetadata({
<>
{renderItemList('supportedData', { highlight: false })}

{isNpe2Enabled && (
{renderItemList('pluginType', { highlight: false })}

{metadata.pluginType.value.includes(PluginType.Reader) &&
renderItemList('readerFileExtensions', {
highlight: false,
inlineList: true,
})}

{metadata.pluginType.value.includes(PluginType.Writer) && (
<>
{renderItemList('pluginType', { highlight: false })}

{metadata.pluginType.value.includes(PluginType.Reader) &&
renderItemList('readerFileExtensions', {
highlight: false,
inlineList: true,
})}

{metadata.pluginType.value.includes(PluginType.Writer) && (
<>
{renderItemList('writerFileExtensions', {
highlight: false,
inlineList: true,
})}
{renderItemList('writerSaveLayers', { highlight: false })}
</>
)}
{renderItemList('writerFileExtensions', {
highlight: false,
inlineList: true,
})}
{renderItemList('writerSaveLayers', { highlight: false })}
</>
)}
</>
Expand Down
50 changes: 0 additions & 50 deletions frontend/src/components/PluginPage/PluginPageContent.tsx

This file was deleted.

Loading

0 comments on commit efaf71a

Please sign in to comment.