npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dso-react-plugin-inventory

v0.0.2

Published

The Inventory Plugin is designed to help you manage and organize various resources in your application. This plugin allows you to register and manage different resources such as locations, groups, and more.

Downloads

13

Readme

Inventory Plugin

The Inventory Plugin is designed to help you manage and organize various resources in your application. This plugin allows you to register and manage different resources such as locations, groups, and more.

Built With

  • Menu UI: React + styled-component + Ant Design.
  • State management: Zustand.
  • Package management: yarn (recommended yarn, should not use npm or bun).
  • IDE: VS Code.

Table of Contents

Installation

First, copy this git repository of inventory plugin, named this link:

https://git.dision.office/dso637/dso-react-plugin-inventory.git

Then import it into your package.json at dependencies section

 "dependencies": {
	"@ant-design/icons": "^5.4.0",`
	"dso-react-plugin-inventory": "https://git.dision.office/dso637/dso-react-plugin-inventory.git",`
	"antd": "^5.19.2",
	"pocketbase": "^0.21.3",
	"react": "^18.3.1",
	"react-dom": "^18.3.1",
	"react-router-dom": "6",
	"zustand": "^4.5.4"
`},

Then, install packages using npm/yarn/bun: (recommended yarn)

Then, install packages using npm/yarn/bun: (recommended yarn)

npm i or yarn or bun i

How to use Inventory Plugin

Overview

    import { ExamplePlugin } from 'ds-example-plugin';
    import { ReactNode, useState } from 'react';
    import { BrowserRouter } from 'react-router-dom';
    import { useMainComponentStore } from './common/main-stores';

    function SampleUsePlugin() {
      const { registerPlugin } = useMainComponentStore();
      return (
        <BrowserRouter>
           <ExamplePlugin
    	     backendProvider={pocketBase};
             activePlugin={(plugin: TRegisterPlugin, menu: React.ReactNode) => {
                registerPlugin(plugin);
               // Do some stuff with menu that Plugin returned.
             }}
           />
        </BrowserRouter>
      );
    }
    export default SampleUsePlugin;

Type of ExamplePlugin

type TExamplePlugin = {
  label?: ReactNode,
  basePath?: string,
  icon?: JSX.Element,
  activePlugin: (pluginConfig: TRegisterPlugin, menu: ReactNode) => void,
  dataProvider?: any,
};

Note: registerPlugin is the function register that can take Router setup from your plugin.

Definitions

  • activePlugin: This function is used to register routes for the ExamplePlugin. When a plugin is activated, this function registers the plugin and updates the component state to render the <Menu> component.
  • backendProvider: This refers to the data provider object used for handling data types within the application.

How to create a Plugin like Inventory Plugin

Create file Plugin.tsx.

Step 1: Create a Functional Component Plugin, cover it by PluginManagerProvider and DataProvider respectively.

import React, { useEffect } from "react";
import { DataProvider, PluginManagerProvider } from "./cores/providers";
import { TPlugin } from "./types";
const Plugin: React.FC<TPlugin> = ({
  label = "YOUR_DEFAULT_PLUGIN_NAME",
  basePath = "/YOUR_DEFAULT_BASE_PATH",
  icon,
}) => {
  return (
    <PluginManagerProvider sourcePath={basePath}>
      <DataProvider>{/* Child components */}</DataProvider>
    </PluginManagerProvider>
  );
};

export default Plugin;

Note: replace YOUR_DEFAULT_PLUGIN_NAME and YOUR_DEFAULT_BASE_PATH by your own default configs.

Step 2: Import our <RouteResources/> for registration router for your elements in Plugin.

import React, { useEffect } from "react";
import { RouteResource } from "./bases";
import { DataProvider, PluginManagerProvider } from "./cores/providers";
import { TPlugin } from "./types";
const Plugin: React.FC<TPlugin> = ({
  label = "YOUR_DEFAULT_PLUGIN_NAME",
  basePath = "/YOUR_DEFAULT_BASE_PATH",
  icon,
}) => {
  return (
    <PluginManagerProvider sourcePath={basePath}>
      <DataProvider>
        <RouteResources
          key={"sample_name"}
          name={"sample_name"}
          element={/*Implement your render component*/}
        />
      </DataProvider>
    </PluginManagerProvider>
  );
};

export default Plugin;

Step 3: Import our <Resources/> component to implement CRUD for your elements.

import React, { useEffect } from "react";
import { TPlugin } from "./types";
import { RouteResource } from "./bases";
import { DataProvider, PluginManagerProvider } from "./cores/providers";
import { sampleList, SampleEdit, SampleCreate } from "./PluginSampleConfig";
const Plugin: React.FC<TPlugin> = ({
  label = "YOUR_DEFAULT_PLUGIN_NAME",
  basePath = "/YOUR_DEFAULT_BASE_PATH",
  icon,
}) => {
  return (
    <PluginManagerProvider sourcePath={basePath}>
      <DataProvider>
        <RouteResources
          key={"sample_name"}
          name={"sample_name"}
          element={
            <Resources
              list={sampleList} //your sample
              edit={<SampleEdit />} //your sample
              create={<SampleCreate />} //your sample
            />
          }
        />
      </DataProvider>
    </PluginManagerProvider>
  );
};

export default Plugin;

Step 4: Create listSample, <SampleEdit/> and <SampleCreate />.

Create Folder PluginSampleConfig. Then create file index.tsx. The list has type of TableProps<DataType>['columns'] or we can know as ColumnsType<DataType> of Ant Design table.

  • Note: DataType is depend on your type of data you want to display.
  • Visit: https://ant.design/components/table#column for more information.
import { DiCreate, DiEdit, DiInput } from "../../../bases";

export const sampleList = [
  { title: "Name", dataIndex: "name", key: "name" },
  { title: "Collection", dataIndex: "collectionId", key: "collectionId" },
  { title: "Status", dataIndex: "status", key: "status" },
  { title: "Playbook", dataIndex: "playbook", key: "playbook" },
  { title: "Description", dataIndex: "description", key: "description" },
  /**You can create more based on your DataType, If you setting list dataIndex do not fit your DataType, It will be empty**/
];

export const SampleCreate = () => {
  return (
    <DiCreate>
      <DiInput name={"name"} />
      <DiInput name="collectionId" />
      <DiInput name="playbook" />
    </DiCreate>
  );
};

export const SampleEdit = () => {
  return (
    <DiEdit>
      <DiInput name={"name"} />
      <DiInput name="collectionId" />
      <DiInput name="playbook" />
    </DiEdit>
  );
};