Skip to content

Commit

Permalink
test: rename to @admin-bro in the example app
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtek-krysiak committed Jul 27, 2020
1 parent f91f4f2 commit 9527a4a
Show file tree
Hide file tree
Showing 27 changed files with 46 additions and 45 deletions.
2 changes: 1 addition & 1 deletion example-app/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require('dotenv-json')({ path: 'cypress.env.json' })
const express = require('express')
const { default: AdminBro } = require('admin-bro')
const { default: AdminBro } = require('@admin-bro/core')
const mongoose = require('mongoose')
const options = require('./src/admin.options')
const buildAdminRouter = require('./src/admin.router')
Expand Down
1 change: 1 addition & 0 deletions example-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"sequelize": "sequelize"
},
"devDependencies": {
"@admin-bro/design-system": "^1.2.3",
"@types/sequelize": "^4.28.8",
"nodemon": "^2.0.2",
"sequelize-cli": "^5.5.1"
Expand Down
4 changes: 2 additions & 2 deletions example-app/src/admin.options.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { default: AdminBro } = require('admin-bro')
const { default: AdminBro } = require('@admin-bro/core')
const AdminBroMongoose = require('admin-bro-mongoose')
const AdminBroSequelize = require('admin-bro-sequelizejs')

Expand All @@ -17,7 +17,7 @@ AdminBro.bundle('./components/sidebar-footer', 'SidebarFooter')
AdminBro.bundle('./components/no-records', 'NoRecords')
AdminBro.bundle('./components/quill-override')

/** @type {import('admin-bro').AdminBroOptions} */
/** @type {import('@admin-bro/core').AdminBroOptions} */
const options = {
resources: [
AdminCompany,
Expand Down
2 changes: 1 addition & 1 deletion example-app/src/admin.router.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { default: AdminBro } = require('admin-bro')
const { default: AdminBro } = require('@admin-bro/core')
const { buildAuthenticatedRouter } = require('admin-bro-expressjs')
const express = require('express')
const argon2 = require('argon2')
Expand Down
22 changes: 11 additions & 11 deletions example-app/src/companies/actions/password.hook.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
const argon2 = require('argon2');
const AdminBro = require('admin-bro');
const argon2 = require('argon2')
const AdminBro = require('@admin-bro/core')


/** @type {AdminBro.After<AdminBro.ActionResponse>} */
const after = async (response) => {
if (response.record && response.record.errors && response.record.errors.encryptedPassword) {
response.record.errors.password = response.record.errors.encryptedPassword;
response.record.errors.password = response.record.errors.encryptedPassword
}
return response;
};
return response
}

/** @type {AdminBro.Before} */
const before = async (request) => {
if (request.method === 'post') {
const { password, ...otherParams } = request.payload;
const { password, ...otherParams } = request.payload

if (password) {
const encryptedPassword = await argon2.hash(password);
const encryptedPassword = await argon2.hash(password)

return {
...request,
payload: {
...otherParams,
encryptedPassword,
},
};
}
}
}
return request;
};
return request
}

module.exports = { after, before };
module.exports = { after, before }
2 changes: 1 addition & 1 deletion example-app/src/companies/company.admin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const AdminBro = require('admin-bro')
const AdminBro = require('@admin-bro/core')
const { Company } = require('./company.entity')

const {
Expand Down
2 changes: 1 addition & 1 deletion example-app/src/components/no-records.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { NoRecordsProps, Box } from 'admin-bro'
import { NoRecordsProps, Box } from '@admin-bro/design-system'

const NoRecords: React.FC<NoRecordsProps> = (props) => {
const { resource, OriginalComponent } = props
Expand Down
2 changes: 1 addition & 1 deletion example-app/src/employees/employee.admin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { Employee } = require('./employee.entity')

/** @type {import('admin-bro').ResourceOptions} */
/** @type {import('@admin-bro/core').ResourceOptions} */
const options = {

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { ExternalEmployees } = require('../../models/index')

/** @type {import('admin-bro').ResourceOptions} */
/** @type {import('@admin-bro/core').ResourceOptions} */
const options = {

}
Expand Down
2 changes: 1 addition & 1 deletion example-app/src/pages/page.admin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { Page } = require('./page.entity')

/** @type {import('admin-bro').ResourceOptions} */
/** @type {import('@admin-bro/core').ResourceOptions} */
const options = {
properties: {
content: {
Expand Down
2 changes: 1 addition & 1 deletion example-app/src/professions/profession.admin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { Profession } = require('./profession.entity')

/** @type {import('admin-bro').ResourceOptions} */
/** @type {import('@admin-bro/core').ResourceOptions} */
const options = {
properties: {
randomContent: {
Expand Down
4 changes: 2 additions & 2 deletions example-app/src/taggables/taggable.admin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { ValidationError } = require('admin-bro')
const { ValidationError } = require('@admin-bro/core')
const { Taggable } = require('../../models/index')

/** @type {import('admin-bro').ResourceOptions} */
/** @type {import('@admin-bro/core').ResourceOptions} */
const options = {
actions: {
show: {
Expand Down
2 changes: 1 addition & 1 deletion example-app/src/tools/tool.admin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { Tool } = require('./tool.entity')

/** @type {import('admin-bro').ResourceOptions} */
/** @type {import('@admin-bro/core').ResourceOptions} */
const options = {

}
Expand Down
2 changes: 1 addition & 1 deletion src/admin-bro-options.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Locale } from './locale/config'
* ### Usage with regular javascript
*
* ```javascript
* const AdminBro = require('admin-bro')
* const AdminBro = require('@admin-bro/core')
* //...
* const adminBro = new AdminBro({
* rootPath: '/xyz-admin',
Expand Down
10 changes: 5 additions & 5 deletions src/admin-bro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export type Adapter = { Database: typeof BaseDatabase; Resource: typeof BaseReso
* user. Its instance is a currier - injected in all other classes.
*
* @example
* const AdminBro = require('admin-bro')
* const AdminBro = require('@admin-bro/core')
* const admin = new AdminBro(AdminBroOptions)
*/
class AdminBro {
Expand All @@ -86,7 +86,7 @@ class AdminBro {
* It is used by external plugins.
*
* @example
* const { Router } = require('admin-bro')
* const { Router } = require('@admin-bro/core')
* Router.routes.forEach(route => {
* // map your framework routes to admin-bro routes
* // see how `admin-bro-expressjs` plugin does it.
Expand All @@ -99,7 +99,7 @@ class AdminBro {
* External adapters have to implement it.
*
* @example <caption>Creating Database Adapter for some ORM</caption>
* const { BaseDatabase } = require('admin-bro')
* const { BaseDatabase } = require('@admin-bro/core')
*
* class Database extends BaseDatabase {
* constructor(ormInstance) {
Expand Down Expand Up @@ -147,7 +147,7 @@ class AdminBro {
* _list_, _edit_, _show_, _delete_ and _bulkDelete_ you can do this here.
*
* @example <caption>Modifying accessibility rules for all show actions</caption>
* const { ACTIONS } = require('admin-bro')
* const { ACTIONS } = require('@admin-bro/core')
* ACTIONS.show.isAccessible = () => {...}
*/
public static ACTIONS: ActionsMap
Expand Down Expand Up @@ -220,7 +220,7 @@ class AdminBro {
* Registers various database adapters written for AdminBro.
*
* @example
* const AdminBro = require('admin-bro')
* const AdminBro = require('@admin-bro/core')
* const MongooseAdapter = require('admin-bro-mongoose')
* AdminBro.registerAdapter(MongooseAdapter)
*
Expand Down
4 changes: 2 additions & 2 deletions src/backend/actions/action.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ export type After<T> = (
* }]
* }
*
* const { ACTIONS } = require('admin-bro')
* const { ACTIONS } = require('@admin-bro/core')
* // example of adding after filter for 'show' action for all resources
* ACTIONS.show.after = async () => {...}
* ```
Expand Down Expand Up @@ -530,7 +530,7 @@ export default interface Action <T extends ActionResponse> {
* }
*
* // and attaching this function to actions for all resources
* const { ACTIONS } = require('admin-bro')
* const { ACTIONS } = require('@admin-bro/core')
*
* ACTIONS.edit.after = createLog
* ACTIONS.delete.after = createLog
Expand Down
2 changes: 1 addition & 1 deletion src/backend/decorators/resource-options.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export type HrefFunction = ((context: HrefContext) => string)
* ### Usage with TypeScript
*
* ```typescript
* import { ResourceOptions } from 'admin-bro'
* import { ResourceOptions } from '@admin-bro/core'
* ```
*/
export interface ResourceOptions {
Expand Down
2 changes: 1 addition & 1 deletion src/current-admin.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* ### Usage with TypeScript
*
* ```typescript
* import { CurrentAdmin } from 'admin-bro'
* import { CurrentAdmin } from '@admin-bro/core'
* ```
*
* @alias CurrentAdmin
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/components/app/base-action-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ declare const AdminBro: {
*
* ```
* // ./my-new-action.jsx
* import { Box } from 'admin-bro'
* import { Box } from '@admin-bro/core'
*
* const MyNewAction = (props) => {
* const { resource, action, record } = props
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/components/property-type/base-property-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type SelectRecord = {
* Example
* ```
* // AdminBroOptions
* const AdminBro = require('admin-bro')
* const AdminBro = require('@admin-bro/core')
* const ResourceModel = require('./resource-model')
* const AdminBroOptions = {
* resources: [{
Expand Down Expand Up @@ -143,7 +143,7 @@ export type ShowPropertyProps = {
* Lets take a look at an example of overriding edit component:
* ```typescript
* import React, { ReactNode } from 'react'
* import { BasePropertyProps, PropertyInEdit, StyledInput } from 'admin-bro'
* import { BasePropertyProps, PropertyInEdit, StyledInput } from '@admin-bro/core'
*
* export default class Edit extends React.Component<PropertyProps> {
* constructor(props) {
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/components/property-type/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const types: Record<PropertyType, any> = {
* Take a look at the following example:
*
* ```
* const AdminBro = require('admin-bro')
* const AdminBro = require('@admin-bro/core')
* const ResourceModel = require('./resource-model')
* const AdminBroOptions = {
* resources: [{
Expand All @@ -86,7 +86,7 @@ const types: Record<PropertyType, any> = {
*
* ```
* import React from 'react'
* import { InputGroup, Label } from 'admin-bro'
* import { InputGroup, Label } from '@admin-bro/core'
*
* const MyReactComponent = props => {
* const { record, property } = props
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/hooks/use-current-admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type UseCurrentAdminResponse = [
* Hook which allows you to get and set currentAdmin
*
* ```usage
* import { useCurrentAdmin } from 'admin-bro'
* import { useCurrentAdmin } from '@admin-bro/core'
*
* const myComponent = () => {
* const [currentAdmin, setCurrentAdmin] = useCurrentAdmin()
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/hooks/use-notice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type AddNotice = (notice: NoticeMessage) => any;
* Hook which allows you to add notice message to the app.
*
* ```usage
* import { useNotice, Button } from 'admin-bro'
* import { useNotice, Button } from '@admin-bro/core'
*
* const myComponent = () => {
* const sendNotice = useNotice()
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/hooks/use-record.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export type UseRecordResult = {
* Consecutive calls will update it.
*
* ```javascript
* import { BasePropertyComponent, useRecord, Box, useTranslation } from 'admin-bro'
* import { BasePropertyComponent, useRecord, Box, useTranslation } from '@admin-bro/design-system'
*
* const MyRecordActionComponent = (props) => {
* const { record: initialRecord, resource, action } = props
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/hooks/use-translation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { TranslateFunctions, createFunctions } from '../../utils/translate-funct
* defined below.
*
* ```javascript
* import { useTranslation } from 'admin-bro'
* import { useTranslation } from '@admin-bro/core'
*
* const MyComponent = () => {
* const { translateButton } = useTranslation()
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/store/with-notice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const mapDispatchToProps = (dispatch): AddNoticeProps => ({
* It gives you the additional prop: `addNotice(noticeMessage)` taking {@link NoticeMessage}.
*
* ```javascript
* import { withNotice } from 'admin-bro'
* import { withNotice } from 'admin-bro/core'
*
* const MY_MESSAGE = {
* message: 'I am toast message',
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/utils/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export type GetPageAPIParams = AxiosRequestConfig & {
*
* Usage:
* ```javascript
* import { ApiClient } from 'admin-bro'
* import { ApiClient } from '@admin-bro/core'
*
* const api = new ApiClient()
* // fetching all records
Expand Down

0 comments on commit 9527a4a

Please sign in to comment.