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

Add Guessers based on the OpenAPI Schema #80

Merged
merged 31 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6a5d5a2
Add dataProvider.getSchema to read the database schema
fzaninotto Nov 5, 2024
5f40365
Add CRUD guessers
fzaninotto Nov 5, 2024
bc7670d
Change imports from to react-admin
fzaninotto Nov 5, 2024
711ed56
Update yarn.lock
fzaninotto Nov 5, 2024
27fe5a8
Add documentation for guessers
fzaninotto Nov 5, 2024
765855c
Add AdminGuesser
fzaninotto Nov 5, 2024
d9ab7e7
Replace demo by AdminGuesser
fzaninotto Nov 5, 2024
1c24516
Include custom pages in AdminGuesser
fzaninotto Nov 5, 2024
3f15e5a
Simplify setup even further
fzaninotto Nov 5, 2024
e453a54
Even simpler guesser
fzaninotto Nov 5, 2024
f72c973
Update AdminGuesser syntax
fzaninotto Nov 5, 2024
e430340
Simplify even further
fzaninotto Nov 6, 2024
a133501
Fix double log of AdminGuesser
fzaninotto Nov 6, 2024
09c8132
Improve onboarding
fzaninotto Nov 6, 2024
a049f85
Fix blinking not found page
fzaninotto Nov 6, 2024
43df047
Improve date detection
fzaninotto Nov 6, 2024
9d0794d
Add unit test for useCrudGuesser
fzaninotto Nov 6, 2024
783b751
Fix e2e tests
fzaninotto Nov 6, 2024
a59fcce
Add AdminGuesser e2e test
fzaninotto Nov 6, 2024
7c77fcd
Remove useless dependencies
fzaninotto Nov 6, 2024
9a15381
Add screenshot
fzaninotto Nov 6, 2024
eaf7117
Add filter guessers
fzaninotto Nov 7, 2024
3418996
Update packages/ra-supabase-core/src/useAPISchema.ts
fzaninotto Nov 7, 2024
d2a75ce
Move devdep to dep
fzaninotto Nov 7, 2024
0119eb3
Fix bad move
fzaninotto Nov 7, 2024
4f0a12e
Fix ts compilation on older TS version
fzaninotto Nov 7, 2024
b382cbd
slight refactor
fzaninotto Nov 7, 2024
0d8775a
Remove required fields in ShowGuesser
fzaninotto Nov 7, 2024
f507185
Add support for full-text search
fzaninotto Nov 7, 2024
9a74c92
Review
fzaninotto Nov 7, 2024
9fc8c78
Add partial match in full-text filter
fzaninotto Nov 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions cypress/e2e/adminGuesser.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { login } from './login';

const getPaginationText = () =>
cy.findByText(/\d+-\d+ of \d+/, { timeout: 10000 });

describe('AdminGuesser', () => {
it('should render one menu item per resource', () => {
cy.visit('/');
login();
cy.findByText('Companies').should('exist');
cy.findByText('Contacts').should('exist');
cy.findByText('Deals').should('exist');
cy.findByText('Tags').should('exist');
cy.findByText('Tasks').should('exist');
cy.findByText('Dealnotes').should('exist');
cy.findByText('Contactnotes').should('exist');
cy.findByText('Sales').should('exist');
});
});
17 changes: 0 additions & 17 deletions cypress/e2e/dashboard.cy.ts

This file was deleted.

71 changes: 4 additions & 67 deletions cypress/e2e/lists.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,57 +11,6 @@ describe('Lists', () => {
getPaginationText();
});

it('should allow to filter by date', () => {
cy.visit('/');
login();
cy.findByText('Contacts').click();
getPaginationText().then(el => {
const count = parseInt(el.text().split('of')[1].trim());

cy.findByText('Earlier').click();
// Use should here to allow built-in retry as it may take a few ms for the list to update
getPaginationText().should(el => {
const countFiltered = parseInt(el.text().split('of')[1].trim());
expect(countFiltered).to.be.lessThan(count);
});
});
});

it('should allow to filter by status', () => {
cy.visit('/');
login();
cy.findByText('Contacts').click();
getPaginationText().then(el => {
const count = parseInt(el.text().split('of')[1].trim());

cy.findByText('Cold').click();
// Use should here to allow built-in retry as it may take a few ms for the list to update
getPaginationText().should(el => {
const countFiltered = parseInt(el.text().split('of')[1].trim());
expect(countFiltered).to.be.lessThan(count);
});
});
});

it('should allow to filter by tag', () => {
cy.visit('/');
login();
cy.findByText('Contacts').click();
getPaginationText().then(el => {
const count = parseInt(el.text().split('of')[1].trim());

cy.findByText('football-fan', {
selector: '[role=button] *',
}).click();

// Use should here to allow built-in retry as it may take a few ms for the list to update
getPaginationText().should(el => {
const countFiltered = parseInt(el.text().split('of')[1].trim());
expect(countFiltered).to.be.lessThan(count);
});
});
});

it('should allow to move through pages', () => {
cy.visit('/');
login();
Expand Down Expand Up @@ -92,23 +41,11 @@ describe('Lists', () => {
cy.visit('/');
login();
cy.findByText('Contacts').click();
cy.findAllByText(/\d+ days? ago/, { timeout: 10000 }).should(
'have.length.greaterThan',
0
);
cy.findAllByText(/\d+ years? ago/, { timeout: 10000 }).should(
'have.length',
0
);
cy.findByText('Sort by Last seen descending').click();
cy.findByText('Last seen ascending').click();
cy.findAllByText(/\d+ days? ago/, { timeout: 10000 }).should(
cy.findByLabelText('Sort by Gender descending').click();
cy.findAllByText('female', { timeout: 10000 }).should(
'have.length',
0
);
cy.findAllByText(/\d+ years? ago/, { timeout: 10000 }).should(
'have.length.greaterThan',
0
10
);
cy.findByText('male').should('not.exist');
});
});
2 changes: 1 addition & 1 deletion packages/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<meta name="theme-color" content="#000000" />
<link rel="manifest" href="./manifest.json" />
<link rel="shortcut icon" href="./favicon.ico" />
<title>Atomic CRM</title>
<title>CRM Demo</title>
<style>
body {
margin: 0;
Expand Down
20 changes: 0 additions & 20 deletions packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,18 @@
"version": "3.2.1",
"private": true,
"dependencies": {
"@hello-pangea/dnd": "^16.3.0",
"@mui/icons-material": "^5.0.1",
"@mui/material": "^5.15.20",
"@nivo/bar": "^0.80.0",
"@nivo/core": "^0.80.0",
"@tanstack/react-query": "^5.45.1",
"@vitejs/plugin-react": "^2.2.0",
"clsx": "^1.1.1",
"date-fns": "^2.19.0",
"faker": "~5.4.0",
"lodash": "~4.17.5",
"prop-types": "^15.7.2",
"ra-data-fakerest": "^5.0.0",
"ra-supabase": "^3.2.1",
"react": "^18.2.0",
"react-admin": "^5.0.0",
"react-beautiful-dnd": "^13.0.0",
"react-dom": "^18.2.0",
"react-error-boundary": "^3.1.4",
"react-router": "^6.23.1",
"react-router-dom": "^6.23.1",
"vite": "^3.2.0"
},
"devDependencies": {
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^15.0.7",
"@testing-library/user-event": "^14.4.3",
"@types/faker": "~5.1.7",
"@types/jest": "^26.0.19",
"@types/lodash": "~4.14.168",
"@types/react": "^18.0.0",
"@types/react-beautiful-dnd": "^13.0.0",
"@types/react-dom": "^18.0.0",
"source-map-explorer": "^2.0.0",
"tsx": "^3.12.2",
Expand Down
78 changes: 5 additions & 73 deletions packages/demo/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,78 +1,10 @@
import * as React from 'react';
import {
Admin,
Resource,
ListGuesser,
defaultTheme,
mergeTranslations,
CustomRoutes,
} from 'react-admin';
import polyglotI18nProvider from 'ra-i18n-polyglot';
import englishMessages from 'ra-language-english';
import { BrowserRouter, Route } from 'react-router-dom';
import {
LoginPage,
raSupabaseEnglishMessages,
SetPasswordPage,
ForgotPasswordPage,
} from 'ra-supabase';
import { QueryClient } from '@tanstack/react-query';
import { authProvider } from './authProvider';
import Layout from './Layout';
import contacts from './contacts';
import companies from './companies';
import deals from './deals';
import { Dashboard } from './dashboard/Dashboard';
import { dataProvider } from './dataProvider';

const queryClient = new QueryClient();
const i18nProvider = polyglotI18nProvider(() => {
return mergeTranslations(englishMessages, raSupabaseEnglishMessages);
}, 'en');
import { AdminGuesser } from 'ra-supabase';

const App = () => (
<BrowserRouter>
<Admin
dataProvider={dataProvider}
authProvider={authProvider}
i18nProvider={i18nProvider}
layout={Layout}
dashboard={Dashboard}
loginPage={LoginPage}
queryClient={queryClient}
theme={{
...defaultTheme,
palette: {
background: {
default: '#fafafb',
},
},
}}
>
<CustomRoutes noLayout>
<Route
path={SetPasswordPage.path}
element={<SetPasswordPage />}
/>
<Route
path={ForgotPasswordPage.path}
element={<ForgotPasswordPage />}
/>
</CustomRoutes>
<Resource name="deals" {...deals} />
<Resource name="contacts" {...contacts} />
<Resource name="companies" {...companies} />
<Resource name="tasks" list={ListGuesser} />
<Resource
name="sales"
list={ListGuesser}
recordRepresentation={(record: any) =>
`${record.first_name} ${record.last_name}`
}
/>
<Resource name="tags" list={ListGuesser} />
</Admin>
</BrowserRouter>
<AdminGuesser
instanceUrl={import.meta.env.VITE_SUPABASE_URL}
apiKey={import.meta.env.VITE_SUPABASE_ANON_KEY}
/>
);

export default App;
82 changes: 0 additions & 82 deletions packages/demo/src/Header.tsx

This file was deleted.

29 changes: 0 additions & 29 deletions packages/demo/src/Layout.tsx

This file was deleted.

20 changes: 0 additions & 20 deletions packages/demo/src/authProvider.ts

This file was deleted.

Loading
Loading