Skip to content

Commit

Permalink
mute the table row for integration action when feature flag is disabl…
Browse files Browse the repository at this point in the history
…ed and no obs installed

Signed-off-by: Ryan Liang <jiallian@amazon.com>
  • Loading branch information
RyanL1997 committed Jul 24, 2024
1 parent d45723b commit 6c9796a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const DirectQueryDataConnectionDetail: React.FC<DirectQueryDataConnection
setBreadcrumbs,
}) => {
const [observabilityDashboardsExists, setObservabilityDashboardsExists] = useState(false);
const checkIfSQLWorkbenchPluginIsInstalled = () => {
const checkIfObservabilityDashboardsPluginIsInstalled = () => {
fetch('/api/status', {
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -211,7 +211,7 @@ export const DirectQueryDataConnectionDetail: React.FC<DirectQueryDataConnection
};

useEffect(() => {
checkIfSQLWorkbenchPluginIsInstalled();
checkIfObservabilityDashboardsPluginIsInstalled();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,43 @@ export const ManageDirectQueryDataConnectionsTable: React.FC<ManageDirectQueryDa
uiSettings,
featureFlagStatus,
}) => {
const [observabilityDashboardsExists, setObservabilityDashboardsExists] = useState(false);

const checkIfObservabilityDashboardsPluginIsInstalled = () => {
fetch('/api/status', {
headers: {
'Content-Type': 'application/json',
'osd-xsrf': 'true',
'accept-language': 'en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7,zh-TW;q=0.6',
pragma: 'no-cache',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-origin',
},
method: 'GET',
referrerPolicy: 'strict-origin-when-cross-origin',
mode: 'cors',
credentials: 'include',
})
.then(function (response) {
return response.json();
})
.then((data) => {
for (let i = 0; i < data.status.statuses.length; ++i) {
if (data.status.statuses[i].id.includes('plugin:observabilityDashboards')) {
setObservabilityDashboardsExists(true);
}
}
})
.catch((error) => {
notifications.toasts.addDanger(
'Error checking Dashboards Observability Plugin Installation status.'
);
// eslint-disable-next-line no-console
console.error(error);
});
};

const [data, setData] = useState<DataConnection[]>([]);
const [isModalVisible, setIsModalVisible] = useState(false);
const [modalLayout, setModalLayout] = useState(<EuiOverlayMask />);
Expand Down Expand Up @@ -139,6 +176,8 @@ export const ManageDirectQueryDataConnectionsTable: React.FC<ManageDirectQueryDa

useEffect(() => {
fetchDataSources();
checkIfObservabilityDashboardsPluginIsInstalled();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [fetchDataSources]);

const handleSelectedDataSourceChange = (e: DataSourceOption[]) => {
Expand Down Expand Up @@ -198,7 +237,10 @@ export const ManageDirectQueryDataConnectionsTable: React.FC<ManageDirectQueryDa
isPrimary: false,
icon: 'integrationGeneral',
type: 'icon',
available: (datasource: DataConnection) => datasource.connectionType !== 'PROMETHEUS',
available: (datasource: DataConnection) =>
!featureFlagStatus &&
observabilityDashboardsExists &&
datasource.connectionType !== 'PROMETHEUS',
onClick: () => {},
'data-test-subj': 'action-integrate',
},
Expand Down

0 comments on commit 6c9796a

Please sign in to comment.