Files
grafana/public/app/features/connections/pages/AddNewConnectionPage.tsx
Syerikjan Kh de0682521d Feat: OSS connections page state filter and update all added (#100688)
* feat: OSS connections page state filter and update all added

* fix: use combobox instead of select

* fix: show no updates available text

* ref: extract update all button to a component
2025-02-21 10:16:45 -05:00

43 lines
1.4 KiB
TypeScript

import { useState } from 'react';
import { PluginType } from '@grafana/data';
import { Page } from 'app/core/components/Page/Page';
import UpdateAllButton from 'app/features/plugins/admin/components/UpdateAllButton';
import UpdateAllModal from 'app/features/plugins/admin/components/UpdateAllModal';
import { useGetUpdatable } from 'app/features/plugins/admin/state/hooks';
import { AddNewConnection } from '../tabs/ConnectData';
export function AddNewConnectionPage() {
const { isLoading: areUpdatesLoading, updatablePlugins } = useGetUpdatable();
const updatableDSPlugins = updatablePlugins.filter((plugin) => plugin.type === PluginType.datasource);
const [showUpdateModal, setShowUpdateModal] = useState(false);
const disableUpdateAllButton = updatableDSPlugins.length <= 0 || areUpdatesLoading;
const onUpdateAll = () => {
setShowUpdateModal(true);
};
const updateAllButton = (
<UpdateAllButton
disabled={disableUpdateAllButton}
onUpdateAll={onUpdateAll}
updatablePluginsLength={updatableDSPlugins.length}
/>
);
return (
<Page navId={'connections-add-new-connection'} actions={updateAllButton}>
<Page.Contents>
<AddNewConnection />
<UpdateAllModal
isOpen={showUpdateModal}
isLoading={areUpdatesLoading}
onDismiss={() => setShowUpdateModal(false)}
plugins={updatableDSPlugins}
/>
</Page.Contents>
</Page>
);
}