
* Update schema * Update queries, mutations, and types * Add render with dividers util function * Add plugin details channels card component * Update plugin details to use channels * Update stories * Update plugin configuration type across the app, fix some other types, temporarily comment some things out in plugins list so types match" * Update schema * Update types * Update plugins list to show channels and global statuses, add plugin channel status, update status label component * Add render with dividers util function * Comment out some stuff for types to match - temporary * Add useChannelsSearchWithLoadMore util to imitate loading more from backend for channels list with load more * Change filters logic to be able to display multiple fields in a field section and add it to plugins view * Add scroll option to plugin availability popup on plugin list * Fix plugin list page story * Temporarily comment some stuff out, fix some types * Add filters errors WIP * Fix filters not updating list * Add error handling to plugins list filters and filters in general * Rename some components according to review * Move useChannelsSearch and useChannelsSearchWithLoadMore to hooks, change some imports accordingly * Fix imports * Move render collection with dividers to a component, fix usages * Replace channels with load more and search query to base channels query * Change render with dividers function to take in a component instead of render function * Update tests * Extract messages * Remove unnecessary imports * Fix filters - autocomplete messing items order sometimes & some fields not working * Update plugin update mutation variables - change channelId to channel * fix failing tests * Add test ids * fix failing tests * fix failing tests * Rename misc.tsx to ts * Remove usage of render collection with diviers, change it to CollectionWithDividers component * Remove unnecessary imports * Update messages ids * Update snapshots Co-authored-by: Karolina Rakoczy <rakoczy.karolina@gmail.com>
75 lines
2 KiB
TypeScript
75 lines
2 KiB
TypeScript
import { Typography } from "@material-ui/core";
|
|
import { makeStyles } from "@material-ui/core/styles";
|
|
import StatusLabel from "@saleor/components/StatusLabel";
|
|
import { statusLabelMessages } from "@saleor/components/StatusLabel/messages";
|
|
import { Plugins_plugins_edges_node } from "@saleor/plugins/types/Plugins";
|
|
import { isPluginGlobal } from "@saleor/plugins/views/utils";
|
|
import React from "react";
|
|
import { useIntl } from "react-intl";
|
|
|
|
import { pluginAvailabilityStatusMessages as messages } from "./messages";
|
|
import {
|
|
getActiveChannelConfigsCount,
|
|
getAllChannelConfigsCount
|
|
} from "./utils";
|
|
|
|
const useStyles = makeStyles(
|
|
() => ({
|
|
horizontalContainer: {
|
|
display: "flex",
|
|
flexDirection: "row"
|
|
}
|
|
}),
|
|
{ name: "ChannelStatusLabel" }
|
|
);
|
|
|
|
interface PluginAvailabilityStatusProps {
|
|
plugin: Plugins_plugins_edges_node;
|
|
}
|
|
|
|
const PluginAvailabilityStatus: React.FC<PluginAvailabilityStatusProps> = ({
|
|
plugin: { globalConfiguration, channelConfigurations }
|
|
}) => {
|
|
const classes = useStyles({});
|
|
const intl = useIntl();
|
|
|
|
const isGlobalPlugin = isPluginGlobal(globalConfiguration);
|
|
|
|
const activeChannelsCount = getActiveChannelConfigsCount(
|
|
channelConfigurations
|
|
);
|
|
|
|
const isStatusActive = isGlobalPlugin
|
|
? globalConfiguration.active
|
|
: !!activeChannelsCount;
|
|
|
|
const globalPluginLabel = intl.formatMessage(
|
|
isStatusActive
|
|
? statusLabelMessages.active
|
|
: statusLabelMessages.deactivated
|
|
);
|
|
|
|
return (
|
|
<StatusLabel
|
|
label={
|
|
isGlobalPlugin ? (
|
|
globalPluginLabel
|
|
) : (
|
|
<div className={classes.horizontalContainer}>
|
|
<Typography>
|
|
{intl.formatMessage(messages.channelTitle, {
|
|
activeChannelsCount
|
|
})}
|
|
</Typography>
|
|
<Typography color="textSecondary">{`/${getAllChannelConfigsCount(
|
|
channelConfigurations
|
|
)}`}</Typography>
|
|
</div>
|
|
)
|
|
}
|
|
status={isStatusActive ? "success" : "error"}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default PluginAvailabilityStatus;
|