Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tech Stories
---

MUI v5 - `Components > Snackbar` ([#9359](https://github.com/linode/manager/pull/9359))
2 changes: 0 additions & 2 deletions packages/manager/src/components/SnackBar/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { SnackbarProvider, SnackbarProviderProps } from 'notistack';
import * as React from 'react';
import { makeStyles } from '@mui/styles';
import { makeStyles } from 'tss-react/mui';
import { Theme } from '@mui/material/styles';
import CloseSnackbar from './CloseSnackbar';

const useStyles = makeStyles((theme: Theme) => ({
const useStyles = makeStyles()((theme: Theme) => ({
root: {
'& div': {
backgroundColor: `${theme.bg.white} !important`,
Expand All @@ -29,7 +29,7 @@ const useStyles = makeStyles((theme: Theme) => ({
borderLeft: `6px solid ${theme.palette.primary.main}`,
},
success: {
borderLeft: `6px solid ${theme.palette.primary.main}`,
borderLeft: `6px solid ${theme.color.green}`,
Comment thread
jaalah-akamai marked this conversation as resolved.
},
error: {
borderLeft: `6px solid ${theme.palette.error.dark}`,
Expand All @@ -39,10 +39,8 @@ const useStyles = makeStyles((theme: Theme) => ({
},
}));

type CombinedProps = SnackbarProviderProps;

const SnackBar: React.FC<CombinedProps> = (props) => {
const classes = useStyles();
export const Snackbar = (props: SnackbarProviderProps) => {
const { classes } = useStyles();
/**
* This pattern is taken from the Notistack docs:
* https://iamhosseindhv.com/notistack/demos#action-for-all-snackbars
Expand Down Expand Up @@ -78,5 +76,3 @@ const SnackBar: React.FC<CombinedProps> = (props) => {
</SnackbarProvider>
);
};

export default SnackBar;
9 changes: 5 additions & 4 deletions packages/manager/src/features/Events/EventsLanding.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Event, getEvents } from '@linode/api-v4/lib/account';
import { ResourcePage } from '@linode/api-v4/lib/types';
import { withSnackbar, WithSnackbarProps } from 'notistack';
import { useSnackbar } from 'notistack';
import { compose as rCompose, concat, uniq } from 'ramda';
import * as React from 'react';
import { connect } from 'react-redux';
Expand Down Expand Up @@ -61,7 +61,7 @@ interface Props {
emptyMessage?: string; // Custom message for the empty state (i.e. no events).
}

type CombinedProps = Props & StateProps & WithSnackbarProps;
type CombinedProps = Props & StateProps;

const appendToEvents = (oldEvents: Event[], newEvents: Event[]) =>
rCompose<Event[], Event[], Event[], Event[]>(
Expand Down Expand Up @@ -173,6 +173,7 @@ export const reducer: EventsReducer = (state, action) => {

export const EventsLanding: React.FC<CombinedProps> = (props) => {
const classes = useStyles();
const { enqueueSnackbar } = useSnackbar();

const [loading, setLoading] = React.useState<boolean>(false);
const [loadMoreEvents, setLoadMoreEvents] = React.useState<boolean>(false);
Expand All @@ -199,7 +200,7 @@ export const EventsLanding: React.FC<CombinedProps> = (props) => {
getEventsRequest({ page: currentPage })
.then(handleEventsRequestSuccess)
.catch(() => {
props.enqueueSnackbar('There was an error loading more events', {
enqueueSnackbar('There was an error loading more events', {
variant: 'error',
});
setLoading(false);
Expand Down Expand Up @@ -403,6 +404,6 @@ const mapStateToProps = (state: ApplicationState) => ({

const connected = connect(mapStateToProps);

const enhanced = compose<CombinedProps, Props>(connected, withSnackbar);
const enhanced = compose<CombinedProps, Props>(connected);

export default enhanced(EventsLanding);
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getKubeConfig } from '@linode/api-v4/lib/kubernetes';
import { withSnackbar, WithSnackbarProps } from 'notistack';
import { useSnackbar } from 'notistack';
import * as React from 'react';
import { RouteComponentProps, withRouter } from 'react-router-dom';
import { compose } from 'recompose';
Expand All @@ -19,15 +19,16 @@ interface Props {
openDialog: () => void;
}

type CombinedProps = Props & RouteComponentProps<{}> & WithSnackbarProps;
type CombinedProps = Props & RouteComponentProps<{}>;
Comment thread
jaalah-akamai marked this conversation as resolved.
Outdated

export const ClusterActionMenu: React.FunctionComponent<CombinedProps> = (
props
) => {
const theme = useTheme<Theme>();
const { enqueueSnackbar } = useSnackbar();
const matchesSmDown = useMediaQuery(theme.breakpoints.down('md'));

const { clusterId, clusterLabel, enqueueSnackbar, openDialog } = props;
const { clusterId, clusterLabel, openDialog } = props;

const actions: Action[] = [
{
Expand Down Expand Up @@ -92,6 +93,6 @@ export const ClusterActionMenu: React.FunctionComponent<CombinedProps> = (
);
};

const enhanced = compose<CombinedProps, Props>(withSnackbar, withRouter);
const enhanced = compose<CombinedProps, Props>(withRouter);
Comment thread
jaalah-akamai marked this conversation as resolved.
Outdated

export default enhanced(ClusterActionMenu);
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Config } from '@linode/api-v4/lib/linodes/types';
import { APIError } from '@linode/api-v4/lib/types';
import { withSnackbar, WithSnackbarProps } from 'notistack';
import * as React from 'react';
import { QueryClient } from 'react-query';
import { connect, MapDispatchToProps } from 'react-redux';
Expand Down Expand Up @@ -94,7 +93,6 @@ type CombinedProps = Props &
DispatchProps &
RouteProps &
StyleProps &
WithSnackbarProps &
WithProfileProps;

export class ListLinodes extends React.Component<CombinedProps, State> {
Expand Down Expand Up @@ -480,7 +478,6 @@ const connected = connect(mapStateToProps, mapDispatchToProps);

export const enhanced = compose<CombinedProps, Props>(
withRouter,
withSnackbar,
connected,
styled,
withFeatureFlagConsumer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
LongviewClient,
LongviewSubscription,
} from '@linode/api-v4/lib/longview/types';
import { withSnackbar, WithSnackbarProps } from 'notistack';
import { isEmpty, pathOr } from 'ramda';
import * as React from 'react';
import { connect } from 'react-redux';
Expand Down Expand Up @@ -79,7 +78,6 @@ interface Props {
export type CombinedProps = Props &
RouteComponentProps &
LongviewProps &
WithSnackbarProps &
StateProps;

type SortKey = 'name' | 'cpu' | 'ram' | 'swap' | 'load' | 'network' | 'storage';
Expand Down Expand Up @@ -334,8 +332,7 @@ const connected = connect(mapStateToProps);
export default compose<CombinedProps, Props & RouteComponentProps>(
React.memo,
connected,
withLongviewClients(),
withSnackbar
withLongviewClients()
)(LongviewClients);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ const props: CombinedProps = {
deleteLongviewClient: jest.fn(),
getLongviewClients: jest.fn().mockResolvedValue([]),
updateLongviewClient: jest.fn(),
enqueueSnackbar: jest.fn(),
closeSnackbar: jest.fn(),
activeSubscription: longviewSubscriptionFactory.build(),
lvClientData: {},
handleAddClient: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ActiveLongviewPlan,
LongviewSubscription,
} from '@linode/api-v4/lib/longview/types';
import { withSnackbar, WithSnackbarProps } from 'notistack';
import { useSnackbar } from 'notistack';
import { isEmpty } from 'ramda';
import * as React from 'react';
import { matchPath, RouteComponentProps } from 'react-router-dom';
Expand All @@ -28,13 +28,12 @@ import SubscriptionDialog from './SubscriptionDialog';
const LongviewClients = React.lazy(() => import('./LongviewClients'));
const LongviewPlans = React.lazy(() => import('./LongviewPlans'));

type CombinedProps = LongviewProps &
RouteComponentProps<{}> &
WithSnackbarProps;
type CombinedProps = LongviewProps & RouteComponentProps<{}>;

export const LongviewLanding: React.FunctionComponent<CombinedProps> = (
props
) => {
const { enqueueSnackbar } = useSnackbar();
const activeSubscriptionRequestHook = useAPIRequest<ActiveLongviewPlan>(
() => getActiveLongviewPlan().then((response) => response),
{}
Expand Down Expand Up @@ -93,7 +92,7 @@ export const LongviewLanding: React.FunctionComponent<CombinedProps> = (
setSubscriptionDialogOpen(true);
} else {
// Any network or other errors handled with a toast
props.enqueueSnackbar(
enqueueSnackbar(
getAPIErrorOrDefault(
errorResponse,
'Error creating Longview client.'
Expand Down Expand Up @@ -180,6 +179,5 @@ export const LongviewLanding: React.FunctionComponent<CombinedProps> = (
};

export default compose<CombinedProps, {} & RouteComponentProps>(
withLongviewClients(),
withSnackbar
withLongviewClients()
)(LongviewLanding);

This file was deleted.

Loading