Skip to content

Commit

Permalink
Only show specific integration inputs when adding integration to a po…
Browse files Browse the repository at this point in the history
…licy
  • Loading branch information
jen-huang committed Jun 8, 2021
1 parent 019ab33 commit b5ba9a4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ export const CreatePackagePolicyPage: React.FunctionComponent = () => {
{!ExtensionView && (
<StepConfigurePackagePolicy
packageInfo={packageInfo}
showOnlyIntegration={integrationInfo?.name}
packagePolicy={packagePolicy}
updatePackagePolicy={updatePackagePolicy}
validationResults={validationResults!}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,38 @@ import { PackagePolicyInputPanel } from './components';

export const StepConfigurePackagePolicy: React.FunctionComponent<{
packageInfo: PackageInfo;
showOnlyIntegration?: string;
packagePolicy: NewPackagePolicy;
updatePackagePolicy: (fields: Partial<NewPackagePolicy>) => void;
validationResults: PackagePolicyValidationResults;
submitAttempted: boolean;
}> = ({ packageInfo, packagePolicy, updatePackagePolicy, validationResults, submitAttempted }) => {
}> = ({
packageInfo,
showOnlyIntegration,
packagePolicy,
updatePackagePolicy,
validationResults,
submitAttempted,
}) => {
const hasIntegrations = useMemo(() => doesPackageHaveIntegrations(packageInfo), [packageInfo]);
const packagePolicyTemplates = useMemo(
() =>
showOnlyIntegration
? (packageInfo.policy_templates || []).filter(
(policyTemplate) => policyTemplate.name === showOnlyIntegration
) || []
: packageInfo.policy_templates || [],
[packageInfo.policy_templates, showOnlyIntegration]
);

// Configure inputs (and their streams)
// Assume packages only export one config template for now
const renderConfigureInputs = () =>
packageInfo.policy_templates && packageInfo.policy_templates.length ? (
packagePolicyTemplates.length ? (
<>
<EuiHorizontalRule margin="m" />
<EuiFlexGroup direction="column" gutterSize="none">
{packageInfo.policy_templates.map((policyTemplate) => {
{packagePolicyTemplates.map((policyTemplate) => {
return (policyTemplate.inputs || []).map((packageInput) => {
const packagePolicyInput = packagePolicy.inputs.find(
(input) =>
Expand Down

0 comments on commit b5ba9a4

Please sign in to comment.