@nocobase/client-v2 2.4.0-alpha.18 → 2.4.0-alpha.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/client-v2",
3
- "version": "2.4.0-alpha.18",
3
+ "version": "2.4.0-alpha.19",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.mjs",
@@ -27,11 +27,11 @@
27
27
  "@formily/antd-v5": "1.2.3",
28
28
  "@formily/react": "^2.2.27",
29
29
  "@formily/shared": "^2.2.27",
30
- "@nocobase/evaluators": "2.4.0-alpha.18",
31
- "@nocobase/flow-engine": "2.4.0-alpha.18",
32
- "@nocobase/sdk": "2.4.0-alpha.18",
33
- "@nocobase/shared": "2.4.0-alpha.18",
34
- "@nocobase/utils": "2.4.0-alpha.18",
30
+ "@nocobase/evaluators": "2.4.0-alpha.19",
31
+ "@nocobase/flow-engine": "2.4.0-alpha.19",
32
+ "@nocobase/sdk": "2.4.0-alpha.19",
33
+ "@nocobase/shared": "2.4.0-alpha.19",
34
+ "@nocobase/utils": "2.4.0-alpha.19",
35
35
  "ahooks": "^3.7.2",
36
36
  "antd": "5.24.2",
37
37
  "antd-style": "3.7.1",
@@ -49,5 +49,5 @@
49
49
  "react-router-dom": "^6.30.1",
50
50
  "zxing-wasm": "^3.1.3"
51
51
  },
52
- "gitHead": "ae799cda3345b2bcb9f47567303b2dccce91d90c"
52
+ "gitHead": "b958d8e10e75dd27b0e7a2882ffc8f9bda9da0d8"
53
53
  }
@@ -7,7 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- import { FlowModel, IFlowModelRepository } from '@nocobase/flow-engine';
10
+ import { type CreateModelOptions, type FlowEngine, FlowModel, IFlowModelRepository } from '@nocobase/flow-engine';
11
11
  import type { BaseApplication } from '../BaseApplication';
12
12
  import _ from 'lodash';
13
13
 
@@ -180,6 +180,21 @@ export class FlowModelRepository implements IFlowModelRepository<FlowModel> {
180
180
  return data ? _.cloneDeep(data) : data;
181
181
  }
182
182
 
183
+ async ensureRouteContent(options: CreateModelOptions) {
184
+ const existing = await this.findOne({ parentId: options.parentId, subKey: options.subKey });
185
+ if (existing) return existing;
186
+
187
+ const response = await this.app.apiClient.request({
188
+ method: 'POST',
189
+ url: 'flowModels:save',
190
+ params: { ensureRouteContent: true },
191
+ data: options,
192
+ });
193
+ const persisted = await this.findOne({ uid: response.data.data });
194
+ if (!persisted) throw new Error('Could not load the initialized route content');
195
+ return persisted;
196
+ }
197
+
183
198
  async save(model: FlowModel, options?: { onlyStepParams?: boolean }) {
184
199
  const data = model.serialize();
185
200
  if (options?.onlyStepParams) {
@@ -220,3 +235,34 @@ export class FlowModelRepository implements IFlowModelRepository<FlowModel> {
220
235
  return response.data?.data;
221
236
  }
222
237
  }
238
+
239
+ // A tab renderer can be mounted again when the UI Editor adds or removes its controls.
240
+ const confirmedRouteModels = new WeakSet<FlowModel>();
241
+
242
+ export function isRouteContentConfirmed(model: FlowModel) {
243
+ return confirmedRouteModels.has(model);
244
+ }
245
+
246
+ export async function loadRouteContentForEditing(engine: FlowEngine, options: CreateModelOptions) {
247
+ const repository = engine.modelRepository;
248
+ if (!(repository instanceof FlowModelRepository)) {
249
+ return engine.loadOrCreateModel(options);
250
+ }
251
+
252
+ // A route model can live in the outer engine while its page lives in this view's engine.
253
+ let cached = engine.findModelByParentId(options.parentId, options.subKey);
254
+ if (!cached) {
255
+ engine.forEachModel((model) => {
256
+ if (model.parentId === options.parentId && model.subKey === options.subKey) cached = model;
257
+ });
258
+ }
259
+ if (cached && isRouteContentConfirmed(cached)) return cached;
260
+ const data = await repository.ensureRouteContent({ ...options, uid: cached?.uid });
261
+ if (cached && cached.uid !== data.uid) engine.removeModelWithSubModels(cached.uid);
262
+ const model = await engine.createModelAsync(data);
263
+ if (model.parent && model.parent.subModels[options.subKey] !== model) {
264
+ model.parent.setSubModel(options.subKey, model);
265
+ }
266
+ confirmedRouteModels.add(model);
267
+ return model;
268
+ }
@@ -15,6 +15,10 @@ import {
15
15
  useFlowViewContext,
16
16
  } from '@nocobase/flow-engine';
17
17
  import type { FlowEngineContext, FlowModel, FlowModelRendererProps, ModelConstructor } from '@nocobase/flow-engine';
18
+ import { observer } from '@formily/reactive-react';
19
+ import { loadRouteContentForEditing } from './FlowModelRepository';
20
+ import { RouteContent, useRouteContentRequest } from './useRouteContentRequest';
21
+ import { RouteModel } from './models/base/RouteModel';
18
22
  import { useRequest } from 'ahooks';
19
23
  import React from 'react';
20
24
  import FlowRoute from './components/FlowRoute';
@@ -85,12 +89,13 @@ const bindViewLayoutState = (model: FlowModel, ctx?: FlowPageViewContext | null)
85
89
  });
86
90
  };
87
91
 
88
- export const FlowPage = React.memo((props: FlowPageProps & Record<string, unknown>) => {
92
+ export const FlowPage = observer((props: FlowPageProps & Record<string, unknown>) => {
89
93
  const { pageModelClass = 'ChildPageModel', parentId, onModelLoaded, defaultTabTitle, ...rest } = props;
90
94
  const flowEngine = useFlowEngine();
95
+ const isRoute = !!parentId && flowEngine.getModel(parentId, true) instanceof RouteModel;
91
96
  const ctx = useFlowViewContext<FlowPageViewContext>();
92
- const { loading, data, error } = useRequest(
93
- async () => {
97
+ const { model, loading, error, needsConfirmation } = useRouteContentRequest(
98
+ async (forEditing) => {
94
99
  const ModelClass = await flowEngine.getModelClassAsync(pageModelClass);
95
100
  if (!ModelClass) {
96
101
  throw new Error(`[NocoBase] Page model class '${pageModelClass}' is not registered.`);
@@ -101,7 +106,7 @@ export const FlowPage = React.memo((props: FlowPageProps & Record<string, unknow
101
106
  async: true,
102
107
  parentId,
103
108
  subKey: 'page',
104
- subType: 'object',
109
+ subType: 'object' as const,
105
110
  use: pageModelClass,
106
111
  };
107
112
  const isRuntimeRecordScopedPage =
@@ -136,7 +141,11 @@ export const FlowPage = React.memo((props: FlowPageProps & Record<string, unknow
136
141
  }
137
142
  const data =
138
143
  (isRuntimeRecordScopedPage && (await flowEngine.loadModel({ ...options, refresh: true }))) ||
139
- (await flowEngine.loadOrCreateModel(options, { skipSave: !flowEngine.context.flowSettingsEnabled }));
144
+ (forEditing
145
+ ? await loadRouteContentForEditing(flowEngine, options)
146
+ : await flowEngine.loadOrCreateModel(options, {
147
+ skipSave: isRoute || !flowEngine.context.flowSettingsEnabled,
148
+ }));
140
149
  if (data?.uid && onModelLoaded) {
141
150
  data.context.addDelegate(ctx);
142
151
  bindViewLayoutState(data, ctx);
@@ -145,17 +154,17 @@ export const FlowPage = React.memo((props: FlowPageProps & Record<string, unknow
145
154
  }
146
155
  return data;
147
156
  },
148
- {
149
- refreshDeps: [parentId, pageModelClass, defaultTabTitle],
150
- },
157
+ isRoute && flowEngine.context.flowSettingsEnabled,
158
+ [parentId, pageModelClass, defaultTabTitle],
151
159
  );
152
160
  if (error) {
153
161
  throw error;
154
162
  }
155
- if (loading || !data?.uid) {
163
+ if (!model?.uid || (loading && !isRoute)) {
156
164
  return <SkeletonFallback style={{ margin: ctx?.isMobileLayout ? 8 : ctx?.themeToken.marginBlock }} />;
157
165
  }
158
- return <InternalFlowPage uid={data.uid} {...rest} />;
166
+ const page = <InternalFlowPage uid={model.uid} {...rest} />;
167
+ return isRoute ? <RouteContent pending={needsConfirmation}>{page}</RouteContent> : page;
159
168
  });
160
169
 
161
170
  FlowPage.displayName = 'FlowPage';
@@ -8,9 +8,46 @@
8
8
  */
9
9
 
10
10
  import { describe, it, expect, vi } from 'vitest';
11
- import { FlowModelRepository } from '../FlowModelRepository';
11
+ import { FlowEngine, FlowModel } from '@nocobase/flow-engine';
12
+ import type { BaseApplication } from '../../BaseApplication';
13
+ import { FlowModelRepository, loadRouteContentForEditing } from '../FlowModelRepository';
12
14
 
13
15
  describe('FlowModelRepository', () => {
16
+ it('keeps the browse UID when the route parent is outside the current engine', async () => {
17
+ const engine = new FlowEngine();
18
+ engine.registerModels({ FlowModel });
19
+ const request = vi
20
+ .fn()
21
+ .mockResolvedValueOnce({ data: {} })
22
+ .mockResolvedValueOnce({ data: { data: 'browse-uid' } })
23
+ .mockResolvedValueOnce({
24
+ data: { data: { uid: 'browse-uid', use: 'FlowModel', parentId: 'route', subKey: 'page' } },
25
+ });
26
+ engine.setModelRepository(new FlowModelRepository({ apiClient: { request } } as unknown as BaseApplication));
27
+ const options = { use: 'FlowModel', parentId: 'route', subKey: 'page', subType: 'object' as const };
28
+ const browsing = engine.createModel({ ...options, uid: 'browse-uid' });
29
+ expect(await loadRouteContentForEditing(engine, options)).toBe(browsing);
30
+ expect(await loadRouteContentForEditing(engine, options)).toBe(browsing);
31
+ expect(request).toHaveBeenCalledTimes(3);
32
+ expect(request.mock.calls[1][0].data).toMatchObject({ ...options, uid: browsing.uid });
33
+ });
34
+
35
+ it('retries the first edit when the initialization request fails', async () => {
36
+ const engine = new FlowEngine();
37
+ engine.registerModels({ FlowModel });
38
+ const options = { use: 'FlowModel', parentId: 'route', subKey: 'page', subType: 'object' as const };
39
+ const model = engine.createModel({ ...options, uid: 'browse-uid' });
40
+ const request = vi
41
+ .fn()
42
+ .mockResolvedValueOnce({ data: {} })
43
+ .mockRejectedValueOnce(new Error('Save failed'))
44
+ .mockResolvedValueOnce({ data: { data: { ...options, uid: model.uid } } });
45
+ engine.setModelRepository(new FlowModelRepository({ apiClient: { request } } as unknown as BaseApplication));
46
+ await expect(loadRouteContentForEditing(engine, options)).rejects.toThrow('Save failed');
47
+ expect(await loadRouteContentForEditing(engine, options)).toBe(model);
48
+ expect(request).toHaveBeenCalledTimes(3);
49
+ });
50
+
14
51
  it('dedupes concurrent findOne requests with same key', async () => {
15
52
  const request = vi.fn(async () => {
16
53
  await new Promise((resolve) => setTimeout(resolve, 10));
@@ -7,10 +7,18 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- import { render, waitFor } from '@testing-library/react';
10
+ import { observable } from '@formily/reactive';
11
+ import { act, fireEvent, render, waitFor } from '@testing-library/react';
11
12
  import React from 'react';
12
13
  import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
13
14
  import { FlowPage } from '../FlowPage';
15
+ import { RouteModel } from '../models/base/RouteModel';
16
+ import { loadRouteContentForEditing } from '../FlowModelRepository';
17
+
18
+ vi.mock('../FlowModelRepository', () => ({
19
+ loadRouteContentForEditing: vi.fn(),
20
+ isRouteContentConfirmed: () => false,
21
+ }));
14
22
 
15
23
  type TestContextProperty = {
16
24
  value?: unknown;
@@ -71,7 +79,6 @@ const createPageModel = (): TestPageModel => {
71
79
  };
72
80
 
73
81
  const mocks = vi.hoisted(() => ({
74
- flowSettingsEnabled: false,
75
82
  loadModel: vi.fn(),
76
83
  loadOrCreateModel: vi.fn(),
77
84
  rendererMobileStates: [] as boolean[],
@@ -83,6 +90,8 @@ const mocks = vi.hoisted(() => ({
83
90
  contextMobileLayout: undefined as boolean | undefined,
84
91
  }));
85
92
 
93
+ const editor = observable({ enabled: false });
94
+
86
95
  vi.mock('@nocobase/flow-engine', async () => {
87
96
  const actual = await vi.importActual<typeof import('@nocobase/flow-engine')>('@nocobase/flow-engine');
88
97
  const ReactModule = await import('react');
@@ -95,14 +104,17 @@ vi.mock('@nocobase/flow-engine', async () => {
95
104
  if (typeof props.model?.context.isMobileLayout === 'boolean') {
96
105
  mocks.rendererMobileStates.push(props.model.context.isMobileLayout);
97
106
  }
98
- return ReactModule.createElement('div', { 'data-testid': 'flow-model-renderer' });
107
+ return ReactModule.createElement('input', { 'data-testid': 'flow-model-renderer' });
99
108
  }),
100
109
  useFlowEngine: vi.fn(() => ({
110
+ getModel: () => Object.create(RouteModel.prototype),
101
111
  getModelClassAsync: vi.fn(async () => TestPageModelClass),
102
112
  loadModel: mocks.loadModel,
103
113
  loadOrCreateModel: mocks.loadOrCreateModel,
104
114
  context: {
105
- flowSettingsEnabled: mocks.flowSettingsEnabled,
115
+ get flowSettingsEnabled() {
116
+ return editor.enabled;
117
+ },
106
118
  },
107
119
  translate: vi.fn((value: string) => value),
108
120
  })),
@@ -123,46 +135,6 @@ vi.mock('@nocobase/flow-engine', async () => {
123
135
  };
124
136
  });
125
137
 
126
- vi.mock('ahooks', async () => {
127
- const actual = await vi.importActual<typeof import('ahooks')>('ahooks');
128
- const ReactModule = await import('react');
129
- return {
130
- ...actual,
131
- useRequest: vi.fn((service: () => Promise<unknown>) => {
132
- const serviceRef = ReactModule.useRef(service);
133
- const [state, setState] = ReactModule.useState<{
134
- loading: boolean;
135
- data?: unknown;
136
- error?: unknown;
137
- }>({
138
- loading: true,
139
- });
140
-
141
- ReactModule.useEffect(() => {
142
- let active = true;
143
- serviceRef
144
- .current()
145
- .then((data) => {
146
- if (active) {
147
- setState({ loading: false, data, error: null });
148
- }
149
- })
150
- .catch((error) => {
151
- if (active) {
152
- setState({ loading: false, data: undefined, error });
153
- }
154
- });
155
-
156
- return () => {
157
- active = false;
158
- };
159
- }, []);
160
-
161
- return state;
162
- }),
163
- };
164
- });
165
-
166
138
  describe('FlowPage', () => {
167
139
  beforeEach(() => {
168
140
  mocks.loadModel.mockImplementation(async () => null);
@@ -170,7 +142,10 @@ describe('FlowPage', () => {
170
142
  });
171
143
 
172
144
  afterEach(() => {
173
- mocks.flowSettingsEnabled = false;
145
+ act(() => {
146
+ editor.enabled = false;
147
+ });
148
+ vi.mocked(loadRouteContentForEditing).mockReset();
174
149
  mocks.loadModel.mockReset();
175
150
  mocks.loadOrCreateModel.mockReset();
176
151
  mocks.rendererMobileStates = [];
@@ -182,6 +157,63 @@ describe('FlowPage', () => {
182
157
  mocks.contextMobileLayout = undefined;
183
158
  });
184
159
 
160
+ it('keeps the mounted route page and confirms storage only on the first edit', async () => {
161
+ mocks.model = createPageModel();
162
+ const { queryByTestId } = render(<FlowPage parentId="route" />);
163
+ await waitFor(() => expect(queryByTestId('flow-model-renderer')).toBeTruthy());
164
+ expect(mocks.loadOrCreateModel).toHaveBeenCalledWith(expect.objectContaining({ parentId: 'route' }), {
165
+ skipSave: true,
166
+ });
167
+ expect(loadRouteContentForEditing).not.toHaveBeenCalled();
168
+
169
+ const input = queryByTestId('flow-model-renderer') as HTMLInputElement;
170
+ fireEvent.change(input, { target: { value: 'draft' } });
171
+ let finish: () => void;
172
+ vi.mocked(loadRouteContentForEditing).mockImplementationOnce(
173
+ () =>
174
+ new Promise((resolve) => {
175
+ finish = () => resolve(mocks.model as unknown as Awaited<ReturnType<typeof loadRouteContentForEditing>>);
176
+ }),
177
+ );
178
+ act(() => {
179
+ editor.enabled = true;
180
+ });
181
+ await waitFor(() => expect(loadRouteContentForEditing).toHaveBeenCalledOnce());
182
+ expect(input.closest('[inert]')).toBeTruthy();
183
+ expect(queryByTestId('flow-model-renderer')).toBe(input);
184
+ await act(async () => finish());
185
+ await waitFor(() => expect(input.closest('[inert]')).toBeNull());
186
+ act(() => {
187
+ editor.enabled = false;
188
+ });
189
+ act(() => {
190
+ editor.enabled = true;
191
+ });
192
+ expect(queryByTestId('flow-model-renderer')).toBe(input);
193
+ expect(input.value).toBe('draft');
194
+ expect(loadRouteContentForEditing).toHaveBeenCalledOnce();
195
+ expect(mocks.loadOrCreateModel).toHaveBeenCalledOnce();
196
+ });
197
+
198
+ it('opens directly in the editor and keeps the confirmed page on subsequent toggles', async () => {
199
+ editor.enabled = true;
200
+ mocks.model = createPageModel();
201
+ vi.mocked(loadRouteContentForEditing).mockResolvedValue(
202
+ mocks.model as unknown as Awaited<ReturnType<typeof loadRouteContentForEditing>>,
203
+ );
204
+ const { findByTestId, getByTestId } = render(<FlowPage parentId="route" />);
205
+ const input = await findByTestId('flow-model-renderer');
206
+ act(() => {
207
+ editor.enabled = false;
208
+ });
209
+ act(() => {
210
+ editor.enabled = true;
211
+ });
212
+ expect(getByTestId('flow-model-renderer')).toBe(input);
213
+ expect(loadRouteContentForEditing).toHaveBeenCalledOnce();
214
+ expect(mocks.loadOrCreateModel).not.toHaveBeenCalled();
215
+ });
216
+
185
217
  it('uses showFlowSettings from page model props', async () => {
186
218
  mocks.model = createPageModel();
187
219
  render(<FlowPage />);
@@ -239,7 +271,7 @@ describe('FlowPage', () => {
239
271
  });
240
272
 
241
273
  it('keeps configured page model cache behavior in flow settings mode', async () => {
242
- mocks.flowSettingsEnabled = true;
274
+ editor.enabled = true;
243
275
  mocks.model = createPageModel();
244
276
  mocks.viewFilterByTk = 1;
245
277
 
@@ -81,6 +81,8 @@ const popoverStyle = css`
81
81
  }
82
82
  `;
83
83
 
84
+ const siderToggleZIndex = 200;
85
+
84
86
  const CollapsedButton: FC<{ collapsed: boolean }> = (props) => {
85
87
  const { token } = antdTheme.useToken();
86
88
  const customToken = token as CustomToken;
@@ -107,7 +109,7 @@ const CollapsedButton: FC<{ collapsed: boolean }> = (props) => {
107
109
  .ant-pro-sider-collapsed-button {
108
110
  top: 64px;
109
111
  left: ${props.collapsed ? 52 : (customToken.siderWidth || 200) - 12}px;
110
- z-index: 200;
112
+ z-index: ${siderToggleZIndex};
111
113
  transition: left 0.2s;
112
114
  }
113
115
  `}
@@ -606,6 +608,11 @@ export const AdminLayoutComponent = observer((props: any) => {
606
608
  z-index: 101 !important;
607
609
  }
608
610
 
611
+ /* The switcher popup is mounted inside the header, while the sider toggle is portaled outside it. */
612
+ .ant-layout-header.ant-pro-layout-header:has(.ant-pro-layout-apps-icon-active) {
613
+ z-index: ${siderToggleZIndex + 1} !important;
614
+ }
615
+
609
616
  .ant-pro-layout-apps-popover {
610
617
  z-index: 2000 !important;
611
618
  }
@@ -10,6 +10,7 @@
10
10
  import { tExpr, MultiRecordResource } from '@nocobase/flow-engine';
11
11
  import { ButtonProps } from 'antd';
12
12
  import { ActionModel, ActionSceneEnum } from '../base';
13
+ import { getHasManyDeleteFilterByTk } from './getHasManyDeleteFilterByTk';
13
14
 
14
15
  export class BulkDeleteActionModel extends ActionModel {
15
16
  static scene = ActionSceneEnum.collection;
@@ -49,11 +50,21 @@ BulkDeleteActionModel.registerFlow({
49
50
  return;
50
51
  }
51
52
  const resource = ctx.blockModel.resource as MultiRecordResource;
52
- if (resource.getSelectedRows().length === 0) {
53
+ const selectedRows = resource.getSelectedRows();
54
+ if (selectedRows.length === 0) {
53
55
  ctx.message.warning(ctx.t('Please select at least one record to delete'));
54
56
  return;
55
57
  }
56
- await resource.destroy(ctx.blockModel.collection.getFilterByTK(resource.getSelectedRows()));
58
+ const association = ctx.blockModel.association;
59
+ const filterByTk =
60
+ association?.type === 'hasMany'
61
+ ? getHasManyDeleteFilterByTk(association.targetKey, selectedRows)
62
+ : ctx.blockModel.collection.getFilterByTK(selectedRows);
63
+ if (association?.type === 'hasMany' && filterByTk === undefined) {
64
+ ctx.message.error(ctx.t('The association target key is missing or invalid.'));
65
+ return;
66
+ }
67
+ await resource.destroy(filterByTk);
57
68
  ctx.message.success(ctx.t('Selected records deleted successfully'));
58
69
  },
59
70
  },
@@ -7,9 +7,10 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- import { tExpr } from '@nocobase/flow-engine';
10
+ import { tExpr, SingleRecordResource } from '@nocobase/flow-engine';
11
11
  import type { ButtonProps } from 'antd/es/button';
12
12
  import { ActionModel, ActionSceneEnum } from '../base';
13
+ import { getHasManyDeleteFilterByTk } from './getHasManyDeleteFilterByTk';
13
14
 
14
15
  export class DeleteActionModel extends ActionModel {
15
16
  static scene = ActionSceneEnum.record;
@@ -53,7 +54,20 @@ DeleteActionModel.registerFlow({
53
54
  ctx.message.error(ctx.t('No resource or record selected for deletion'));
54
55
  return;
55
56
  }
56
- await ctx.resource.destroy(ctx.blockModel.collection.getFilterByTK(ctx.record));
57
+ const association = ctx.blockModel.association;
58
+ const filterByTk =
59
+ association?.type === 'hasMany'
60
+ ? getHasManyDeleteFilterByTk(association.targetKey, ctx.record)
61
+ : ctx.blockModel.collection.getFilterByTK(ctx.record);
62
+ if (association?.type === 'hasMany' && filterByTk === undefined) {
63
+ ctx.message.error(ctx.t('The association target key is missing or invalid.'));
64
+ return;
65
+ }
66
+ if (association?.type === 'hasMany' && ctx.resource instanceof SingleRecordResource) {
67
+ await ctx.resource.destroy({ params: { filterByTk } });
68
+ } else {
69
+ await ctx.resource.destroy(filterByTk);
70
+ }
57
71
  ctx.message.success(ctx.t('Record deleted successfully'));
58
72
  },
59
73
  },