diff --git a/web/specs/example.spec.ts b/web/specs/example.spec.ts
index 44a9645..b1ea448 100644
--- a/web/specs/example.spec.ts
+++ b/web/specs/example.spec.ts
@@ -29,6 +29,10 @@ test.describe.serial('item flows', () => {
await page.waitForTimeout(500);
+ const itemId = await page
+ .getByTestId('new-item-id-input')
+ .textContent();
+
const newItemIdInput = await page
.getByTestId('new-item-id-input')
.inputValue();
@@ -46,8 +50,11 @@ test.describe.serial('item flows', () => {
await page.getByRole('button', { name: 'Save' }).click();
+ // wait till navigated to /item/:itemId
+ await page.waitForURL(WEB_URL + '/item/' + itemId);
+
h1 = await page.locator('h1');
- await expect(h1).toHaveText(DEFAULT_ITEM_NAME);
+ await expect(h1).toHaveText(DEFAULT_ITEM_NAME, { timeout: 5000 });
});
test('search item', async () => {
diff --git a/web/src/api/item/index.ts b/web/src/api/item/index.ts
index ab22ddd..4ecab95 100644
--- a/web/src/api/item/index.ts
+++ b/web/src/api/item/index.ts
@@ -150,8 +150,18 @@ export const useDeleteItem = (
};
// Edit item
-export const useEditItem = () => {
+export const useEditItem = (
+ properties: UseMutationOptions<
+ boolean,
+ Error,
+ {
+ item_id: string;
+ data: paths['/item/{item_id}']['patch']['requestBody']['content']['application/json; charset=utf-8'];
+ }
+ >
+) => {
return useMutation({
+ ...properties,
mutationFn: async ({
item_id,
data,
diff --git a/web/src/components/settings/nav.tsx b/web/src/components/settings/nav.tsx
index 8682475..b7bbe78 100644
--- a/web/src/components/settings/nav.tsx
+++ b/web/src/components/settings/nav.tsx
@@ -33,12 +33,12 @@ export const SettingsNav = () => {
'Instance',
[
['/settings/search', 'Search', ],
+ ['/settings/storage', 'Storage', ],
[
'/settings/intelligence',
'Intelligence',
,
],
- ['/settings/storage', 'Storage', ],
],
],
[
diff --git a/web/src/routes/item/$itemId/edit.tsx b/web/src/routes/item/$itemId/edit.tsx
index e369696..602157b 100644
--- a/web/src/routes/item/$itemId/edit.tsx
+++ b/web/src/routes/item/$itemId/edit.tsx
@@ -20,6 +20,7 @@ import {
useDeleteItem,
useEditItem,
} from '@/api/item';
+import { DynamicIcon } from '@/components/DynamicIcon';
import { BaseInput } from '@/components/input/BaseInput';
import { ItemIntelligentSuggest } from '@/components/item/ItemIntelligentSuggest';
import { EditMediaGallery } from '@/components/media/EditMediaGallery';
@@ -35,7 +36,6 @@ import {
ItemUpdatePayload,
} from '@/util/item';
import { queryClient } from '@/util/query';
-import { DynamicIcon } from '@/components/DynamicIcon';
const EMPTY_VALUE = '$$EMPTY$$';
@@ -194,7 +194,14 @@ export const Route = createFileRoute('/item/$itemId/edit')({
const { itemId } = useParams({ from: '/item/$itemId/edit' });
const { data: item } = useSuspenseQuery(getItemById(itemId));
const { data: media } = useSuspenseQuery(getItemMedia(itemId));
- const { mutateAsync: editItem } = useEditItem();
+ const { mutateAsync: editItem } = useEditItem({
+ onSuccess: async (data, variables, context) => {
+ navigate({
+ to: '/item/$itemId',
+ params: { itemId },
+ });
+ },
+ });
const { data: itemFields } = useSuspenseQuery(getItemFields(itemId));
const { data: instanceSettings } = useSuspenseQuery(
getInstanceSettings()
@@ -267,14 +274,10 @@ export const Route = createFileRoute('/item/$itemId/edit')({
data: diff,
},
{
- onSuccess: async (data, variables, context) => {
+ onSuccess: () => {
toast.success('Item saved', {
id: toastId,
});
- navigate({
- to: '/item/$itemId',
- params: { itemId },
- });
},
onError(error, variables, context) {
toast.error('Failed to save item', {