mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 19:46:46 +00:00
Use ApiIcon for plugin panels (#8496)
- Richer set of icons available - Allows plugin to define their own icon
This commit is contained in:
parent
f9d3f43b02
commit
10e88cd3e4
@ -11,8 +11,13 @@ export const ApiIcon = ({ name: _name, size = 22 }: ApiIconProps) => {
|
|||||||
const icon = useIconState(
|
const icon = useIconState(
|
||||||
(s) => s.packagesMap[iconPackage]?.icons[name]?.variants[variant]
|
(s) => s.packagesMap[iconPackage]?.icons[name]?.variants[variant]
|
||||||
);
|
);
|
||||||
|
|
||||||
const unicode = icon ? String.fromCodePoint(Number.parseInt(icon, 16)) : '';
|
const unicode = icon ? String.fromCodePoint(Number.parseInt(icon, 16)) : '';
|
||||||
|
|
||||||
|
if (!unicode) {
|
||||||
|
console.warn(`ApiIcon not found: ${_name}`);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<i
|
<i
|
||||||
className={classes.icon}
|
className={classes.icon}
|
||||||
|
@ -2,6 +2,7 @@ import { useQuery } from '@tanstack/react-query';
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
|
|
||||||
import { api } from '../App';
|
import { api } from '../App';
|
||||||
|
import { ApiIcon } from '../components/items/ApiIcon';
|
||||||
import type { PanelType } from '../components/panels/Panel';
|
import type { PanelType } from '../components/panels/Panel';
|
||||||
import {
|
import {
|
||||||
type InvenTreeContext,
|
type InvenTreeContext,
|
||||||
@ -15,7 +16,6 @@ import {
|
|||||||
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
||||||
import type { ModelType } from '../enums/ModelType';
|
import type { ModelType } from '../enums/ModelType';
|
||||||
import { identifierString } from '../functions/conversion';
|
import { identifierString } from '../functions/conversion';
|
||||||
import { InvenTreeIcon, type InvenTreeIconType } from '../functions/icons';
|
|
||||||
import { apiUrl } from '../states/ApiState';
|
import { apiUrl } from '../states/ApiState';
|
||||||
import { useGlobalSettingsState } from '../states/SettingsState';
|
import { useGlobalSettingsState } from '../states/SettingsState';
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ export function usePluginPanels({
|
|||||||
const pluginPanels: PanelType[] = useMemo(() => {
|
const pluginPanels: PanelType[] = useMemo(() => {
|
||||||
return (
|
return (
|
||||||
pluginData?.map((props: PluginUIFeature) => {
|
pluginData?.map((props: PluginUIFeature) => {
|
||||||
const iconName: string = props?.icon || 'plugin';
|
const iconName: string = props?.icon || 'ti:plug:outline';
|
||||||
const identifier = identifierString(
|
const identifier = identifierString(
|
||||||
`${props.plugin_name}-${props.key}`
|
`${props.plugin_name}-${props.key}`
|
||||||
);
|
);
|
||||||
@ -102,7 +102,7 @@ export function usePluginPanels({
|
|||||||
return {
|
return {
|
||||||
name: identifier,
|
name: identifier,
|
||||||
label: props.title,
|
label: props.title,
|
||||||
icon: <InvenTreeIcon icon={iconName as InvenTreeIconType} />,
|
icon: <ApiIcon name={iconName} />,
|
||||||
content: (
|
content: (
|
||||||
<PluginPanelContent
|
<PluginPanelContent
|
||||||
pluginFeature={props}
|
pluginFeature={props}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user