Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial wiring up for capture interval #1230

Merged
merged 13 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 36 additions & 42 deletions src/components/capture/Create/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ import useDraftSpecs from 'hooks/useDraftSpecs';
import usePageTitle from 'hooks/usePageTitle';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { CustomEvents } from 'services/types';
import BindingHydrator from 'stores/Binding/Hydrator';
import { DetailsFormHydrator } from 'stores/DetailsForm/Hydrator';
import { useDetailsFormStore } from 'stores/DetailsForm/Store';
import { EndpointConfigHydrator } from 'stores/EndpointConfig/Hydrator';
import WorkflowHydrator from 'stores/Workflow/Hydrator';
import { MAX_DISCOVER_TIME } from 'utils/misc-utils';

function CaptureCreate() {
Expand Down Expand Up @@ -84,50 +82,46 @@ function CaptureCreate() {
);

return (
<DetailsFormHydrator>
<EndpointConfigHydrator>
<BindingHydrator>
<MutateDraftSpecProvider value={updateDraftSpecs}>
<EntityCreate
entityType={entityType}
draftSpecMetadata={draftSpecsMetadata}
toolbar={
<EntityToolbar
taskNames={taskNames}
waitTimes={{
generate: MAX_DISCOVER_TIME,
}}
primaryButtonProps={{
disabled: !draftId,
logEvent: CustomEvents.CAPTURE_CREATE,
}}
secondaryButtonProps={{
disabled: !hasConnectors,
logEvent: CustomEvents.CAPTURE_TEST,
}}
GenerateButton={
<CaptureGenerateButton
entityType={entityType}
disabled={!hasConnectors}
createWorkflowMetadata={{
initiateDiscovery,
setInitiateDiscovery,
}}
/>
}
/>
}
RediscoverButton={
<RediscoverButton
<WorkflowHydrator>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual change... grouped all hydrators into a shared spot

<MutateDraftSpecProvider value={updateDraftSpecs}>
<EntityCreate
entityType={entityType}
draftSpecMetadata={draftSpecsMetadata}
toolbar={
<EntityToolbar
taskNames={taskNames}
waitTimes={{
generate: MAX_DISCOVER_TIME,
}}
primaryButtonProps={{
disabled: !draftId,
logEvent: CustomEvents.CAPTURE_CREATE,
}}
secondaryButtonProps={{
disabled: !hasConnectors,
logEvent: CustomEvents.CAPTURE_TEST,
}}
GenerateButton={
<CaptureGenerateButton
entityType={entityType}
disabled={!hasConnectors}
createWorkflowMetadata={{
initiateDiscovery,
setInitiateDiscovery,
}}
/>
}
/>
</MutateDraftSpecProvider>
</BindingHydrator>
</EndpointConfigHydrator>
</DetailsFormHydrator>
}
RediscoverButton={
<RediscoverButton
entityType={entityType}
disabled={!hasConnectors}
/>
}
/>
</MutateDraftSpecProvider>
</WorkflowHydrator>
);
}

Expand Down
87 changes: 39 additions & 48 deletions src/components/capture/Edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
useEditorStore_queryResponse_mutate,
} from 'components/editor/Store/hooks';
import EntityEdit from 'components/shared/Entity/Edit';
import DraftInitializer from 'components/shared/Entity/Edit/DraftInitializer';
import EntityToolbar from 'components/shared/Entity/Header';
import { MutateDraftSpecProvider } from 'components/shared/Entity/MutateDraftSpecContext';
import useGlobalSearchParams, {
Expand All @@ -17,11 +16,9 @@ import { useDraftSpecs_editWorkflow } from 'hooks/useDraftSpecs';
import usePageTitle from 'hooks/usePageTitle';
import { useCallback, useMemo } from 'react';
import { CustomEvents } from 'services/types';
import BindingHydrator from 'stores/Binding/Hydrator';
import { DetailsFormHydrator } from 'stores/DetailsForm/Hydrator';
import { EndpointConfigHydrator } from 'stores/EndpointConfig/Hydrator';
import { MAX_DISCOVER_TIME } from 'utils/misc-utils';
import useValidConnectorsExist from 'hooks/connectors/useHasConnectors';
import WorkflowHydrator from 'stores/Workflow/Hydrator';

const entityType = 'capture';
function CaptureEdit() {
Expand Down Expand Up @@ -59,50 +56,44 @@ function CaptureEdit() {
);

return (
<DraftInitializer>
<DetailsFormHydrator>
<EndpointConfigHydrator>
<BindingHydrator>
<MutateDraftSpecProvider value={updateDraftSpecs}>
<EntityEdit
title="routeTitle.captureEdit"
entityType={entityType}
readOnly={{ detailsForm: true }}
draftSpecMetadata={draftSpecsMetadata}
toolbar={
<EntityToolbar
taskNames={taskNames}
waitTimes={{
generate: MAX_DISCOVER_TIME,
}}
primaryButtonProps={{
disabled: !draftId,
logEvent: CustomEvents.CAPTURE_EDIT,
}}
secondaryButtonProps={{
disabled: !hasConnectors,
logEvent: CustomEvents.CAPTURE_TEST,
}}
GenerateButton={
<CaptureGenerateButton
entityType={entityType}
disabled={!hasConnectors}
/>
}
/>
}
RediscoverButton={
<RediscoverButton
entityType={entityType}
disabled={!hasConnectors}
/>
}
/>
</MutateDraftSpecProvider>
</BindingHydrator>
</EndpointConfigHydrator>
</DetailsFormHydrator>
</DraftInitializer>
<WorkflowHydrator>
<MutateDraftSpecProvider value={updateDraftSpecs}>
<EntityEdit
title="routeTitle.captureEdit"
entityType={entityType}
readOnly={{ detailsForm: true }}
draftSpecMetadata={draftSpecsMetadata}
toolbar={
<EntityToolbar
taskNames={taskNames}
waitTimes={{
generate: MAX_DISCOVER_TIME,
}}
primaryButtonProps={{
disabled: !draftId,
logEvent: CustomEvents.CAPTURE_EDIT,
}}
secondaryButtonProps={{
disabled: !hasConnectors,
logEvent: CustomEvents.CAPTURE_TEST,
}}
GenerateButton={
<CaptureGenerateButton
entityType={entityType}
disabled={!hasConnectors}
/>
}
/>
}
RediscoverButton={
<RediscoverButton
entityType={entityType}
disabled={!hasConnectors}
/>
}
/>
</MutateDraftSpecProvider>
</WorkflowHydrator>
);
}

Expand Down
119 changes: 119 additions & 0 deletions src/components/capture/Interval/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import {
FormControl,
FormHelperText,
InputAdornment,
InputLabel,
MenuItem,
OutlinedInput,
Select,
Stack,
Typography,
} from '@mui/material';
import { FormattedMessage, useIntl } from 'react-intl';

const DESCRIPTION_ID = 'capture-interval-description';
const INPUT_ID = 'capture-interval-input';
const INPUT_SIZE = 'small';
interface Props {
readOnly?: boolean;
}

function CaptureInterval({ readOnly }: Props) {
const intl = useIntl();
const label = intl.formatMessage({
id: 'workflows.interval.input.label',
});

// Need to check if Capture Interval is there

return (
<Stack spacing={1}>
<Typography variant="formSectionHeader">
<FormattedMessage id="workflows.interval.header" />
</Typography>

<Typography>
<FormattedMessage id="workflows.interval.message" />
</Typography>

<FormControl
error={false}
fullWidth={false}
size={INPUT_SIZE}
variant="outlined"
sx={{
'& .MuiFormHelperText-root.Mui-error': {
whiteSpace: 'break-spaces',
},
}}
>
<InputLabel
disabled={readOnly}
focused
htmlFor={INPUT_ID}
variant="outlined"
>
{label}
</InputLabel>

<OutlinedInput
aria-describedby={DESCRIPTION_ID}
disabled={readOnly}
error={false}
id={INPUT_ID}
label={label}
size={INPUT_SIZE}
sx={{ borderRadius: 3 }}
onChange={(event) => {
console.log('change', event.target.value);
}}
endAdornment={
<InputAdornment position="start">
<Select
disabled={readOnly}
disableUnderline
error={false}
required
size={INPUT_SIZE}
variant="standard"
sx={{
'maxWidth': 100,
'minWidth': 100,
'& .MuiSelect-select': {
paddingBottom: 0.2,
},
}}
onChange={(event) => {
console.log(
'select change',
event.target.value
);
}}
>
<MenuItem value="s" selected>
<FormattedMessage id="workflows.interval.input.seconds" />
</MenuItem>

<MenuItem value="m">
<FormattedMessage id="workflows.interval.input.minutes" />
</MenuItem>

<MenuItem value="h">
<FormattedMessage id="workflows.interval.input.hours" />
</MenuItem>
</Select>
</InputAdornment>
}
/>
<FormHelperText
id={DESCRIPTION_ID}
// error={showErrors ? !description : undefined}
>
errors go here
</FormHelperText>
</FormControl>
</Stack>
);
}

export default CaptureInterval;
2 changes: 2 additions & 0 deletions src/components/editor/Bindings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ function BindingsMultiEditor({
<Stack spacing={3} sx={{ mb: 5 }}>
{entityType === 'capture' ? <AutoDiscoverySettings /> : null}

{/*{entityType === 'capture' ? <CaptureInterval /> : null}*/}

{entityType === 'materialization' ? <SourceCapture /> : null}

{workflow === 'capture_edit' ||
Expand Down
Loading