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

q3-admin

v4.5.15

Published

Q3 admin ships with a default component that handles most state and routing for you. As such, there's a lot of props available to customize this setup process. Most are optional and used in more advanced cases.

Downloads

571

Readme

🧰 Q3 Admin

Containers

Admin

Q3 admin ships with a default component that handles most state and routing for you. As such, there's a lot of props available to customize this setup process. Most are optional and used in more advanced cases.

API

| Prop | Description | Type | | -------------------- | ---------------------------------------------------------------- | -------- | | AppProps.directory | The relative path where Q3 renders (i.e. /app/) | string | | AppProps.pages | Collections to render. See AbstractBuilder for data structure. | array |

Example

import React from 'react';
import Admin from 'q3-admin';
import { Builders } from 'q3-ui-forms';
import Tests from './components/Tests';

export default () => (
  <Admin AppProps={{ pages }}>
    <Tests path="/tests" />
  </Admin>
);

Detail

The container for viewing individual documents in Q3. When using the builders, properties of genDetail and genDetailProps are assembled into this container.

API

| Prop | Description | Type | | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ------------- | | registerOptions | Used to register custom UI elements in the detail side panel. Options can be programmatically setup or inferred (see example below). | func/array* | | registerPanels | Same as above for usage, though this prop is intended for lengthier content and actions. | func/array* |

Example

// programmatic method
export const registerOptions = (data, dispatchers, t) => {
  const out = [];
  if (data.isOn)
    out.push({
      title: t('titles:hello'),
      component: () => null,
    });

  return out;
};

// inferred method
export const registerPanels = [
  {
    // is localized
    title: 'hello',
    // receives all params from method above
    component: ({ data, dispatchers, t }) => null,
    // runs through comparisons for easy conditional rendering
    conditions: ['foo=1'],
  },
];

Gatekeeper

The container for checking user authentication. Redirects users if necessary.

API

| Prop | Description | Type | | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | | redirectCheck | Redirects users when the function returns a string. The function can take user profile as an argument. Note: redirectPathOnPublic and redirectPathOnSession are evaluated before this function. | func | | redirectPathOnSession | Redirects a user when logged in and this prop is a string. | string | | redirectPathOnPublic | Redirects a user when not logged in and this prop is a string | string | | children | children will be returned when none of conditions are true | node |

Example

import { Gatekeeper } from  'q3-admin/lib/containers';
import  IsBrowserReady  from  'gatsby-theme-q3/src/components/IsBrowserReady';

const shouldRedirect = (auth) => auth.role === 'Employer" ? '/employers' : undefined;

const AdminPrivateGateway = ({ children, ...rest }) => {
	return (
		<IsBrowserReady>
			<Gatekeeper
				redirectCheck={shouldRedirect}
				redirectPathOnPublic="/login"
				{...rest}
			>
				{children}
			</Gatekeeper>
		</IsBrowserReady>
	);
};

Components

SidePanelAction

This component standardizes the UI for single-click actions in the Detail SidePanel implementation.

API

| Prop | Description | Type | | ------------- | ------------------------------------ | --------- | | description | A key for the descriptions namespace | string* | | label | A key for the labels namespace | string* | | onClick | A callback for the default button | func* |

Example

import { SidePanelAction } from 'q3-admin/lib/components';

export default ({ isOn, update }) => (
  <SidePanelAction
    description="enableFeature"
    label={isOn ? 'off' : 'on'}
    onClick={update(!isOn)}
  />
);

Hooks

useIo

Returns exportCollection and importCollection for connecting to Q3 API's process automation. Both methods are curried and intended for use with click handlers. Note that this hook does not actual call React hooks API, so it may be used in non-components.

API

| Parameter | Description | Type | | --------- | ----------------------------------------------------------- | -------- | ------ | | ids | Document IDs to target in the bulk operation | string | array | | params | Location URL parameter methods (i.e. delete, set, toString) | object |

Example

import { useIo } from 'q3-admin/lib/hooks';
import { withLocation } from 'with-location';

export default withLocation(({ params }) => {
  const { exportCollection } = useIo(1, params);
  return (
    <button
      type="button"
      onClick={exportCollection('templateName')}
    >
      Export ID #1
    </button>
  );
});