Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
@balena/autoui
Advanced tools
A library of UI components, built using [React][react], [styled-components][styled-components] to allow building a UI just using a model.
A library of UI components, built using React, [styled-components][styled-components] to allow building a UI just using a model.
npm install --save autoui
Wrap your application in the AutoUIProvider
component and start using components!
import React from 'react';
import ReactDOM from 'react-dom';
import { AutoUIProvider } from 'autoui';
import { useAnalyticsContext } from '@balena/ui-shared-components';
import {
AutoUIBaseResource,
AutoUIRawModel,
autoUIDefaultPermissions,
autoUIJsonSchemaPick,
autoUIRunTransformers,
autoUIGetModelForCollection,
} from 'autoui';
type AugmentedRelease = AutoUIBaseResource<{}>
interface EntityType {
id: number,
name: string,
surname: string,
}
const observerPermissions = {
read: [
'id',
'name',
'surname',
],
create: [],
update: [],
delete: false,
};
const adminPermissions = {
...observerPermissions,
create: ['name'],
update: ['name'],
delete: true,
};
const model = {
resource: 'user',
schema: {
type: 'object',
required: [],
properties: {
id: {
title: 'Id',
type: 'number',
},
name: {
title: 'Name',
type: 'string',
},
surname: {
title: 'Surname',
type: 'string',
},
},
},
permissions: {
default: autoUIDefaultPermissions,
administrator: adminPermissions,
developer: adminPermissions,
member: autoUIDefaultPermissions,
operator: observerPermissions,
observer: observerPermissions,
support_agent: observerPermissions,
balena_admin: observerPermissions,
},
priorities: {
primary: ['name'],
secondary: [
'surname',
'id',
],
tertiary: [],
},
} as AutoUIRawModel<Partial<AugmentedRelease>>;
// where the UI can add new properties, but this will be removed soon as everything should live in the model
const transformers = {
__permissions: (entity: BalenaSdk.Release, context: any) => {
return model(getExpanded(entity.belongs_to__application)?.is_of__class!)
.permissions[context.accessRole ?? 'default'];
},
};
const App = () => {
const data = [
{
"id": 2313948,
"name": "John",
"surname": "Smith",
},
{
"id": 2307403,
"name": "Robert",
"surname": "Taylor",
}
]
const memoizedData = React.useMemo(() => {
return autoUIRunTransformers(data, transformers, {});
}, [data]);
const memoizedModel = React.useMemo(() => {
return autoUIGetModelForCollection(model);
}, [model]);
return (
<AnalyticsContextProvider>
<AutoUIProvider>
<AutoUI<EntityType>
data={data}
model={model}
/>
</AutoUIProvider>
</AnalyticsContextProvider>
);
};
ReactDOM.render(
<App/>,
document.getElementById('root')
);
Wrap your application in the <Provider>
component so that child components can correctly inherit the following properties:
t
: used for translations (expected lib i18n-next
)history
: used to allow persistent filters. (expected lib history
)externalTranslationMap
: used to add translations for resources (e.g. {'resource.application': 'Applications'}). Usually used if i18n-next
is not used.The AnalyticsContextProvider
is a mandatory wrapper that is used to send analytics to our Analytics Backend.
If you don't want to send analytics you can instantiate the component without any props.
Please read our contribution guidelines
v7.3.0
react-router-dom
v5 history
and v6 navigate
[myarmolinsky]FAQs
A library of UI components, built using [React][react], [styled-components][styled-components] to allow building a UI just using a model.
The npm package @balena/autoui receives a total of 1,051 weekly downloads. As such, @balena/autoui popularity was classified as popular.
We found that @balena/autoui demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.