Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/cozy-showers-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@wso2is/admin.approval-workflows.v1": patch
"@wso2is/admin.flow-builder-core.v1": patch
"@wso2is/admin.policy-administration.v1": patch
"@wso2is/admin.rules.v1": patch
"@wso2is/admin.webhooks.v1": patch
---

Replace inline array default props with module-level constants to prevent unnecessary re-renders
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import WorkflowConditionTextInput from "./workflow-condition-text-input";
import WorkflowResourceListSelect from "./workflow-resource-list-select";
import { APPROVAL_WORKFLOW_RULE_FIELDS } from "../../constants/approval-workflow-constants";

const EMPTY_STRING_ARRAY: string[] = [];

/**
* Props interface of {@link WorkflowConditionValueInput}
*/
Expand Down Expand Up @@ -66,8 +68,8 @@ const WorkflowConditionValueInput: FunctionComponent<WorkflowConditionValueInput
expressionValue: _expressionValue,
metaValue,
setIsResourceMissing,
hiddenResources: _hiddenResources = [],
hiddenValues: _hiddenValues = [],
hiddenResources: _hiddenResources = EMPTY_STRING_ARRAY,
hiddenValues: _hiddenValues = EMPTY_STRING_ARRAY,
readonly: isReadonly,
showValidationError = false
}: WorkflowConditionValueInputPropsInterface) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ import AutoCompleteRenderOption from "./auto-complete-render-option";
import useGetWorkflowResources from "../../hooks/use-get-workflow-resources";
import { normalizeResourceResponse, processResourceItems } from "../../utils/resource-utils";

const EMPTY_STRING_ARRAY: string[] = [];

/**
* Value input autocomplete options interface.
*/
Expand Down Expand Up @@ -93,7 +95,7 @@ const WorkflowResourceAutocomplete: FunctionComponent<WorkflowResourceAutocomple
conditionId: _conditionId,
expressionId: _expressionId,
shouldFetch,
hiddenResources: _hiddenResources = [],
hiddenResources: _hiddenResources = EMPTY_STRING_ARRAY,
showClearFilter = false,
readonly: isReadonly,
showValidationError = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ import WorkflowResourceAutocomplete from "./workflow-resource-autocomplete";
import useGetWorkflowResources from "../../hooks/use-get-workflow-resources";
import { normalizeResourceResponse, processResourceItems } from "../../utils/resource-utils";

const EMPTY_STRING_ARRAY: string[] = [];

/**
* Props interface of {@link WorkflowResourceListSelect}
*/
Expand Down Expand Up @@ -74,7 +76,7 @@ const WorkflowResourceListSelect: FunctionComponent<WorkflowResourceListSelectPr
findMetaValuesAgainst,
initialResourcesLoadUrl,
filterBaseResourcesUrl,
hiddenResources: _hiddenResources = [],
hiddenResources: _hiddenResources = EMPTY_STRING_ARRAY,
readonly: isReadonly,
showValidationError = false
}: WorkflowResourceListSelectPropsInterface) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ import ElementPropertiesPanel from "../resource-property-panel/resource-property
import ValidationPanel from "../validation-panel/validation-panel";
import VersionHistoryPanel from "../version-history-panel/version-history-panel";

const EMPTY_NODES: Node[] = [];
const EMPTY_EDGES: Edge[] = [];

/**
* Props interface of {@link DecoratedVisualFlow}
*/
Expand Down Expand Up @@ -91,8 +94,8 @@ const DecoratedVisualFlow: FunctionComponent<DecoratedVisualFlowPropsInterface>
"data-componentid": componentId = "authentication-flow-visual-editor",
aiGeneratedFlow,
resources,
initialNodes = [],
initialEdges = [],
initialNodes = EMPTY_NODES,
initialEdges = EMPTY_EDGES,
setNodes,
setEdges,
edges,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import PolicyListNode from "./policy-list-node";
import { PolicyInterface } from "../models/policies";
import "./policy-list.scss";

const EMPTY_POLICIES: PolicyInterface[] = [];

interface PolicyListProps extends IdentifiableComponentInterface {
onDrop?: (containerId: string) => void;
policies?: PolicyInterface[]; // Use PolicyInterface[]
Expand Down Expand Up @@ -66,7 +68,7 @@ interface PolicyListProps extends IdentifiableComponentInterface {

export const PolicyList: React.FunctionComponent<PolicyListProps> = ({
onDrop,
policies = [],
policies = EMPTY_POLICIES,
deleteActivePolicy,
deleteInactivePolicy,
activatePolicy,
Expand Down
16 changes: 9 additions & 7 deletions features/admin.rules.v1/components/rule-conditions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ import {
} from "../models/rules";
import "./rule-conditions.scss";

const EMPTY_STRING_ARRAY: string[] = [];

/**
* Value input autocomplete options interface.
*/
Expand Down Expand Up @@ -210,7 +212,7 @@ const RuleConditions: FunctionComponent<RulesComponentPropsInterface> = ({
conditionId,
expressionId,
shouldFetch,
hiddenResources = []
hiddenResources = EMPTY_STRING_ARRAY
}: ValueInputAutocompleteProps) => {

const [ inputValue, setInputValue ] = useState<string>(null);
Expand Down Expand Up @@ -403,7 +405,7 @@ const RuleConditions: FunctionComponent<RulesComponentPropsInterface> = ({
findMetaValuesAgainst,
initialResourcesLoadUrl,
filterBaseResourcesUrl,
hiddenResources = []
hiddenResources = EMPTY_STRING_ARRAY
}: ResourceListSelectProps) => {

const [ resourceDetails, setResourceDetails ] = useState<ResourceInterface>(null);
Expand Down Expand Up @@ -666,8 +668,8 @@ const RuleConditions: FunctionComponent<RulesComponentPropsInterface> = ({
expressionValue,
metaValue,
setIsResourceMissing,
hiddenResources = [],
hiddenValues = []
hiddenResources = EMPTY_STRING_ARRAY,
hiddenValues = EMPTY_STRING_ARRAY
}: ConditionValueInputProps) => {

if (metaValue?.inputType === "input" || null) {
Expand Down Expand Up @@ -780,9 +782,9 @@ const RuleConditions: FunctionComponent<RulesComponentPropsInterface> = ({
index,
isConditionLast,
isConditionExpressionRemovable,
hiddenConditions = [],
hiddenResources = [],
hiddenValues = []
hiddenConditions = EMPTY_STRING_ARRAY,
hiddenResources = EMPTY_STRING_ARRAY,
hiddenValues = EMPTY_STRING_ARRAY
}: RuleExpressionComponentProps) => {

const [ isResourceMissing, setIsResourceMissing ] = useState<boolean>(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { Icon } from "semantic-ui-react";
import { WebhookChannelConfigInterface } from "../models/event-profile";
import { ChannelStatus, WebhookChannelSubscriptionInterface } from "../models/webhooks";

const EMPTY_CHANNEL_SUBSCRIPTIONS: WebhookChannelSubscriptionInterface[] = [];

interface WebhookChannelConfigFormInterface extends IdentifiableComponentInterface {
/**
* Specifies the channel configurations for the form.
Expand All @@ -45,7 +47,7 @@ interface WebhookChannelConfigFormInterface extends IdentifiableComponentInterfa
const WebhookChannelConfigForm: FunctionComponent<WebhookChannelConfigFormInterface> = ({
channelConfigs,
isReadOnly,
channelSubscriptions = [],
channelSubscriptions = EMPTY_CHANNEL_SUBSCRIPTIONS,
["data-componentid"]: _componentId = "webhook-channel-config-form"
}: WebhookChannelConfigFormInterface): ReactElement => {
const defaultChannels: WebhookChannelConfigInterface[] = channelConfigs;
Expand Down
Loading