[UI] API Context (#8851)

* Create ApiContext provider

* Utilize new context

* Remove api from global context

* Refactor <InvenTreeTable>

- No longer need hard-coded API constant

* Refactor useInstance hook

* Refactoring

- QueryCountDatshboardWidget
- NotesEditor
- RenderInstance

* Refactor multiple tables

* Fix typos

* Refactor useFilters hook

- Allow plugins to use this hook!

* Further refactoring

* Refactor API forms

* Cleanup context routing

* Fix provision order
This commit is contained in:
Oliver
2025-01-08 07:34:06 +11:00
committed by GitHub
parent 3a62bdd276
commit 296c54a1d7
33 changed files with 127 additions and 66 deletions
@@ -7,7 +7,7 @@ import 'easymde/dist/easymde.min.css';
import { useCallback, useEffect, useMemo, useState } from 'react';
import SimpleMDE from 'react-simplemde-editor';
import { api } from '../../App';
import { useApi } from '../../contexts/ApiContext';
import { ApiEndpoints } from '../../enums/ApiEndpoints';
import type { ModelType } from '../../enums/ModelType';
import { apiUrl } from '../../states/ApiState';
@@ -31,6 +31,7 @@ export default function NotesEditor({
modelId: number;
editable?: boolean;
}>) {
const api = useApi();
// In addition to the editable prop, we also need to check if the user has "enabled" editing
const [editing, setEditing] = useState<boolean>(false);