Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PMM-13428 Fix add remote instance issues. #784

Merged
merged 3 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ services:
- "./:/workspace"
- "./public:/usr/share/grafana/public"
- "./conf/grafana.local-dev.ini:/usr/share/grafana/conf/defaults.ini"
# pmm
# - "../pmm:/root/go/src/github.com/percona/pmm"
ports:
- 80:8080
- 443:8443
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { FC, useCallback, useEffect, useMemo } from 'react';

import { useStyles2 } from '@grafana/ui';
import { NodesAgents } from 'app/percona/add-instance/components/AddRemoteInstance/FormParts/NodesAgents/NodesAgents';
import { PasswordInputField } from 'app/percona/shared/components/Form/PasswordInput';
import { RadioButtonGroupField } from 'app/percona/shared/components/Form/RadioButtonGroup';
import { TextInputField } from 'app/percona/shared/components/Form/TextInput';
Expand Down Expand Up @@ -97,7 +96,6 @@ export const ExternalServiceConnectionDetails: FC<FormPartProps> = ({ form }) =>
/>
<div />
</div>
<NodesAgents form={form} />
<div className={styles.group}>
<TextInputField
name="address"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { FC, useCallback, useMemo } from 'react';

import { useStyles2 } from '@grafana/ui';
import { NodesAgents } from 'app/percona/add-instance/components/AddRemoteInstance/FormParts/NodesAgents/NodesAgents';
import { PasswordInputField } from 'app/percona/shared/components/Form/PasswordInput';
import { TextInputField } from 'app/percona/shared/components/Form/TextInput';
import Validators from 'app/percona/shared/helpers/validators';
Expand Down Expand Up @@ -30,7 +29,6 @@ export const HAProxyConnectionDetails: FC<MainDetailsFormPartProps> = ({ form, r
/>
<div />
</div>
<NodesAgents form={form} />
<div className={styles.group}>
<TextInputField
name="address"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@ export const NodesAgents: FC<NodesAgentsProps> = ({ form }) => {
}, []);

const changeAgentValue = (value: AgentsOption) => {
if (value.label !== PMM_SERVER_NODE_AGENT_ID) {
form?.change('address', 'localhost');
} else {
form?.change('address', '');
console.log(form?.getState().values?.address);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
console.log(form?.getState().values?.address);

if (form?.getState().values?.address === undefined || form?.getState().values?.address === '' ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (form?.getState().values?.address === undefined || form?.getState().values?.address === '' ) {
if (!form?.getState().values?.address) {

if (value.label !== PMM_SERVER_NODE_AGENT_ID) {
form?.change('address', 'localhost');
} else {
form?.change('address', '');
}
}
};

Expand All @@ -57,13 +60,9 @@ export const NodesAgents: FC<NodesAgentsProps> = ({ form }) => {
}
if (selectedAgent) {
form?.change('pmm_agent_id', selectedAgent);

if (selectedAgent.value !== PMM_SERVER_NODE_AGENT_ID) {
form?.change('address', 'localhost');
}
changeAgentValue(selectedAgent);
} else {
form?.change('pmm_agent_id', undefined);
form?.change('address', '');
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import { FormApi } from 'final-form';

export interface NodesAgentsProps {
form?: FormApi;
isRDS?: boolean;
matejkubinec marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ export const nodesOptionsMapper = (nodeFromDb: NodeDB[]): NodesOption[] =>
label: node.node_name,
agents: agents,
};
});
}).filter((node) => node.agents.length > 0);
Loading