Skip to content

Commit

Permalink
Merge branch 'main' into T-4339
Browse files Browse the repository at this point in the history
  • Loading branch information
katherinehhh committed May 23, 2024
2 parents ba49093 + b052a82 commit e4e3246
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ https://github.com/nocobase/nocobase/assets/1267426/1d6a3979-d1eb-4e50-b726-2f90

## We'd love your support!

<a href="https://www.producthunt.com/products/nocobase" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=456520&theme=light" alt="NocoBase - Scalability&#0045;first&#0044;&#0032;open&#0045;source&#0032;no&#0045;code&#0032;platform | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
<a href="https://www.producthunt.com/posts/nocobase?utm_source=badge-top-post-badge&utm_medium=badge&utm_souce=badge-nocobase" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/top-post-badge.svg?post_id=456520&theme=light&period=daily" alt="NocoBase - Scalability&#0045;first&#0044;&#0032;open&#0045;source&#0032;no&#0045;code&#0032;platform | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>

## Recent major updates

Expand Down
4 changes: 2 additions & 2 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

https://github.com/nocobase/nocobase/assets/1267426/29623e45-9a48-4598-bb9e-9dd173ade553

## 5 月 20 号期待你的支持
## 感谢你的支持

<a href="https://www.producthunt.com/products/nocobase" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=456520&theme=light" alt="NocoBase - Scalability&#0045;first&#0044;&#0032;open&#0045;source&#0032;no&#0045;code&#0032;platform | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
<a href="https://www.producthunt.com/posts/nocobase?utm_source=badge-top-post-badge&utm_medium=badge&utm_souce=badge-nocobase" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/top-post-badge.svg?post_id=456520&theme=light&period=daily" alt="NocoBase - Scalability&#0045;first&#0044;&#0032;open&#0045;source&#0032;no&#0045;code&#0032;platform | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>

## 最近重要更新
- [v1.0:新的里程碑 - 2024/04/28](https://docs-cn.nocobase.com/welcome/release/v1001-changelog)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const SchemaSettingsDataScope: FC<DataScopeProps> = function DataScopeCon
{...props}
form={form}
record={record}
noDisabled={true}
shouldChange={getShouldChange({
collectionField: props.collectionField,
variables,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ type Props = {
* @returns
*/
returnScope?: (scope: Option[]) => any[];
/**
* 不需要禁用选项,一般会在表达式中使用
*/
noDisabled?: boolean;
};

/**
Expand All @@ -91,6 +95,7 @@ export const VariableInput = (props: Props) => {
record,
returnScope = _.identity,
targetFieldSchema,
noDisabled,
} = props;
const { name: blockCollectionName } = useBlockCollection();
const scope = useVariableScope();
Expand All @@ -103,6 +108,7 @@ export const VariableInput = (props: Props) => {
operator,
uiSchema,
targetFieldSchema,
noDisabled,
});
const contextVariable = useContextAssociationFields({ schema, maxDepth: 2, contextCollectionName, collectionField });
const { compatOldVariables } = useCompatOldVariables({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export const useDatetimeVariable = ({ operator, schema, noDisabled }: Props = {}
const { t } = useTranslation();
const datetimeSettings = useMemo(() => {
const operatorValue = operator?.value || '';
const disabled = noDisabled ? false : !['DatePicker', 'DatePicker.RangePicker'].includes(schema?.['x-component']);
const disabled = noDisabled ? false : !['DatePicker.RangePicker'].includes(schema?.['x-component']);
const dateOptions = [
{
key: 'now',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { Form } from '@formily/core';
import { ISchema, Schema } from '@formily/react';
import { useMemo } from 'react';
import { CollectionFieldOptions_deprecated } from '../../../collection-manager';
import { useBlockCollection } from './useBlockCollection';
import { useDatetimeVariable } from './useDateVariable';
import { useCurrentFormVariable } from './useFormVariable';
import { useCurrentObjectVariable } from './useIterationVariable';
Expand Down Expand Up @@ -56,7 +55,6 @@ export const useVariableOptions = ({
targetFieldSchema,
record,
}: Props) => {
const { name: blockCollectionName = record?.__collectionName } = useBlockCollection();
const blockParentCollectionName = record?.__parent?.__collectionName;
const { currentUserSettings } = useCurrentUserVariable({
maxDepth: 3,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* This file is part of the NocoBase (R) project.
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
* Authors: NocoBase Team.
*
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/

import { getNewSchema } from '../../initializer/CustomRequestInitializer';

describe('CustomRequestInitializer', () => {
it('should generate a new schema with different x-uid each time', () => {
const schema1 = getNewSchema();
const schema2 = getNewSchema();
expect(schema1['x-uid']).not.toBe(schema2['x-uid']);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
* For more information, please refer to: https://www.nocobase.com/agreement.
*/

import { uid } from '@formily/shared';
import { BlockInitializer, useSchemaInitializerItem } from '@nocobase/client';
import { merge, uid } from '@formily/shared';
import { SchemaInitializerItem, useSchemaInitializer, useSchemaInitializerItem } from '@nocobase/client';
import React from 'react';
import { useCustomRequestsResource } from '../hooks/useCustomRequestsResource';

export const CustomRequestInitializer: React.FC<any> = (props) => {
const customRequestsResource = useCustomRequestsResource();

const schema = {
export const getNewSchema = () => {
return {
title: '{{ t("Custom request") }}',
'x-component': 'CustomRequestAction',
'x-action': 'customize:form:request',
Expand All @@ -31,21 +29,28 @@ export const CustomRequestInitializer: React.FC<any> = (props) => {
},
},
};
};

export const CustomRequestInitializer: React.FC<any> = (props) => {
const customRequestsResource = useCustomRequestsResource();
const itemConfig = useSchemaInitializerItem();
const { insert } = useSchemaInitializer();

return (
<BlockInitializer
<SchemaInitializerItem
{...itemConfig}
item={itemConfig}
onClick={async (s) => {
onClick={async () => {
const schema = getNewSchema();
const s = merge(schema || {}, itemConfig.schema || {});
itemConfig?.schemaInitialize?.(s);
insert(s);
// create a custom request
await customRequestsResource.create({
values: {
key: s['x-uid'],
},
});
}}
schema={schema}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import { CompatibleSchemaInitializer, useCollection_deprecated } from '@nocobase/client';

const commonOptions = {
name: 'kanban:configureActions',
title: "{{t('Configure actions')}}",
icon: 'SettingOutlined',
style: {
Expand Down

0 comments on commit e4e3246

Please sign in to comment.