Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@shopware-ag/admin-app-actions

Package Overview
Dependencies
Maintainers
6
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopware-ag/admin-app-actions

A small library for App iframes to communicate with the Shopware Adminstration.

  • 0.0.5
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
6
Weekly downloads
 
Created
Source

Warning:

This repository is still under development and should not be used yet.


E2E Tests Lint NPM_SIZE

Admin app actions

for the Shopware 6 app system

Open documentation

This small library is for using admin actions in your app iframes.

Your app can then extend the Administration with many different actions, customizing UI elements and more. It can send actions to the administration or receive data from it.

send('redirect', {
  url: 'https://www.shopware.com',
  newTab: true
})

Installation

Using NPM:

Install it to your package.json

npm i --save @shopware-ag/admin-app-actions

Then import it in your app:

import { send } from '@shopware-ag/admin-app-actions';
Using CDN:

Import the source from the CDN:

// use the latest version available
<script src="https://unpkg.com/@shopware-ag/admin-app-actions"></script>

// use a fix version (example here: 1.2.3)
<script src="https://unpkg.com/@shopware-ag/admin-app-actions@1.2.3"></script>

Then you can access it with the global variable AdminAppActions.

const { send } = AdminAppActions;

Features

  • Simple API
  • Sending actions to the admin
  • Receive data from the admin
  • Extremely small footprint on app side
  • Full Typescript support

Simple API

The API is very expressive and easy to learn. You just need to import our library and then you can use the send method for sending actions and receiving data.

The iframe are using only the function send for sending the actions. The first parameter is the action-type and the second parameter contains the options for the action.

import { send } from '@shopware-ag/admin-app-actions';

send('redirect', {
  url: 'https://www.shopware.com',
  newTab: true,
})

If the action has a response then you can get the information with the returned Promise value:

import { send } from '@shopware-ag/admin-app-actions';

const pageTitle = await send('getPageTitle', {});

Extremely small footprint on app side

The bundle size of this library is extremely small and will not grow when new actions will be defined. How is this done? The functions only execute the commands. Only types are describing the API and therefore not increase the bundle size.

Full Typescript support

Typescript provides a good developer experience for everyone using this tool. Every action and options can be autocompleted by the IDE. If you are also writing your application in Typescript you get direct feedback if you are doing a mistake in using the API.

A full auto-generated API documentation can be found in the documentation: https://shopware.github.io/admin-app-actions/


Recipient (only for usage in the Shopware 6 Administration):

The Shopware 6 administration listens to all messages. If a message matches an action then the given functionality will be called. Here is an example code how it can look like:

import { on } from '@shopware-ag/admin-app-actions';

on('redirect', ({ newTab, url }) => {  
  // call a method which redirects to the url
  redirect({ newTab, url });
})

on('getPageTitle', () => {  
  // or return the value if the type needs a response
  return document.title;
})

Keywords

FAQs

Package last updated on 12 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc