Skip to content

Commit

Permalink
Merge pull request #5109 from voxel51/improv/plugin-config
Browse files Browse the repository at this point in the history
mark newly added plugin config options as optional
  • Loading branch information
sashankaryal authored Nov 14, 2024
2 parents 65bf645 + cea0c84 commit 2d3660f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
33 changes: 19 additions & 14 deletions app/packages/plugins/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ export function getCategoryLabel(category: CategoryID): string {
return "Curate";
case "analyze":
return "Analyze";
case "custom":
default:
return "Custom";
}
}
Expand All @@ -332,16 +332,13 @@ export function getCategoryForPanel(panel: PluginComponentRegistration) {
return panel.panelOptions?.category || "custom";
}

type Category = {
id: CategoryID;
label: string;
};

type PluginActivator = (props: any) => boolean;

type PanelOptions = {
/**
* Whether to allow multiple instances of the plugin
* Whether to allow multiple instances of the plugin.
*
* Defaults to `false`.
*/
allowDuplicates?: boolean;

Expand All @@ -352,7 +349,7 @@ type PanelOptions = {
priority?: number;

/**
* Markdown help text for the plugin
* Markdown help text for the plugin.
*/
helpMarkdown?: string;

Expand All @@ -367,19 +364,27 @@ type PanelOptions = {
TabIndicator?: React.ComponentType;

/**
* The category of the plugin
* The category of the plugin.
*
* Defaults to `custom`.
*/
category: CategoryID;
category?: CategoryID;

/**
* Whether the plugin is in beta
* Whether the plugin is in beta.
* This is used to highlight beta plugins.
*
* Defaults to `false`.
*/
beta: boolean;
beta?: boolean;

/**
* Whether the plugin is new
* Whether the plugin is new.
* This is used to highlight new plugins.
*
* Defaults to `false`.
*/
isNew: boolean;
isNew?: boolean;
};

type PluginComponentProps<T> = T & {
Expand Down
6 changes: 3 additions & 3 deletions app/packages/spaces/src/components/AddPanelButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ export default function AddPanelButton({ node, spaceId }: AddPanelButtonProps) {
<PanelCategories>
{sortedCategories.map(({ label, panels }) => (
<PanelCategory key={label} label={label}>
{panels.map((panel) => (
{panels.map((panel: PluginComponentRegistration) => (
<AddPanelItem
key={panel.name}
node={node}
name={panel.name}
label={panel.label}
spaceId={spaceId}
showBeta={panel.panelOptions?.beta}
showNew={panel.panelOptions?.isNew}
showBeta={panel.panelOptions?.beta ?? false}
showNew={panel.panelOptions?.isNew ?? false}
onClick={() => setOpen(false)}
/>
))}
Expand Down
12 changes: 9 additions & 3 deletions app/packages/spaces/src/components/PanelTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export default function PanelTab({ node, active, spaceId }: PanelTabProps) {
{panel && !loading && <PanelIcon name={panelName as string} />}
{panel && <Typography>{title || panel.label || panel.name}</Typography>}
<PanelTabMeta
showBeta={panel?.panelOptions?.beta}
showNew={panel?.panelOptions?.isNew}
showBeta={panel?.panelOptions?.beta ?? false}
showNew={panel?.panelOptions?.isNew ?? false}
/>
{panel && TabIndicator && (
<TabIndicatorContainer>
Expand Down Expand Up @@ -90,7 +90,13 @@ export default function PanelTab({ node, active, spaceId }: PanelTabProps) {
);
}

function PanelTabMeta({ showBeta, showNew }) {
function PanelTabMeta({
showBeta,
showNew,
}: {
showBeta: boolean;
showNew: boolean;
}) {
return (
<Grid container gap={1} sx={{ width: "auto", ml: "6px" }}>
{showNew && (
Expand Down

0 comments on commit 2d3660f

Please sign in to comment.