Skip to content

Commit

Permalink
[PC-1545]: Allow configuration hiding specific plugin presets
Browse files Browse the repository at this point in the history
Summary: For a peculiar use case.

Test Plan: Try overriding `hidePresetsForPlugin` in the `data-export` configurable. Whatever logic you put there should be reflected by hiding preset scripts from `/configure-data-export` based on your conditions.

Reviewers: michelle, vihang

Reviewed By: michelle

JIRA Issues: PC-1545

Signed-off-by: Nick Lanam <[email protected]>

Differential Revision: https://phab.corp.pixielabs.ai/D11651

GitOrigin-RevId: 49543c8
  • Loading branch information
NickLanam authored and copybaranaut committed Jun 21, 2022
1 parent 9702951 commit c5f35e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/ui/src/configurables/base/data-export.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import * as React from 'react';
import { Button, Typography } from '@mui/material';
import { Link } from 'react-router-dom';

import { PartialPlugin } from 'app/pages/configure-data-export/data-export-gql';

export const DataExportNoPluginsEnabledSplash = React.memo<{ isEmbedded: boolean }>(({ isEmbedded }) => {
return (
isEmbedded ? (
Expand All @@ -46,3 +48,9 @@ export const DataExportNoPluginsEnabledSplash = React.memo<{ isEmbedded: boolean
);
});
DataExportNoPluginsEnabledSplash.displayName = 'DataExportNoPluginsEnabledSplash';

/** May be useful for custom environments. By default, doesn't do anything. */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function hidePresetsForPlugin(plugin: PartialPlugin): boolean {
return false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import { Link, useRouteMatch } from 'react-router-dom';
import { isPixieEmbedded } from 'app/common/embed-context';
import { Spinner, useSnackbar } from 'app/components';
import { GQLRetentionScript } from 'app/types/schema';
import { hidePresetsForPlugin } from 'configurable/data-export';

import { PluginIcon } from './data-export-common';
import {
Expand Down Expand Up @@ -273,7 +274,9 @@ export const ConfigureDataExportBody = React.memo(() => {
const { loading: loadingScripts, error: scriptsError, scripts } = useRetentionScripts();
const { loading: loadingPlugins, error: pluginsError, plugins } = useRetentionPlugins();

const enabledPlugins = React.useMemo(() => (plugins?.filter(p => p.retentionEnabled) ?? []), [plugins]);
const enabledPlugins = React.useMemo(() => (
plugins?.filter(p => p.retentionEnabled && !hidePresetsForPlugin(p)) ?? []
), [plugins]);

React.useEffect(() => {
const pMsg = pluginsError?.message;
Expand Down

0 comments on commit c5f35e9

Please sign in to comment.