Skip to content

Commit

Permalink
chore: merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtek-krysiak committed Aug 30, 2020
2 parents 945f729 + 5df0138 commit 6ad1410
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 23 deletions.
5 changes: 4 additions & 1 deletion example-app/src/nested/value-trigger.component.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React from 'react'
import { EditPropertyProps } from 'admin-bro'
import { EditPropertyProps, unflatten } from 'admin-bro'
import { Button, Box } from '@admin-bro/design-system'

const ValueTrigger: React.FC<EditPropertyProps> = (props) => {
const { onChange, record } = props

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const data = unflatten(record.params)

const handleClick = (): void => {
onChange({
...record,
Expand Down
2 changes: 2 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import AdminBro from './types/src/admin-bro'
import * as ACTIONS from './types/src/backend/actions/index'
import { ReduxState } from './types/src/frontend/store/store'

export { flatten, unflatten } from './types/src/admin-bro'

export * from '@admin-bro/design-system'
export * from './types/src/frontend/store/store'
export * from './types/src/backend/utils/build-feature'
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const { buildFeature, mergeResourceOptions } = require('./lib/backend/utils/buil

AdminBro.buildFeature = buildFeature
AdminBro.mergeResourceOptions = mergeResourceOptions
AdminBro.flatten = require('./lib/admin-bro').flatten
AdminBro.unflatten = require('./lib/admin-bro').unflatten

AdminBro.require = AdminBro.bundle
Object.keys(constants).forEach((key) => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "admin-bro",
"version": "3.1.0-beta.5",
"version": "3.1.2",
"description": "Admin panel for apps written in node.js",
"main": "index.js",
"types": "index.d.ts",
Expand Down
2 changes: 2 additions & 0 deletions src/admin-bro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as _ from 'lodash'
import * as path from 'path'
import * as fs from 'fs'
import i18n, { i18n as I18n } from 'i18next'
import { flatten, unflatten } from 'flat'

import AdminBroOptions, { AdminBroOptionsWithDefault } from './admin-bro-options.interface'
import BaseResource from './backend/adapters/base-resource'
Expand Down Expand Up @@ -356,5 +357,6 @@ interface AdminBro extends TranslateFunctions {}

export const { registerAdapter } = AdminBro
export const { bundle } = AdminBro
export { flatten, unflatten }

export default AdminBro
16 changes: 0 additions & 16 deletions src/backend/utils/request-parser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ describe('RequestParser', function () {
describe('boolean values', function () {
beforeEach(function () {
resource = buildResourceWithProperty('isHired', {
isDisabled: () => false,
type: () => 'boolean',
})
})
Expand All @@ -45,19 +44,4 @@ describe('RequestParser', function () {
expect(requestParser(request, resource).payload?.isHired).to.be.false
})
})

describe('disabled values', function () {
beforeEach(function () {
resource = buildResourceWithProperty('anyProperty', {
isDisabled: () => true,
type: () => 'number',
})
})

it('strips payload from disabled properties', function () {
const request = { ...baseRequest, payload: { anyProperty: 'yeAaa' } }

expect(requestParser(request, resource).payload?.anyProperty).to.be.undefined
})
})
})
5 changes: 0 additions & 5 deletions src/backend/utils/request-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ const RequestParser = (originalRequest: ActionRequest, resource: BaseResource):
if (formValue === FORM_VALUE_EMPTY_ARRAY) { value = [] }

if (property) {
// Strip payload from disabled properties.
// isDisabled method has been added recently so this check is needed
// so adapters with older version of admin-bro will also work
if (property.isDisabled && property.isDisabled()) { return { ...memo } }

if (property.type() === 'boolean') {
if (value === 'true') { return { ...memo, [path]: true } }
if (value === 'false') { return { ...memo, [path]: false } }
Expand Down
3 changes: 3 additions & 0 deletions src/frontend/bundle-entry.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { BrowserRouter } from 'react-router-dom'
import { ThemeProvider } from 'styled-components'
import { initReactI18next } from 'react-i18next'
import i18n from 'i18next'
import flat from 'flat'

import App from './components/application'
import BasePropertyComponent from './components/property-type'
Expand Down Expand Up @@ -58,6 +59,8 @@ export default {
env,
...AppComponents,
...Hooks,
flatten: flat.flatten,
unflatten: flat.unflatten,
// DEPRECATED: this should be removed in the next version
// now it was added here to ensure backwards compatibility
// window.AdminBroDesignSystem is set by design-system bundle
Expand Down

0 comments on commit 6ad1410

Please sign in to comment.