Skip to content

Commit

Permalink
feat(chrome-devtools): add customValueValidate (#3400)
Browse files Browse the repository at this point in the history
  • Loading branch information
KyrieLii authored Dec 25, 2024
1 parent 222aa5b commit 5b347f5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/neat-jars-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/devtools': patch
---

feat(chrome-devtools): add option customValueValidate for form component
2 changes: 2 additions & 0 deletions packages/chrome-devtools/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const App = (props: RootComponentProps) => {
getVersion,
handleSnapshot,
handleProxyAddress,
customValueValidate,
} = props;
const [module, setModule] = useState(window.__FEDERATION__?.moduleInfo || {});

Expand All @@ -37,6 +38,7 @@ const App = (props: RootComponentProps) => {
getVersion={getVersion}
handleSnapshot={handleSnapshot}
handleProxyAddress={handleProxyAddress}
customValueValidate={customValueValidate}
/>
) : (
<Empty description={'No ModuleInfo Detected'} />
Expand Down
8 changes: 7 additions & 1 deletion packages/chrome-devtools/src/component/Form/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const FormComponent = (props: FormProps & RootComponentProps) => {
versionList,
setVersionList,
getVersion,
customValueValidate,
} = props;
const { moduleInfo } = window.__FEDERATION__;
let { producer } = separateType(moduleInfo);
Expand Down Expand Up @@ -145,7 +146,12 @@ const FormComponent = (props: FormProps & RootComponentProps) => {
};
}

if (validateCustom(value) || validateSemver(value) || validatePort(value)) {
if (
validateCustom(value) ||
validateSemver(value) ||
validatePort(value) ||
customValueValidate?.(value)
) {
statusSet[index].valueStatus = true;
flushSync(() => setFormStatus(statusSet));
return callback();
Expand Down
2 changes: 2 additions & 0 deletions packages/chrome-devtools/src/component/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const Layout = (
setVersionList,
getVersion,
handleProxyAddress,
customValueValidate,
} = props;
const { producer } = separateType(moduleInfo);
const [condition, setCondition] = useState(statusInfo.processing);
Expand Down Expand Up @@ -209,6 +210,7 @@ const Layout = (
versionList={versionList}
setVersionList={setVersionList}
getVersion={getVersion}
customValueValidate={customValueValidate}
/>
</Form>

Expand Down
1 change: 1 addition & 0 deletions packages/chrome-devtools/src/utils/types/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export interface RootComponentProps {
setVersionList?: React.Dispatch<React.SetStateAction<Array<Array<string>>>>;
getVersion?: (moduleName: string) => Promise<Array<string>>;
handleProxyAddress?: (address: string) => string;
customValueValidate?: (schema: string) => boolean;
}

0 comments on commit 5b347f5

Please sign in to comment.