mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
UI Plugin API (#4256)
* Add page registration * Add example plugin * First version of proper react plugins * Make reference react plugin * Add patching functions * Add tools link poc * NavItem poc * Add loading hook for lazily loaded components * Add documentation
This commit is contained in:
@@ -33,6 +33,7 @@ import {
|
||||
faVideo,
|
||||
} from "@fortawesome/free-solid-svg-icons";
|
||||
import { baseURL } from "src/core/createClient";
|
||||
import { PatchComponent } from "src/pluginApi";
|
||||
|
||||
interface IMenuItem {
|
||||
name: string;
|
||||
@@ -158,6 +159,20 @@ const newPathsList = allMenuItems
|
||||
.filter((item) => item.userCreatable)
|
||||
.map((item) => item.href);
|
||||
|
||||
const MainNavbarMenuItems = PatchComponent(
|
||||
"MainNavBar.MenuItems",
|
||||
(props: React.PropsWithChildren<{}>) => {
|
||||
return <Nav>{props.children}</Nav>;
|
||||
}
|
||||
);
|
||||
|
||||
const MainNavbarUtilityItems = PatchComponent(
|
||||
"MainNavBar.UtilityItems",
|
||||
(props: React.PropsWithChildren<{}>) => {
|
||||
return <Nav>{props.children}</Nav>;
|
||||
}
|
||||
);
|
||||
|
||||
export const MainNavbar: React.FC = () => {
|
||||
const history = useHistory();
|
||||
const location = useLocation();
|
||||
@@ -335,7 +350,7 @@ export const MainNavbar: React.FC = () => {
|
||||
<Navbar.Collapse className="bg-dark order-sm-1">
|
||||
<Fade in={!loading}>
|
||||
<>
|
||||
<Nav>
|
||||
<MainNavbarMenuItems>
|
||||
{menuItems.map(({ href, icon, message }) => (
|
||||
<Nav.Link
|
||||
eventKey={href}
|
||||
@@ -354,8 +369,10 @@ export const MainNavbar: React.FC = () => {
|
||||
</LinkContainer>
|
||||
</Nav.Link>
|
||||
))}
|
||||
</Nav>
|
||||
<Nav>{renderUtilityButtons()}</Nav>
|
||||
</MainNavbarMenuItems>
|
||||
<MainNavbarUtilityItems>
|
||||
{renderUtilityButtons()}
|
||||
</MainNavbarUtilityItems>
|
||||
</>
|
||||
</Fade>
|
||||
</Navbar.Collapse>
|
||||
@@ -376,7 +393,9 @@ export const MainNavbar: React.FC = () => {
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
{renderUtilityButtons()}
|
||||
<MainNavbarUtilityItems>
|
||||
{renderUtilityButtons()}
|
||||
</MainNavbarUtilityItems>
|
||||
<Navbar.Toggle className="nav-menu-toggle ml-sm-2">
|
||||
<Icon icon={expanded ? faTimes : faBars} />
|
||||
</Navbar.Toggle>
|
||||
|
||||
Reference in New Issue
Block a user