refactor(playlists): address review comments

Signed-off-by: Phil Kuang <pkuang@factset.com>
This commit is contained in:
Phil Kuang
2022-09-06 17:36:17 -04:00
parent d3737da337
commit 2028a73c96
27 changed files with 330 additions and 201 deletions
+8 -14
View File
@@ -14,24 +14,18 @@
* limitations under the License.
*/
import { IdentityClient } from '@backstage/plugin-auth-node';
import { createRouter } from '@backstage/plugin-playlist-backend';
import { Router } from 'express';
import { PluginEnvironment } from '../types';
export default async function createPlugin({
database,
discovery,
logger,
permissions,
}: PluginEnvironment): Promise<Router> {
export default async function createPlugin(
env: PluginEnvironment,
): Promise<Router> {
return await createRouter({
database,
identity: IdentityClient.create({
discovery,
issuer: await discovery.getExternalBaseUrl('auth'),
}),
logger,
permissions,
database: env.database,
discovery: env.discovery,
identity: env.identity,
logger: env.logger,
permissions: env.permissions,
});
}
+11 -13
View File
@@ -16,7 +16,6 @@ import { CardHeaderProps } from '@material-ui/core/CardHeader';
import { Column } from '@material-table/core';
import { ComponentClass } from 'react';
import { ComponentProps } from 'react';
import { ComponentType } from 'react';
import { default as CSS_2 } from 'csstype';
import { CSSProperties } from 'react';
import { ElementType } from 'react';
@@ -53,16 +52,6 @@ import { Theme } from '@material-ui/core/styles';
import { TooltipProps } from '@material-ui/core/Tooltip';
import { WithStyles } from '@material-ui/core/styles';
// @public (undocumented)
export type ActionItemProps = {
label?: ListItemTextProps['primary'];
secondaryLabel?: ListItemTextProps['secondary'];
icon?: ReactElement;
disabled?: boolean;
onClick?: (event: React_2.MouseEvent<HTMLDivElement>) => void;
WrapperComponent?: ComponentType;
};
// @public (undocumented)
export function AlertDisplay(props: AlertDisplayProps): JSX.Element | null;
@@ -448,9 +437,18 @@ export function Header(props: PropsWithChildren<Props_14>): JSX.Element;
// @public (undocumented)
export function HeaderActionMenu(props: HeaderActionMenuProps): JSX.Element;
// @public (undocumented)
export type HeaderActionMenuItem = {
label?: ListItemTextProps['primary'];
secondaryLabel?: ListItemTextProps['secondary'];
icon?: ReactElement;
disabled?: boolean;
onClick?: (event: React_2.MouseEvent<HTMLElement>) => void;
};
// @public (undocumented)
export type HeaderActionMenuProps = {
actionItems: ActionItemProps[];
actionItems: HeaderActionMenuItem[];
};
// @public (undocumented)
@@ -1357,7 +1355,7 @@ export function Table<T extends object = {}>(props: TableProps<T>): JSX.Element;
// @public (undocumented)
export namespace Table {
var // (undocumented)
tableIcons: Readonly<Icons>;
icons: Readonly<Icons>;
}
// Warning: (ae-missing-release-tag) "TableClassKey" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
@@ -523,4 +523,4 @@ export function Table<T extends object = {}>(props: TableProps<T>) {
);
}
Table.tableIcons = Object.freeze(tableIcons);
Table.icons = Object.freeze(tableIcons);
@@ -60,7 +60,7 @@ describe('<ComponentContextMenu />', () => {
);
});
it('Test wrapper, and secondary label', async () => {
it('Secondary label', async () => {
const onClickFunction = jest.fn();
const rendered = await renderInTestApp(
<HeaderActionMenu
@@ -68,9 +68,7 @@ describe('<ComponentContextMenu />', () => {
{
label: 'Some label',
secondaryLabel: 'Secondary label',
WrapperComponent: ({ children }) => (
<button onClick={onClickFunction}>{children}</button>
),
onClick: onClickFunction,
},
]}
/>,
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import React, { Fragment, ReactElement, ComponentType } from 'react';
import React, { Fragment, ReactElement } from 'react';
import IconButton from '@material-ui/core/IconButton';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
@@ -28,13 +28,12 @@ import MoreVert from '@material-ui/icons/MoreVert';
/**
* @public
*/
export type ActionItemProps = {
export type HeaderActionMenuItem = {
label?: ListItemTextProps['primary'];
secondaryLabel?: ListItemTextProps['secondary'];
icon?: ReactElement;
disabled?: boolean;
onClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
WrapperComponent?: ComponentType;
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
};
const ActionItem = ({
@@ -43,10 +42,9 @@ const ActionItem = ({
icon,
disabled = false,
onClick,
WrapperComponent = React.Fragment,
}: ActionItemProps) => {
}: HeaderActionMenuItem) => {
return (
<WrapperComponent>
<React.Fragment>
<ListItem
data-testid="header-action-item"
disabled={disabled}
@@ -60,7 +58,7 @@ const ActionItem = ({
{icon && <ListItemIcon>{icon}</ListItemIcon>}
<ListItemText primary={label} secondary={secondaryLabel} />
</ListItem>
</WrapperComponent>
</React.Fragment>
);
};
@@ -68,7 +66,7 @@ const ActionItem = ({
* @public
*/
export type HeaderActionMenuProps = {
actionItems: ActionItemProps[];
actionItems: HeaderActionMenuItem[];
};
/**
@@ -16,6 +16,6 @@
export { HeaderActionMenu } from './HeaderActionMenu';
export type {
ActionItemProps,
HeaderActionMenuItem,
HeaderActionMenuProps,
} from './HeaderActionMenu';