Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codesandbox template for reporting bug #5

Open
kopax opened this issue Mar 18, 2019 · 0 comments
Open

Codesandbox template for reporting bug #5

kopax opened this issue Mar 18, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@kopax
Copy link
Contributor

kopax commented Mar 18, 2019

Problem to solve

In order to improve the debugging and issues experience, it would be efficient to have the equivalent of the test application of ra-ui, available in a codesandbox.io

Target audience

Developers that use @bootstrap-styled/ra-ui

Further details

Goals:

  • Show error/warning and test bug between versions using live editor.

Proposal

By creating a boilerplate link that people can fork on codesandbox. It will be exactly as the demo of this project, a create-react-app application that use a fake data provider to serve the data.

What does success look like, and how can we measure that?

People should be able to purpose a source such as this without writting a lot of boilerplate code:

import React from 'react';
import {
  ShowButton,
  EditButton,
  DeleteButton,
  List,
  Datagrid,
  Filter,
  TextField,
  DateField,
  BooleanField,
  TextInput,
  DisabledInput,
  BooleanInput,
  Edit,
  Show,
  Create,
  ReferenceInput,
  SelectInput,
  SimpleForm,
  SimpleShowLayout,
  ReferenceField,
  ReferenceArrayField,
  SingleFieldList,
  ChipField,
} from '@bootstrap-styled/ra-ui';

export const ProjectCreate = (props) => (
  <Create {...props}>
    <SimpleForm>
      <TextInput source="name" />
      <ReferenceInput source="visibility.id" reference="projectVisibilities" allowEmpty>
        <SelectInput optionText="visibility" />
      </ReferenceInput>
      <ReferenceInput source="companyId" reference="companies" allowEmpty>
        <SelectInput optionText="name" />
      </ReferenceInput>
    </SimpleForm>
  </Create>
);


export const ProjectFilter = (props) => (
  <Filter {...props}>
    <TextInput source="id" />
    <TextInput source="name" />
  </Filter>
);

export const ProjectList = (props) => (
  <List
    {...props}
    sort={{ field: 'id', order: 'DESC' }}
    filters={<ProjectFilter />}
  >
    <Datagrid striped hover>
      <TextField source="name" />
      {/*<ReferenceField source="companyId" reference="companies" allowEmpty>*/}
        {/*<TextField source="name" />*/}
      {/*</ReferenceField>*/}
      <ShowButton size="sm" />
    </Datagrid>
  </List>
);

export const ProjectTitle = ({ record }) => {
  return <span>{record ? `#${record.id} ${record.name}` : ''}</span>;
};

export const ProjectEdit = (props) => {
  return (
    <Edit title={<ProjectTitle />} {...props}>
      <SimpleForm>
        <DisabledInput source="id" />
        <TextInput source="name" />
        <ReferenceInput source="visibility.visibilityId" reference="projectVisibilities" allowEmpty>
          <SelectInput optionText="visibility" />
        </ReferenceInput>
        <ReferenceInput source="companyId" reference="companies" allowEmpty>
          <SelectInput optionText="name" />
        </ReferenceInput>
      </SimpleForm>
    </Edit>
  );
};


export const ProjectShow = (props) => (
  <Show {...props}>
    <SimpleShowLayout>
      <TextField source="id" />
      <TextField source="name" />
      <TextField source="visibility.visibilityId" />
      <ReferenceArrayField
        source="projectServiceIdList"
        reference="projectServices"
      >
        <SingleFieldList>
          <ChipField source="name" />
        </SingleFieldList>
      </ReferenceArrayField>
    </SimpleShowLayout>
  </Show>
);

Links / references

@kopax kopax added the enhancement New feature or request label Mar 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant