-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GEN-1603]: add rules column to overview (#1661)
- Loading branch information
1 parent
78eda6e
commit 6a91aba
Showing
23 changed files
with
375 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
frontend/webapp/containers/main/rules/add-rule-modal/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import styled from 'styled-components'; | ||
import React, { useEffect, useState } from 'react'; | ||
import { RULE_OPTIONS, RuleOption } from './rule-options'; | ||
import { AutocompleteInput, Divider, FadeLoader, Modal, NavigationButtons, NotificationNote, SectionTitle } from '@/reuseable-components'; | ||
|
||
const Container = styled.section` | ||
width: 100%; | ||
max-width: 640px; | ||
height: 640px; | ||
margin: 0 15vw; | ||
padding: 64px 12px 0 12px; | ||
display: flex; | ||
flex-direction: column; | ||
overflow-y: scroll; | ||
`; | ||
|
||
const Center = styled.div` | ||
width: 100%; | ||
margin-top: 24px; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
`; | ||
|
||
interface Props { | ||
isModalOpen: boolean; | ||
handleCloseModal: () => void; | ||
} | ||
|
||
export const AddRuleModal: React.FC<Props> = ({ isModalOpen, handleCloseModal }) => { | ||
// const { formData, handleFormChange, resetFormData, validateForm } = useRuleFormData(); | ||
// const { createRule, loading } = useRuleCRUD({ onSuccess: handleClose }); | ||
const [selectedItem, setSelectedItem] = useState<RuleOption | undefined>(undefined); | ||
|
||
useEffect(() => { | ||
if (!selectedItem) handleSelect(RULE_OPTIONS[0]); | ||
}, [selectedItem]); | ||
|
||
// const isFormOk = useMemo(() => !!selectedItem && validateForm(), [selectedItem, formData]); | ||
|
||
const handleSubmit = async () => { | ||
// createRule(formData); | ||
}; | ||
|
||
function handleClose() { | ||
// resetFormData(); | ||
setSelectedItem(undefined); | ||
handleCloseModal(); | ||
} | ||
|
||
const handleSelect = (item: RuleOption) => { | ||
// resetFormData(); | ||
// handleFormChange('type', item.type); | ||
setSelectedItem(item); | ||
}; | ||
|
||
return ( | ||
<Modal | ||
isOpen={isModalOpen} | ||
onClose={handleClose} | ||
header={{ title: 'Add Instrumentation Rule' }} | ||
actionComponent={ | ||
<NavigationButtons | ||
buttons={[ | ||
{ | ||
variant: 'primary', | ||
label: 'DONE', | ||
onClick: handleSubmit, | ||
disabled: true, | ||
}, | ||
]} | ||
/> | ||
} | ||
> | ||
<Container> | ||
<SectionTitle | ||
title='Define Instrumentation Rule' | ||
description='Instrumentation rules control how telemetry is recorded from your application. Choose a rule type and provide necessary information.' | ||
/> | ||
<NotificationNote | ||
type='info' | ||
text='We currently support one rule. We’ll be adding new rule types in the near future.' | ||
style={{ marginTop: '24px' }} | ||
/> | ||
<AutocompleteInput options={RULE_OPTIONS} selectedOption={selectedItem} onOptionSelect={handleSelect} style={{ marginTop: '12px' }} /> | ||
|
||
{!!selectedItem?.type ? ( | ||
<div> | ||
<Divider margin='16px 0' /> | ||
|
||
{/* {loading ? ( */} | ||
<Center> | ||
<FadeLoader cssOverride={{ scale: 2 }} /> | ||
</Center> | ||
{/* ) : ( | ||
<ChooseRuleBody rule={selectedItem} formData={formData} handleFormChange={handleFormChange} /> | ||
)} */} | ||
</div> | ||
) : null} | ||
</Container> | ||
</Modal> | ||
); | ||
}; |
25 changes: 25 additions & 0 deletions
25
frontend/webapp/containers/main/rules/add-rule-modal/rule-options.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { InstrumentationRuleType } from '@/types'; | ||
import { getRuleIcon } from '@/utils/functions'; | ||
|
||
export type RuleOption = { | ||
id: string; | ||
label: string; | ||
type?: InstrumentationRuleType; | ||
icon?: string; | ||
description?: string; | ||
docsEndpoint?: string; | ||
docsDescription?: string; | ||
items?: RuleOption[]; | ||
}; | ||
|
||
export const RULE_OPTIONS: RuleOption[] = [ | ||
{ | ||
id: 'payload_collection', | ||
label: 'Payload Collection', | ||
description: 'Collect span attributes containing payload data to traces.', | ||
type: InstrumentationRuleType.PAYLOAD_COLLECTION, | ||
icon: getRuleIcon(InstrumentationRuleType.PAYLOAD_COLLECTION), | ||
docsEndpoint: '/pipeline/rules/payloadcollection', | ||
docsDescription: 'The “Payload Collection” Rule can be used to add span attributes containing payload data to traces.', | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './add-rule-modal'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.