2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-30 18:50:53 +00:00

React UI improvements (#5756)

* Add CompanyDetail page

* Add "edit company" button (and associated form)

* Implement dropdown actions for company page

* Update actions for PartDetail

* Adds overlay while modal is loading

- Lets the user know that something is at least happening in the background

* Update panels

* Implement separate pages for different company types

- Mostly for better breadcrumbs

* Placeholder actions for build detail

* Add stock table to company page

* typescript linting

* Fix unused variables

* remove dodgy improt
This commit is contained in:
Oliver
2023-10-20 00:23:58 +11:00
committed by GitHub
parent ae063d2722
commit e57b69be48
21 changed files with 689 additions and 93 deletions

View File

@ -0,0 +1,65 @@
import { ActionIcon, Menu, Tooltip } from '@mantine/core';
import { ReactNode, useMemo } from 'react';
import { notYetImplemented } from '../../functions/notifications';
export type ActionDropdownItem = {
icon: ReactNode;
name: string;
tooltip?: string;
disabled?: boolean;
onClick?: () => void;
};
/**
* A simple Menu component which renders a set of actions.
*
* If no "active" actions are provided, the menu will not be rendered
*/
export function ActionDropdown({
icon,
tooltip,
actions
}: {
icon: ReactNode;
tooltip?: string;
actions: ActionDropdownItem[];
}) {
const hasActions = useMemo(() => {
return actions.some((action) => !action.disabled);
}, [actions]);
return hasActions ? (
<Menu position="bottom-end">
<Menu.Target>
<Tooltip label={tooltip}>
<ActionIcon size="lg" radius="sm" variant="outline">
{icon}
</ActionIcon>
</Tooltip>
</Menu.Target>
<Menu.Dropdown>
{actions.map((action, index) =>
action.disabled ? null : (
<Tooltip label={action.tooltip}>
<Menu.Item
icon={action.icon}
key={index}
onClick={() => {
if (action.onClick != undefined) {
action.onClick();
} else {
notYetImplemented();
}
}}
disabled={action.disabled}
>
{action.name}
</Menu.Item>
</Tooltip>
)
)}
</Menu.Dropdown>
</Menu>
) : null;
}