Skip to content

Commit 5b347f5

Browse files
authored
feat(chrome-devtools): add customValueValidate (#3400)
1 parent 222aa5b commit 5b347f5

File tree

5 files changed

+17
-1
lines changed

5 files changed

+17
-1
lines changed

.changeset/neat-jars-type.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/devtools': patch
3+
---
4+
5+
feat(chrome-devtools): add option customValueValidate for form component

packages/chrome-devtools/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const App = (props: RootComponentProps) => {
1717
getVersion,
1818
handleSnapshot,
1919
handleProxyAddress,
20+
customValueValidate,
2021
} = props;
2122
const [module, setModule] = useState(window.__FEDERATION__?.moduleInfo || {});
2223

@@ -37,6 +38,7 @@ const App = (props: RootComponentProps) => {
3738
getVersion={getVersion}
3839
handleSnapshot={handleSnapshot}
3940
handleProxyAddress={handleProxyAddress}
41+
customValueValidate={customValueValidate}
4042
/>
4143
) : (
4244
<Empty description={'No ModuleInfo Detected'} />

packages/chrome-devtools/src/component/Form/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const FormComponent = (props: FormProps & RootComponentProps) => {
5858
versionList,
5959
setVersionList,
6060
getVersion,
61+
customValueValidate,
6162
} = props;
6263
const { moduleInfo } = window.__FEDERATION__;
6364
let { producer } = separateType(moduleInfo);
@@ -145,7 +146,12 @@ const FormComponent = (props: FormProps & RootComponentProps) => {
145146
};
146147
}
147148

148-
if (validateCustom(value) || validateSemver(value) || validatePort(value)) {
149+
if (
150+
validateCustom(value) ||
151+
validateSemver(value) ||
152+
validatePort(value) ||
153+
customValueValidate?.(value)
154+
) {
149155
statusSet[index].valueStatus = true;
150156
flushSync(() => setFormStatus(statusSet));
151157
return callback();

packages/chrome-devtools/src/component/Layout/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const Layout = (
5050
setVersionList,
5151
getVersion,
5252
handleProxyAddress,
53+
customValueValidate,
5354
} = props;
5455
const { producer } = separateType(moduleInfo);
5556
const [condition, setCondition] = useState(statusInfo.processing);
@@ -209,6 +210,7 @@ const Layout = (
209210
versionList={versionList}
210211
setVersionList={setVersionList}
211212
getVersion={getVersion}
213+
customValueValidate={customValueValidate}
212214
/>
213215
</Form>
214216

packages/chrome-devtools/src/utils/types/common.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ export interface RootComponentProps {
1313
setVersionList?: React.Dispatch<React.SetStateAction<Array<Array<string>>>>;
1414
getVersion?: (moduleName: string) => Promise<Array<string>>;
1515
handleProxyAddress?: (address: string) => string;
16+
customValueValidate?: (schema: string) => boolean;
1617
}

0 commit comments

Comments
 (0)