import React from 'react'; import { RelativeTimestamp } from '../RelativeTimestamp'; import type { FetchApplicationManagementDataQueryVariables } from '../graphql/graphql-sdk'; import { FetchApplicationManagementDataDocument, useImportDeliveryConfigMutation } from '../graphql/graphql-sdk'; import { useApplicationContextSafe } from '../../presentation/hooks/useApplicationContext.hook'; import { YamlViewer } from '../utils/YamlViewer'; import { useLogEvent } from '../utils/logging'; import { useNotifyOnError } from '../utils/useNotifyOnError.hook'; import { Spinner } from '../../widgets'; interface IDeliveryConfigProps { config?: string; updatedAt?: string; isProcessed?: boolean; } const ReImportConfig = () => { const appName = useApplicationContextSafe().name; const refetchVariables: FetchApplicationManagementDataQueryVariables = { appName }; const [importDeliveryConfig, { error, loading }] = useImportDeliveryConfigMutation({ variables: { application: appName }, refetchQueries: [{ query: FetchApplicationManagementDataDocument, variables: refetchVariables }], }); const logEvent = useLogEvent('GitIntegration', 'ImportNow'); useNotifyOnError({ key: 'import-error', content: `Failed to import delivery config`, error }); return ( <> ( { importDeliveryConfig(); logEvent(); }} disabled={loading} > Import now ) {loading && } > ); }; export const DeliveryConfig: React.FC = ({ config, updatedAt, isProcessed, children }) => { return ( {isProcessed ? 'Processed Delivery Config' : 'Delivery config'} {updatedAt && ( Last update: )} {!isProcessed && } {children} {config && } ); };