feat: Upgrade plugin version to 2.0.0 and refactor configuration handling
- Updated version numbers in package.json, package-lock.json, and manifest.json to 2.0.0. - Refactored configuration types to use data sources (SELF, APP) instead of type-based configurations. - Enhanced settings UI to allow selection between using the current record or another app's record. - Improved error handling and validation for configuration settings. - Added new input component for better handling of text inputs in settings. - Updated localization files for new settings structure and error messages. - Optimized API calls with memoization for fetching form field properties and checking configurations.
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
import { KintoneRestAPIClient } from '@kintone/rest-api-client';
|
||||
import moize from 'moize';
|
||||
import React from 'react';
|
||||
import { ErrorBoundary } from 'react-error-boundary';
|
||||
import { loadConfig, type PluginConfig } from '../common/config';
|
||||
import ErrorFallback from '../common/ErrorFallback';
|
||||
import Loading from '../common/Loading';
|
||||
import type { KintoneFormFieldProperties } from '../common/types';
|
||||
import { checkConfig } from './checkConfig';
|
||||
import MenuPanel from './MenuPanel';
|
||||
|
||||
interface DesktopAppProps {
|
||||
@@ -9,12 +14,34 @@ interface DesktopAppProps {
|
||||
event: kintone.events.AppRecordDetailShowEvent | kintone.events.MobileAppRecordDetailShowEvent;
|
||||
}
|
||||
|
||||
const cachedFormFieldsProperties = moize.promise(async (appId: number): Promise<KintoneFormFieldProperties> => {
|
||||
const client = new KintoneRestAPIClient();
|
||||
const { properties } = await client.app.getFormFields({ app: appId, preview: false });
|
||||
return properties;
|
||||
});
|
||||
|
||||
const cachedConfigCheck = moize.promise(
|
||||
async (config: PluginConfig, record: kintone.types.SavedFields): Promise<string> => {
|
||||
return await checkConfig(config, record);
|
||||
},
|
||||
);
|
||||
|
||||
const DesktopApp: React.FC<DesktopAppProps> = (props) => {
|
||||
const { pluginId, event } = props;
|
||||
|
||||
const config = loadConfig(pluginId);
|
||||
const propertiesPromise = cachedFormFieldsProperties(event.appId);
|
||||
const fileKeyPromise = cachedConfigCheck(config, event.record);
|
||||
|
||||
return (
|
||||
<ErrorBoundary FallbackComponent={ErrorFallback}>
|
||||
<React.Suspense fallback={<Loading />}>
|
||||
<MenuPanel pluginId={pluginId} event={event} />
|
||||
<MenuPanel
|
||||
pluginId={pluginId}
|
||||
event={event}
|
||||
propertiesPromise={propertiesPromise}
|
||||
fileKeyPromise={fileKeyPromise}
|
||||
/>
|
||||
</React.Suspense>
|
||||
</ErrorBoundary>
|
||||
);
|
||||
|
Reference in New Issue
Block a user