MCPcopy Index your code
hub / github.com/apache/devlake / operator

Function operator

config-ui/src/utils/operator.ts:38–57  ·  view source on GitHub ↗
(request: () => Promise<T>, config?: OperateConfig)

Source from the content-addressed store, hash-verified

36 * @returns
37 */
38export const operator = async <T>(request: () => Promise<T>, config?: OperateConfig): Promise<[boolean, any?]> => {
39 const { setOperating, formatMessage, formatReason } = config || {};
40
41 try {
42 setOperating?.(true);
43 const res = await request();
44 const content = formatMessage?.() ?? 'Operation successfully completed';
45 if (!config?.hideToast) {
46 message.success(content);
47 }
48 return [true, res];
49 } catch (err) {
50 console.error('Operation failed.', err);
51 const reason = formatReason?.(err) ?? (err as any).response?.data?.message ?? 'Operation failed.';
52 message.error(reason);
53 return [false, err];
54 } finally {
55 setOperating?.(false);
56 }
57};

Callers 15

handleDeleteFunction · 0.90
handleDeleteDataScopeFunction · 0.90
handleUpdateFunction · 0.90
handleDeleteFunction · 0.90
handleCreateFunction · 0.90
handleSelectFunction · 0.90
handleDeleteFunction · 0.90
handleCreateFunction · 0.90
handleSubmitFunction · 0.90
handleRunFunction · 0.90
handleRemoveConnectionFunction · 0.90

Calls 2

formatMessageFunction · 0.85
requestFunction · 0.70

Tested by

no test coverage detected