mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-10-13 05:21:31 +08:00

* fix: update AWS accounts API response to return accounts list * feat: display skeleton UI for account actions and refactored rendering logic * chore: update AWS service naming from "AWS Web Services" to "Amazon Web Services" * feat: aws integration success modal changes * feat: auto-select first service when no service is active * feat: display 'enable service' if service hasn't been configured and 'Configure (x/2)' if configured * fix: display no data yet if status is not available * feat: properly handle remove integration account flow * fix: rename accountId param to cloudAccountId * fix: update the aws service list and details api parameter from account_id to cloud_account_id * fix: fix the issue of stale service config modal enabled/disabled state * chore: improve the UI of configure button * feat: add connection parameters support for AWS cloud integration * feat: add optional link support for cloud service dashboards * fix: get the correct supported signals count + a minor refactoring * fix: remove cloudAccountId on success of account remove * chore: update the remove integration copy * refactor: add react query key for AWS connection parameters * fix: correct typo in integration loading state variable name * refactor: move skeleton inline styles to style file and do overall refactoring * chore: address the requested changes
119 lines
3.1 KiB
TypeScript
119 lines
3.1 KiB
TypeScript
import './ServicesTabs.style.scss';
|
|
|
|
import { Color } from '@signozhq/design-tokens';
|
|
import type { SelectProps, TabsProps } from 'antd';
|
|
import { Select, Tabs } from 'antd';
|
|
import { getAwsServices } from 'api/integrations/aws';
|
|
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
|
|
import useUrlQuery from 'hooks/useUrlQuery';
|
|
import { ChevronDown } from 'lucide-react';
|
|
import { useMemo, useState } from 'react';
|
|
import { useQuery } from 'react-query';
|
|
|
|
import ServiceDetails from './ServiceDetails';
|
|
import ServicesList from './ServicesList';
|
|
|
|
export enum ServiceFilterType {
|
|
ALL_SERVICES = 'all_services',
|
|
ENABLED = 'enabled',
|
|
AVAILABLE = 'available',
|
|
}
|
|
|
|
interface ServicesFilterProps {
|
|
cloudAccountId: string;
|
|
onFilterChange: (value: ServiceFilterType) => void;
|
|
}
|
|
|
|
function ServicesFilter({
|
|
cloudAccountId,
|
|
onFilterChange,
|
|
}: ServicesFilterProps): JSX.Element | null {
|
|
const { data: services, isLoading } = useQuery(
|
|
[REACT_QUERY_KEY.AWS_SERVICES, cloudAccountId],
|
|
() => getAwsServices(cloudAccountId),
|
|
);
|
|
|
|
const { enabledCount, availableCount } = useMemo(() => {
|
|
if (!services) return { enabledCount: 0, availableCount: 0 };
|
|
|
|
return services.reduce(
|
|
(acc, service) => {
|
|
const isEnabled =
|
|
service?.config?.logs?.enabled || service?.config?.metrics?.enabled;
|
|
return {
|
|
enabledCount: acc.enabledCount + (isEnabled ? 1 : 0),
|
|
availableCount: acc.availableCount + (isEnabled ? 0 : 1),
|
|
};
|
|
},
|
|
{ enabledCount: 0, availableCount: 0 },
|
|
);
|
|
}, [services]);
|
|
|
|
const selectOptions: SelectProps['options'] = useMemo(
|
|
() => [
|
|
{ value: 'all_services', label: `All Services (${services?.length || 0})` },
|
|
{ value: 'enabled', label: `Enabled (${enabledCount})` },
|
|
{ value: 'available', label: `Available (${availableCount})` },
|
|
],
|
|
[services, enabledCount, availableCount],
|
|
);
|
|
|
|
if (isLoading) return null;
|
|
if (!services?.length) return null;
|
|
|
|
return (
|
|
<div className="services-filter">
|
|
<Select
|
|
style={{ width: '100%' }}
|
|
defaultValue={ServiceFilterType.ALL_SERVICES}
|
|
options={selectOptions}
|
|
className="services-sidebar__select"
|
|
suffixIcon={<ChevronDown size={16} color={Color.BG_VANILLA_400} />}
|
|
onChange={onFilterChange}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function ServicesSection(): JSX.Element {
|
|
const urlQuery = useUrlQuery();
|
|
const cloudAccountId = urlQuery.get('cloudAccountId') || '';
|
|
|
|
const [activeFilter, setActiveFilter] = useState<
|
|
'all_services' | 'enabled' | 'available'
|
|
>('all_services');
|
|
|
|
return (
|
|
<div className="services-section">
|
|
<div className="services-section__sidebar">
|
|
<ServicesFilter
|
|
cloudAccountId={cloudAccountId}
|
|
onFilterChange={setActiveFilter}
|
|
/>
|
|
<ServicesList cloudAccountId={cloudAccountId} filter={activeFilter} />
|
|
</div>
|
|
<div className="services-section__content">
|
|
<ServiceDetails />
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
function ServicesTabs(): JSX.Element {
|
|
const tabItems: TabsProps['items'] = [
|
|
{
|
|
key: 'services',
|
|
label: 'Services For Integration',
|
|
children: <ServicesSection />,
|
|
},
|
|
];
|
|
|
|
return (
|
|
<div className="services-tabs">
|
|
<Tabs defaultActiveKey="services" items={tabItems} />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default ServicesTabs;
|