saleor-dashboard/src/components/AppLayout/AppChannelSelect.tsx
Dominik Żegleń a175fb9497
Add global channel picker (#841)
* Move theme switch to user menu

* Add global channel picker

* Fix picker styles

* Use app channel state

* Improve prop naming to indicate id vs slug

* Disable picker if no reason to pick channel

* Remove settings modal leftovers

* Remove channel settings dialog

* Remove unused props

* Skip channel fetching if user is not authenticated

* Remove channel selection from components

* Update messages

* Fix e2e tests

* Remove channel picker leftover

* Revert ChannelSettingsDialog deletion

* Update snapshots

* Update messages
2020-11-23 10:39:24 +01:00

51 lines
1.2 KiB
TypeScript

import makeStyles from "@material-ui/core/styles/makeStyles";
import { ChannelDetailsFragment } from "@saleor/fragments/types/ChannelDetailsFragment";
import { ChannelProps } from "@saleor/types";
import { mapNodeToChoice } from "@saleor/utils/maps";
import React from "react";
import SingleSelectField from "../SingleSelectField";
const useStyles = makeStyles(
theme => ({
root: {
"&& fieldset": {
borderColor: theme.palette.divider
},
marginRight: theme.spacing(2),
width: 192
}
}),
{
name: "AppChannelSelect"
}
);
export interface AppChannelSelectProps extends ChannelProps {
channels: ChannelDetailsFragment[];
disabled: boolean;
onChannelSelect: (id: string) => void;
}
const AppChannelSelect: React.FC<AppChannelSelectProps> = ({
channels,
disabled,
onChannelSelect,
selectedChannelId
}) => {
const classes = useStyles({});
return (
<div className={classes.root}>
<SingleSelectField
choices={mapNodeToChoice(channels)}
disabled={disabled}
value={selectedChannelId}
onChange={event => onChannelSelect(event.target.value)}
/>
</div>
);
};
AppChannelSelect.displayName = "AppChannelSelect";
export default AppChannelSelect;