Skip to content

Commit

Permalink
fixed ui for webhooks to update
Browse files Browse the repository at this point in the history
  • Loading branch information
avneesh-akto committed Nov 6, 2023
1 parent 48733e4 commit 73713bc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function ApiCollectionsDropdown({ selectedCollections, setSelectedCollections })
[],
);

const [selectedOptions, setSelectedOptions] = useState(selectedCollections);
const [selectedOptions, setSelectedOptions] = useState(selectedCollections ? selectedCollections : []);
const [inputValue, setInputValue] = useState('');
const [options, setOptions] = useState(deselectedOptions);

Expand Down Expand Up @@ -68,7 +68,7 @@ function ApiCollectionsDropdown({ selectedCollections, setSelectedCollections })
<Listbox.Option
key={`${value}`}
value={value}
selected={selectedOptions.includes(value)}
selected={selectedOptions && selectedOptions.includes(value)}
accessibilityLabel={label}
>
{label}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,11 @@ function SampleData(props) {
}, [])

if (instance){
instance.onDidChangeModelContent(()=> {
getEditorData(instance.getValue())
})
if (!readOnly) {
instance.onDidChangeModelContent(()=> {
getEditorData(instance.getValue())
})
}
}

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ function Webhook() {
},
];

const customWebhookFindId = customWebhooks.find(customWebhook => customWebhook.id.toString() === webhookId)

function handleWebhookTabChange(selectedTabIndex) {
setSelectedWebhookTab(selectedTabIndex)
}
Expand Down Expand Up @@ -201,9 +199,7 @@ function Webhook() {
}

function getSelectedCollections(collectionStateField) {
const customWebhookFindId = customWebhooks.find(customWebhook => customWebhook.id.toString() === webhookId)

if (customWebhookFindId) return customWebhookFindId[collectionStateField]
if (webhook) return webhook[collectionStateField]
else return []
}

Expand Down Expand Up @@ -269,15 +265,15 @@ function Webhook() {
)


let Card
let CardComponent
let CardTitle
let actionContent
if (showOptions) {
Card = OptionsCard
CardComponent = OptionsCard
CardTitle = "Options"
actionContent = "Custom"
} else {
Card = CustomWebhookEditor
CardComponent = CustomWebhookEditor
CardTitle = "Custom"
actionContent = "Default"
}
Expand All @@ -289,7 +285,7 @@ function Webhook() {
const OverallCard = (
<LegacyCard title={CardTitle} key="options" actions={[{content: actionContent, onAction: toggleShowOptions}]}>
<LegacyCard.Section>
{Card}
{CardComponent}
<Divider />
<div style={{ paddingTop: "10px" }}>
<Text variant="headingMd">Run every</Text>
Expand Down Expand Up @@ -335,7 +331,7 @@ function Webhook() {
isLoading ? <SpinnerCentered /> :
<PageWithMultipleCards
title={webhookId ?
customWebhookFindId ? customWebhookFindId.webhookName : ''
webhook? webhook.webhookName : ''
: "Create custom webhook"}
divider
backUrl="/dashboard/settings/integrations/webhooks"
Expand Down

0 comments on commit 73713bc

Please sign in to comment.