Skip to content

Commit 20e5ba7

Browse files
Merge pull request #180 from 51Degrees/feature/audit-log-v2-pattern-library
2 parents 9cbed9f + 004f9da commit 20e5ba7

70 files changed

Lines changed: 17225 additions & 8 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTORS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Project Contributors
2+
3+
The following companies have helped make this project:
4+
5+
[51Degrees](https://51degrees.com) provide real time high performance open source solutions for the open web.

paf-mvp-audit/src/model.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,27 @@ export class Model implements IModel {
1919
/**
2020
* The data fields that relate to each transmission result to be displayed.
2121
*/
22-
readonly results: FieldTransmissionResult[];
22+
readonly results: FieldTransmissionResult[] = [];
2323

2424
/**
2525
* All the fields that need to be bound.
2626
*/
27-
readonly allFields: IFieldBind[];
27+
readonly allFields: IFieldBind[] = [];
2828

2929
/**
3030
* Constructs the data model from the audit log.
3131
* @param audit
3232
*/
3333
constructor(audit: AuditLog) {
34-
this.results = [];
35-
for (let i = 0; i < audit.transmissions.length; i++) {
36-
this.results.push(new FieldTransmissionResult(this, audit.transmissions[i]));
37-
}
38-
this.allFields = this.results;
34+
audit.transmissions?.forEach((t) => {
35+
const field = new FieldTransmissionResult(this, t);
36+
this.results.push(field);
37+
this.allFields.push(field);
38+
});
3939
}
4040

4141
/**
42-
* Calls the refresh method on all the fields in the model to connect them to the currently displayed UI.
42+
* Calls the updateUI method on all the fields in the model to connect them to the currently displayed UI.
4343
*/
4444
public updateUI() {
4545
this.allFields?.forEach((f) => f.updateUI());
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"sourceType": "unambiguous",
3+
"presets": [
4+
[
5+
"@babel/preset-env",
6+
{
7+
"shippedProposals": true,
8+
"loose": true
9+
}
10+
],
11+
"@babel/preset-typescript"
12+
],
13+
"plugins": [
14+
"@babel/plugin-transform-shorthand-properties",
15+
"@babel/plugin-transform-block-scoping",
16+
[
17+
"@babel/plugin-proposal-decorators",
18+
{
19+
"legacy": true
20+
}
21+
],
22+
[
23+
"@babel/plugin-proposal-class-properties",
24+
{
25+
"loose": true
26+
}
27+
],
28+
[
29+
"@babel/plugin-proposal-private-methods",
30+
{
31+
"loose": true
32+
}
33+
],
34+
"@babel/plugin-proposal-export-default-from",
35+
"@babel/plugin-syntax-dynamic-import",
36+
[
37+
"@babel/plugin-proposal-object-rest-spread",
38+
{
39+
"loose": true,
40+
"useBuiltIns": true
41+
}
42+
],
43+
"@babel/plugin-transform-classes",
44+
"@babel/plugin-transform-arrow-functions",
45+
"@babel/plugin-transform-parameters",
46+
"@babel/plugin-transform-destructuring",
47+
"@babel/plugin-transform-spread",
48+
"@babel/plugin-transform-for-of",
49+
"babel-plugin-macros",
50+
"@babel/plugin-proposal-optional-chaining",
51+
"@babel/plugin-proposal-nullish-coalescing-operator",
52+
[
53+
"babel-plugin-polyfill-corejs3",
54+
{
55+
"method": "usage-global",
56+
"absoluteImports": "core-js",
57+
"version": "3.21.0"
58+
}
59+
]
60+
]
61+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
storybook-static
3+
build/*
4+
!build/index.html
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const path = require("path");
2+
3+
module.exports = {
4+
"stories": [
5+
"../stories/**/*.stories.mdx",
6+
"../stories/**/*.stories.@(js|jsx|ts|tsx)"
7+
],
8+
"addons": [
9+
"@storybook/addon-links",
10+
"@storybook/addon-essentials"
11+
],
12+
"framework": "@storybook/html",
13+
staticDirs: ["../assets"],
14+
webpackFinal: async (config, { configType }) => {
15+
// `configType` has a value of 'DEVELOPMENT' or 'PRODUCTION'
16+
// You can change the configuration based on that.
17+
// 'PRODUCTION' is used when building the static version of storybook.
18+
19+
// Make whatever fine-grained changes you need
20+
config.module.rules.push({
21+
test: /\.scss$/,
22+
use: ['style-loader', 'css-loader', 'sass-loader'],
23+
include: path.resolve(__dirname, '../'),
24+
});
25+
26+
// Return the altered config
27+
return config;
28+
},
29+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import pretty from "pretty";
2+
import "../styles/ok-ui-audit.scss";
3+
import "../javascript/ok-ui.js";
4+
import { addDecorator } from '@storybook/html';
5+
6+
export const parameters = {
7+
layout: 'padded',
8+
previewTabs: {
9+
canvas: { hidden: true }
10+
},
11+
actions: { argTypesRegex: "^on[A-Z].*" },
12+
backgrounds: {
13+
default: 'background',
14+
values: [
15+
{
16+
name: 'background',
17+
value: '#F7F9FC',
18+
}
19+
],
20+
},
21+
controls: {
22+
matchers: {
23+
color: /(background|color)$/i,
24+
date: /Date$/,
25+
},
26+
},
27+
docs: {
28+
transformSource: input => pretty(input, { ocd: true })
29+
}
30+
}
31+
32+
// this is an important piece of code that ensures every component/group is wrapped in the requisite OneKey container
33+
addDecorator(story => `
34+
<aside class="ok-ui">${story()}</aside>
35+
`);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Storybook",
9+
"type": "node-terminal",
10+
"request": "launch",
11+
"command": "npm run storybook",
12+
"cwd": "${workspaceFolder}"
13+
}
14+
]
15+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{
2+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"type": "shell",
6+
"label": "Build CSS",
7+
"command": "npm run build-css",
8+
}
9+
]
10+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# OneKey UI
2+
3+
## Installation
4+
5+
- `npm install` to install the dependencies
6+
- `npm start` to run the pattern library
7+
8+
## Documentation
9+
10+
The docs for using, building, and customising the pattern library are available within the pattern library itself:
11+
12+
- http://localhost:6006/
13+
- Or [stories/Introduction.stories.mdx](stories/Introduction.stories.mdx)

0 commit comments

Comments
 (0)