1.0.5 • Published 1 year ago

md-ext v1.0.5

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

Managment Dashboard extension

Installation

npm i md-ext
yarn add md-ext

Init client

Initialise client for Managment Portal Context changes

import {
  registerClient,
} from 'md-ext/lib'

registerClient();

Context

App Context passed to callback from Managment Dashboard

NameTypeNullable
accessTokenstringyes
tenantstringyes
configurationConfigurationyes
siteSite[]yes
currentSiteSiteyes
currencyCurrencyyes
languageLanguageyes
clientsClient[]yes

Configuration

NameTypeNullable
currenciesCurrency[]no
languagesLanguage[]no
themeThemeno

Client

NameTypeNullable
tenantstringno
clientIdstring[]no

Currency, Language,

NameTypeNullable
idstringno
labelstringno
defaultbooleanno
requiredbooleanno

Site

NameTypeNullable
activebooleanno
codestringno
currencystringno
defaultbooleanno
defaultLanguagestringno
languagesstring[]no
namestringno

Theme

  colors: {
    default: string
    primary: string
    secondary: string
  }
  logos: {
    dark: string
    light: string
  }

Add state changes callback

Registers a callback fired everytime Context changes. First argument is a key handler (string) and the second is callback function

import {
  registerCallback,
} from 'md-ext/lib'


registerCallback('callbackId', (ctx) => {
  console.log('context update', ctx)
})

Remove statechange callback

In order to unregister from Context changes unregisterCallback must be called with callbackId.

yarn build
import {
  unregisterCallback,
} from ''md-ext/lib''
unregisterCallback('callbackId')

Deeplinking

To ensure Managment Dashboard url refleks the extansion url a thus having ability to have deeplinking enabled in client module you need to sync your current path with Managment dashboard.

import { syncUrl } from 'md-ext/lib'


syncUrl(<current path>)

Example Vue implementation:

  setup() {
    const route = useRoute()
    watch(route, () => {
      syncUrl(route.fullPath)
    })
  },

Example React implementation:

  useEffect(() => {
    syncUrl('/' + location.pathname);
  }, [location]);
1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago