mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 04:31:36 +08:00

* 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
43 lines
1.4 KiB
TypeScript
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>
|
|
);
|
|
}
|