saleor-dashboard/src/components/TablePagination/TablePagination.tsx
AlicjaSzu 211b0b892d
Apps (#599)
* create Apps view

* create more app components, generate types and messages

* apps refactor, update snapshots

* show error message in tooltip  when app installation fail

* update apps components and view, add apps list to storybook

* update defaultMessages

* create app details view

* update AppListPage with Skeleton component

* create app activate/deactivate dialogs, create app details stories

* add AppHeader to AppDetailsPage

* update defaultMessages

* update AppDetails view and components after review

* create custom app details view

* refactor webhooks

* update webhooks fixtures

* update WebhookDetailsPage story

* update strings

* create CustomAppCreate view and components

* update AppListPage story

* create AppInstall view and page

* handle errors in AppInstall view

* update defaultMessages

* add AppInstallPage to storybook

* add status prop to MessageManager

* update defaultMessages

* remove service account section

* remove service account routes

* remove as operator from notify status

* add notifications for app installations

* update styles for deactivated app

* update app installations with local storage

* update defaultMessages

* AppInstall update

* dd delete button to ongoin installations table

* fix active installations condition

* fix error messages in AppsList

* update defaultMessages

* add iframe to AppDetailsPage

* create AppDetailsSettingsPage

* install macaw-ui

* apps styles clean up

* update schema, fixtures

* few apps updates

* WebhookCreate - fix onBack button name

* WebhookCreatePage story update

* rename apps table from external to thirdparty

* update defaultMessages

* fix test, update snapshots

* AppDetailsSettings - add token to headers

* fix first number in local apps query

* app details settings - use shop domain host

* add onSettingsRowClick to InstalledApps

* resolve conflicts

* update changelog and messages

* add noopener noreferrer do app privacy link

* update snapshots

* update snapshots

* updates after review

* update defaultMessages

* CustomAppDetails - add missing notify status
2020-07-22 12:54:15 +02:00

120 lines
2.9 KiB
TypeScript

import { IconButtonProps } from "@material-ui/core/IconButton";
import { makeStyles } from "@material-ui/core/styles";
import TableCell from "@material-ui/core/TableCell";
import Toolbar from "@material-ui/core/Toolbar";
import RowNumberSelect from "@saleor/components/RowNumberSelect";
import { maybe } from "@saleor/misc";
import React from "react";
import { ListSettings } from "../../types";
import TablePaginationActions from "./TablePaginationActions";
const useStyles = makeStyles(
theme => ({
actions: {
color: theme.palette.text.secondary,
flexShrink: 0,
marginLeft: theme.spacing(2.5)
},
caption: {
flexShrink: 0
},
input: {
flexShrink: 0,
fontSize: "inherit"
},
root: {
"&:last-child": {
padding: 0
}
},
select: {
paddingLeft: theme.spacing(),
paddingRight: theme.spacing(2)
},
selectIcon: {
top: 1
},
selectRoot: {
color: theme.palette.text.secondary,
marginLeft: theme.spacing(),
marginRight: theme.spacing(4)
},
spacer: {
flex: "1 1 100%"
},
toolbar: {
height: 56,
minHeight: 56,
paddingLeft: 2,
paddingRight: 2
}
}),
{ name: "TablePagination" }
);
interface TablePaginationProps {
backIconButtonProps?: Partial<IconButtonProps>;
colSpan: number;
component?: string | typeof TableCell;
settings?: ListSettings;
hasNextPage: boolean;
hasPreviousPage: boolean;
nextIconButtonProps?: Partial<IconButtonProps>;
onNextPage(event);
onPreviousPage(event);
onUpdateListSettings?(key: keyof ListSettings, value: any): void;
}
const TablePagination: React.FC<TablePaginationProps> = props => {
const {
backIconButtonProps,
colSpan: colSpanProp,
component: Component,
settings,
hasNextPage,
hasPreviousPage,
nextIconButtonProps,
onNextPage,
onPreviousPage,
onUpdateListSettings,
...other
} = props;
const classes = useStyles(props);
let colSpan;
if (Component === TableCell || Component === "td") {
colSpan = colSpanProp || 1000;
}
return (
<Component className={classes.root} colSpan={colSpan} {...other}>
<Toolbar className={classes.toolbar}>
<div className={classes.spacer}>
{maybe(() => settings.rowNumber) && (
<RowNumberSelect
choices={[10, 20, 30, 50, 100]}
settings={settings}
onChange={onUpdateListSettings}
/>
)}
</div>
<TablePaginationActions
backIconButtonProps={backIconButtonProps}
hasNextPage={hasNextPage}
hasPreviousPage={hasPreviousPage}
nextIconButtonProps={nextIconButtonProps}
onNextPage={onNextPage}
onPreviousPage={onPreviousPage}
/>
</Toolbar>
</Component>
);
};
TablePagination.defaultProps = {
component: TableCell
};
TablePagination.displayName = "TablePagination";
export default TablePagination;