packages/core: update to not use default exports for components

This commit is contained in:
Patrik Oldsberg
2020-06-21 17:51:16 +02:00
parent cddfff19c8
commit 9fc73e9e36
59 changed files with 146 additions and 126 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ import privateExports, {
import { BrowserRouter, MemoryRouter } from 'react-router-dom';
import { ErrorPage } from '../layout/ErrorPage';
import Progress from '../components/Progress';
import { Progress } from '../components/Progress';
import { lightTheme, darkTheme } from '@backstage/theme';
import { AppConfig, JsonObject } from '@backstage/config';
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export * from './AlertDisplay';
export { AlertDisplay } from './AlertDisplay';
@@ -15,7 +15,7 @@
*/
import React from 'react';
import CodeSnippet from './CodeSnippet';
import { CodeSnippet } from './CodeSnippet';
import { InfoCard } from '../../layout/InfoCard';
export default {
@@ -18,7 +18,7 @@ import React from 'react';
import { render } from '@testing-library/react';
import { wrapInTestApp } from '@backstage/test-utils';
import CodeSnippet from './CodeSnippet';
import { CodeSnippet } from './CodeSnippet';
const JAVASCRIPT = `const greeting = "Hello";
const world = "World";
@@ -31,7 +31,7 @@ const defaultProps = {
showLineNumbers: false,
};
const CodeSnippet: FC<Props> = props => {
export const CodeSnippet: FC<Props> = props => {
const { text, language, showLineNumbers } = {
...defaultProps,
...props,
@@ -57,5 +57,3 @@ CodeSnippet.propTypes = {
language: PropTypes.string.isRequired,
showLineNumbers: PropTypes.bool,
};
export default CodeSnippet;
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export { default } from './CodeSnippet';
export { CodeSnippet } from './CodeSnippet';
@@ -15,7 +15,7 @@
*/
import React from 'react';
import CopyTextButton from '.';
import { CopyTextButton } from '.';
export default {
title: 'CopyTextButton',
@@ -17,7 +17,7 @@
import React from 'react';
import { render } from '@testing-library/react';
import { wrapInTestApp } from '@backstage/test-utils';
import CopyTextButton from './CopyTextButton';
import { CopyTextButton } from './CopyTextButton';
import {
ApiRegistry,
errorApiRef,
@@ -56,7 +56,7 @@ const defaultProps = {
tooltipText: 'Text copied to clipboard',
};
const CopyTextButton: FC<Props> = props => {
export const CopyTextButton: FC<Props> = props => {
const { text, tooltipDelay, tooltipText } = {
...defaultProps,
...props,
@@ -110,5 +110,3 @@ CopyTextButton.propTypes = {
tooltipDelay: PropTypes.number,
tooltipText: PropTypes.string,
};
export default CopyTextButton;
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export { default } from './CopyTextButton';
export { CopyTextButton } from './CopyTextButton';
@@ -15,7 +15,7 @@
*/
import React from 'react';
import DismissableBanner from './DismissableBanner';
import { DismissableBanner } from './DismissableBanner';
import { Link, Typography } from '@material-ui/core';
import {
ApiProvider,
@@ -17,7 +17,7 @@
import React from 'react';
import { fireEvent } from '@testing-library/react';
import { renderWithEffects, wrapInTestApp } from '@backstage/test-utils';
import DismissableBanner from './DismissableBanner';
import { DismissableBanner } from './DismissableBanner';
import {
ApiRegistry,
ApiProvider,
@@ -59,7 +59,7 @@ type Props = {
id: string;
};
const DismissableBanner: FC<Props> = ({ variant, message, id }) => {
export const DismissableBanner: FC<Props> = ({ variant, message, id }) => {
const classes = useStyles();
const storageApi = useApi(storageApiRef);
const notificationsStore = storageApi.forBucket('notifications');
@@ -111,5 +111,3 @@ const DismissableBanner: FC<Props> = ({ variant, message, id }) => {
</Snackbar>
);
};
export default DismissableBanner;
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export { default } from './DismissableBanner';
export { DismissableBanner } from './DismissableBanner';
@@ -0,0 +1,17 @@
/*
* Copyright 2020 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { FeatureCalloutCircular } from './FeatureCalloutCircular';
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import React from 'react';
import HorizontalScrollGrid from './HorizontalScrollGrid';
import { HorizontalScrollGrid } from './HorizontalScrollGrid';
const cardContentStyle = { height: 0, padding: 150, margin: 20 };
const containerStyle = { width: 800, height: 400, margin: 20 };
@@ -17,7 +17,7 @@
import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import { renderWithEffects, wrapInTestApp } from '@backstage/test-utils';
import HorizontalScrollGrid from './HorizontalScrollGrid';
import { HorizontalScrollGrid } from './HorizontalScrollGrid';
import { Grid } from '@material-ui/core';
describe('<HorizontalScrollGrid />', () => {
@@ -181,7 +181,7 @@ function useSmoothScroll(
return setScrollTarget;
}
const HorizontalScrollGrid: FC<Props> = props => {
export const HorizontalScrollGrid: FC<Props> = props => {
const {
scrollStep = 100,
scrollSpeed = 50,
@@ -245,5 +245,3 @@ const HorizontalScrollGrid: FC<Props> = props => {
</div>
);
};
export default HorizontalScrollGrid;
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export { default } from './HorizontalScrollGrid';
export { HorizontalScrollGrid } from './HorizontalScrollGrid';
@@ -15,7 +15,7 @@
*/
import React from 'react';
import Progress from '.';
import { Progress } from '.';
export default {
title: 'Progress',
@@ -17,7 +17,7 @@
import React, { FC, useState, useEffect } from 'react';
import { LinearProgress, LinearProgressProps } from '@material-ui/core';
const Progress: FC<LinearProgressProps> = props => {
export const Progress: FC<LinearProgressProps> = props => {
const [isVisible, setIsVisible] = useState(false);
useEffect(() => {
@@ -31,5 +31,3 @@ const Progress: FC<LinearProgressProps> = props => {
<div style={{ display: 'none' }} data-testid="progress" />
);
};
export default Progress;
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export { default } from './Progress';
export { Progress } from './Progress';
@@ -17,7 +17,7 @@
import React from 'react';
import { render } from '@testing-library/react';
import { wrapInTestApp } from '@backstage/test-utils';
import CircleProgress, { getProgressColor } from './CircleProgress';
import { CircleProgress, getProgressColor } from './CircleProgress';
describe('<CircleProgress />', () => {
it('renders without exploding', () => {
@@ -77,7 +77,7 @@ export function getProgressColor(
return palette.status.ok;
}
const CircleProgress: FC<Props> = props => {
export const CircleProgress: FC<Props> = props => {
const classes = useStyles(props);
const theme = useTheme<BackstageTheme>();
const { value, fractional, inverse, unit, max } = {
@@ -104,5 +104,3 @@ const CircleProgress: FC<Props> = props => {
</div>
);
};
export default CircleProgress;
@@ -15,7 +15,7 @@
*/
import React from 'react';
import HorizontalProgress from './HorizontalProgress';
import { HorizontalProgress } from './HorizontalProgress';
const containerStyle = { width: 300 };
@@ -28,7 +28,7 @@ type Props = {
value: number;
};
const HorizontalProgress: FC<Props> = ({ value }) => {
export const HorizontalProgress: FC<Props> = ({ value }) => {
const theme = useTheme<BackstageTheme>();
if (isNaN(value)) {
return null;
@@ -49,5 +49,3 @@ const HorizontalProgress: FC<Props> = ({ value }) => {
</Tooltip>
);
};
export default HorizontalProgress;
@@ -15,7 +15,7 @@
*/
import React from 'react';
import ProgressCard from './ProgressCard';
import { ProgressCard } from './ProgressCard';
import { Grid } from '@material-ui/core';
const linkInfo = { title: 'Go to XYZ Location', link: '#' };
@@ -18,7 +18,7 @@ import React from 'react';
import { render } from '@testing-library/react';
import { wrapInTestApp } from '@backstage/test-utils';
import ProgressCard from './ProgressCard';
import { ProgressCard } from './ProgressCard';
const minProps = { title: 'Tingle upgrade', progress: 0.12 };
@@ -18,7 +18,7 @@ import React, { FC } from 'react';
import { makeStyles } from '@material-ui/core';
import { InfoCard } from '../../layout/InfoCard';
import { BottomLinkProps } from '../../layout/BottomLink';
import CircleProgress from './CircleProgress';
import { CircleProgress } from './CircleProgress';
type Props = {
title: string;
@@ -36,7 +36,7 @@ const useStyles = makeStyles({
},
});
const ProgressCard: FC<Props> = props => {
export const ProgressCard: FC<Props> = props => {
const classes = useStyles(props);
const { title, subheader, progress, deepLink, variant } = props;
@@ -53,5 +53,3 @@ const ProgressCard: FC<Props> = props => {
</div>
);
};
export default ProgressCard;
@@ -0,0 +1,19 @@
/*
* Copyright 2020 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { ProgressCard } from './ProgressCard';
export { CircleProgress } from './CircleProgress';
export { HorizontalProgress } from './HorizontalProgress';
@@ -16,8 +16,8 @@
import React from 'react';
import { render, fireEvent, within } from '@testing-library/react';
import { wrapInTestApp } from '@backstage/test-utils';
import Stepper from './SimpleStepper';
import Step from './SimpleStepperStep';
import { SimpleStepper as Stepper } from './SimpleStepper';
import { SimpleStepperStep as Step } from './SimpleStepperStep';
const getTextInSlide = (rendered: any, index: number) =>
within(rendered.getByTestId(`step${index}`)).getByText;
@@ -40,13 +40,17 @@ export interface StepperProps {
onStepChange?: (prevIndex: number, nextIndex: number) => void;
}
const Stepper: FC<StepperProps> = ({ children, elevated, onStepChange }) => {
export const SimpleStepper: FC<StepperProps> = ({
children,
elevated,
onStepChange,
}) => {
const [stepIndex, setStepIndex] = useState<number>(0);
const [stepHistory, setStepHistory] = useState<number[]>([0]);
const steps: React.ReactNode[] = [];
let endStep;
Children.forEach(children, (child) => {
Children.forEach(children, child => {
if (isValidElement(child)) {
if (child.props.end) {
endStep = child;
@@ -80,5 +84,3 @@ const Stepper: FC<StepperProps> = ({ children, elevated, onStepChange }) => {
</>
);
};
export default Stepper;
@@ -18,7 +18,7 @@ import { Button, makeStyles } from '@material-ui/core';
import { StepActions } from './SimpleStepperStep';
import { VerticalStepperContext } from './SimpleStepper';
const useStyles = makeStyles((theme) => ({
const useStyles = makeStyles(theme => ({
root: {
marginTop: theme.spacing(3),
'& button': {
@@ -71,7 +71,7 @@ export type SimpleStepperFooterProps = {
children?: ReactNode;
};
const SimpleStepperFooter: FC<SimpleStepperFooterProps> = ({
export const SimpleStepperFooter: FC<SimpleStepperFooterProps> = ({
actions = {},
children,
}) => {
@@ -145,5 +145,3 @@ const SimpleStepperFooter: FC<SimpleStepperFooterProps> = ({
</div>
);
};
export default SimpleStepperFooter;
@@ -21,9 +21,9 @@ import {
Typography,
makeStyles,
} from '@material-ui/core';
import SimpleStepperFooter from './SimpleStepperFooter';
import { SimpleStepperFooter } from './SimpleStepperFooter';
const useStyles = makeStyles((theme) => ({
const useStyles = makeStyles(theme => ({
end: {
padding: theme.spacing(3),
},
@@ -53,7 +53,7 @@ export type StepProps = {
actions?: StepActions;
};
const Step: FC<StepProps> = ({
export const SimpleStepperStep: FC<StepProps> = ({
title,
children,
end,
@@ -82,5 +82,3 @@ const Step: FC<StepProps> = ({
</MuiStep>
);
};
export default Step;
@@ -14,7 +14,5 @@
* limitations under the License.
*/
import SimpleStepper from './SimpleStepper';
import SimpleStepperStep from './SimpleStepperStep';
export { SimpleStepper, SimpleStepperStep };
export { SimpleStepper } from './SimpleStepper';
export { SimpleStepperStep } from './SimpleStepperStep';
@@ -23,7 +23,7 @@ import {
StatusRunning,
StatusWarning,
} from './Status';
import Table from '../Table';
import { Table } from '../Table';
import { InfoCard } from '../../layout/InfoCard';
export default {
@@ -16,7 +16,7 @@
import React, { FC } from 'react';
import { InfoCard } from '../../layout/InfoCard';
import { Grid } from '@material-ui/core';
import StructuredMetadataTable from '.';
import { StructuredMetadataTable } from './StructuredMetadataTable';
const cardContentStyle = { heightX: 200, width: 500 };
@@ -17,7 +17,7 @@
import React from 'react';
import { render } from '@testing-library/react';
import StructuredMetadataTable from './StructuredMetadataTable';
import { StructuredMetadataTable } from './StructuredMetadataTable';
import { startCase } from 'lodash';
describe('<StructuredMetadataTable />', () => {
@@ -56,7 +56,7 @@ function renderMap(
nested?: boolean,
options?: any,
) {
const values = Object.keys(map).map((key) => {
const values = Object.keys(map).map(key => {
const value = toValue(map[key], true);
const fmtKey =
options && options.titleFormat
@@ -98,7 +98,7 @@ function toValue(
}
function mapToItems(info: { [key: string]: string }, options: any) {
return Object.keys(info).map((key) => (
return Object.keys(info).map(key => (
<TableItem key={key} title={key} value={info[key]} options={options} />
));
}
@@ -147,7 +147,8 @@ interface ComponentProps {
dense?: boolean;
options?: any;
}
export default class StructuredMetadataTable extends Component<ComponentProps> {
export class StructuredMetadataTable extends Component<ComponentProps> {
render() {
const { metadata, dense, options } = this.props;
const metadataItems = mapToItems(metadata, options || {});
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export { default } from './StructuredMetadataTable';
export { StructuredMetadataTable } from './StructuredMetadataTable';
@@ -49,7 +49,7 @@ const useStyles = makeStyles(theme => ({
},
}));
const SupportButton: FC<Props> = ({
export const SupportButton: FC<Props> = ({
slackChannel = '#backstage',
email = [],
children,
@@ -155,5 +155,3 @@ const SupportButton: FC<Props> = ({
</Fragment>
);
};
export default SupportButton;
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export { default } from './SupportButton';
export { SupportButton } from './SupportButton';
@@ -33,7 +33,7 @@ type SubvalueCellProps = {
subvalue: React.ReactNode;
};
const SubvalueCell: FC<SubvalueCellProps> = ({ value, subvalue }) => {
export const SubvalueCell: FC<SubvalueCellProps> = ({ value, subvalue }) => {
const classes = useSubvalueCellStyles();
return (
@@ -43,5 +43,3 @@ const SubvalueCell: FC<SubvalueCellProps> = ({ value, subvalue }) => {
</>
);
};
export default SubvalueCell;
@@ -15,7 +15,7 @@
*/
import React from 'react';
import Table, { SubvalueCell, TableColumn } from './';
import { Table, SubvalueCell, TableColumn } from './';
export default {
title: 'Table',
@@ -17,7 +17,7 @@
import React from 'react';
import { render } from '@testing-library/react';
import { wrapInTestApp } from '@backstage/test-utils';
import Table from './';
import { Table } from './Table';
const minProps = {
columns: [
+1 -3
View File
@@ -162,7 +162,7 @@ export interface TableProps extends MaterialTableProps<{}> {
subtitle?: string;
}
const Table: FC<TableProps> = ({
export const Table: FC<TableProps> = ({
columns,
options,
title,
@@ -212,5 +212,3 @@ const Table: FC<TableProps> = ({
/>
);
};
export default Table;
+2 -2
View File
@@ -14,6 +14,6 @@
* limitations under the License.
*/
export { default } from './Table';
export { Table } from './Table';
export type { TableColumn } from './Table';
export { default as SubvalueCell } from './SubvalueCell';
export { SubvalueCell } from './SubvalueCell';
+1 -1
View File
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export { Tabs as default } from './Tabs';
export { Tabs } from './Tabs';
@@ -15,8 +15,8 @@
*/
import React from 'react';
import TrendLine from '.';
import Table from '../Table';
import { Table } from '../Table';
import { TrendLine } from './TrendLine';
import { InfoCard } from '../../layout/InfoCard';
export default {
@@ -19,7 +19,7 @@ import React from 'react';
import { render } from '@testing-library/react';
import { wrapInTestApp } from '@backstage/test-utils';
import TrendLine from '.';
import { TrendLine } from './TrendLine';
describe('TrendLine', () => {
describe('when no data is present', () => {
@@ -27,7 +27,7 @@ function color(data: number[], theme: BackstageTheme): string | undefined {
return theme.palette.status.error;
}
const Trendline: FC<SparklinesProps & { title?: string }> = props => {
export const TrendLine: FC<SparklinesProps & { title?: string }> = props => {
const theme = useTheme<BackstageTheme>();
if (!props.data) return null;
@@ -38,5 +38,3 @@ const Trendline: FC<SparklinesProps & { title?: string }> = props => {
</Sparklines>
);
};
export default Trendline;
@@ -14,4 +14,4 @@
* limitations under the License.
*/
export { default } from './TrendLine';
export { TrendLine } from './TrendLine';
@@ -15,7 +15,7 @@
*/
import React from 'react';
import WarningPanel from '.';
import { WarningPanel } from './WarningPanel';
import { Link, Button } from '@material-ui/core';
export default {
@@ -18,7 +18,7 @@ import React from 'react';
import { render } from '@testing-library/react';
import { wrapInTestApp } from '@backstage/test-utils';
import WarningPanel from './WarningPanel';
import { WarningPanel } from './WarningPanel';
const minProps = { title: 'Mock title', message: 'Some more info' };
@@ -19,7 +19,7 @@ import { Typography, makeStyles } from '@material-ui/core';
import { BackstageTheme } from '@backstage/theme';
import ErrorOutline from '@material-ui/icons/ErrorOutline';
const useErrorOutlineStyles = makeStyles<BackstageTheme>((theme) => ({
const useErrorOutlineStyles = makeStyles<BackstageTheme>(theme => ({
root: {
marginRight: theme.spacing(1),
fill: theme.palette.warningText,
@@ -30,7 +30,7 @@ const ErrorOutlineStyled = () => {
return <ErrorOutline classes={classes} />;
};
const useStyles = makeStyles<BackstageTheme>((theme) => ({
const useStyles = makeStyles<BackstageTheme>(theme => ({
message: {
display: 'flex',
flexDirection: 'column',
@@ -62,7 +62,7 @@ type Props = {
title?: string;
};
const WarningPanel: FC<Props> = (props) => {
export const WarningPanel: FC<Props> = props => {
const classes = useStyles(props);
const { title, message, children } = props;
return (
@@ -82,5 +82,3 @@ const WarningPanel: FC<Props> = (props) => {
</div>
);
};
export default WarningPanel;
@@ -13,4 +13,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { default } from './WarningPanel';
export { WarningPanel } from './WarningPanel';
+36
View File
@@ -0,0 +1,36 @@
/*
* Copyright 2020 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './AlertDisplay';
export * from './Button';
export * from './CodeSnippet';
export * from './CopyTextButton';
export * from './DismissableBanner';
export * from './FeatureDiscovery';
export * from './HorizontalScrollGrid';
export * from './Lifecycle';
export * from './Link';
export * from './OAuthRequestDialog';
export * from './Progress';
export * from './ProgressBars';
export * from './SimpleStepper';
export * from './Status';
export * from './StructuredMetadataTable';
export * from './SupportButton';
export * from './Table';
export * from './Tabs';
export * from './TrendLine';
export * from './WarningPanel';
+1 -24
View File
@@ -17,28 +17,5 @@
export * from '@backstage/core-api';
export * from './api-wrappers';
export * from './components';
export * from './layout';
export { default as CodeSnippet } from './components/CodeSnippet';
export { default as DismissableBanner } from './components/DismissableBanner';
export { AlertDisplay } from './components/AlertDisplay';
export { default as HorizontalScrollGrid } from './components/HorizontalScrollGrid';
export { default as ProgressCard } from './components/ProgressBars/ProgressCard';
export { default as CircleProgress } from './components/ProgressBars/CircleProgress';
export { default as HorizontalProgress } from './components/ProgressBars/HorizontalProgress';
export { default as CopyTextButton } from './components/CopyTextButton';
export { default as Progress } from './components/Progress';
export * from './components/SimpleStepper';
export { OAuthRequestDialog } from './components/OAuthRequestDialog';
export { Lifecycle } from './components/Lifecycle';
export { default as SupportButton } from './components/SupportButton';
export { default as Table, SubvalueCell } from './components/Table';
export type { TableColumn } from './components/Table/Table';
export { default as StructuredMetadataTable } from './components/StructuredMetadataTable';
export { default as TrendLine } from './components/TrendLine';
export { FeatureCalloutCircular } from './components/FeatureDiscovery/FeatureCalloutCircular';
export * from './components/Status';
export * from './components/Button';
export * from './components/Link';
export { default as WarningPanel } from './components/WarningPanel';
export { default as Tabs } from './components/Tabs';
@@ -22,7 +22,7 @@ import { ContentHeader } from '../ContentHeader/ContentHeader';
import { Grid } from '@material-ui/core';
import { SignInPageProps, useApi, configApiRef } from '@backstage/core-api';
import { useSignInProviders, SignInProviderId } from './providers';
import Progress from '../../components/Progress';
import { Progress } from '../../components/Progress';
export type Props = SignInPageProps & {
providers: SignInProviderId[];