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
ui: add plan gist as option on bundle collection #110931
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,11 +31,11 @@ const { Option } = Select; | |
export interface ActivateDiagnosticsModalProps { | ||
activate: (insertStmtDiagnosticsRequest: InsertStmtDiagnosticRequest) => void; | ||
refreshDiagnosticsReports: () => void; | ||
onOpenModal?: (statement: string) => void; | ||
onOpenModal?: (statement: string, planGists: string[]) => void; | ||
} | ||
|
||
export interface ActivateDiagnosticsModalRef { | ||
showModalFor: (statement: string) => void; | ||
showModalFor: (statement: string, planGists: string[]) => void; | ||
} | ||
|
||
export const ActivateStatementDiagnosticsModal = React.forwardRef( | ||
|
@@ -45,7 +45,10 @@ export const ActivateStatementDiagnosticsModal = React.forwardRef( | |
) => { | ||
const [visible, setVisible] = useState(false); | ||
const [statement, setStatement] = useState<string>(); | ||
const [planGists, setPlanGists] = useState<string[]>(); | ||
const [conditional, setConditional] = useState(true); | ||
const [filterPerPlanGist, setFilterPerPlanGist] = useState(false); | ||
const [selectedPlanGist, setSelectedPlanGist] = useState<string>(""); | ||
const [expires, setExpires] = useState(true); | ||
const [minExecLatency, setMinExecLatency] = useState(100); | ||
const [minExecLatencyUnit, setMinExecLatencyUnit] = | ||
|
@@ -84,6 +87,7 @@ export const ActivateStatementDiagnosticsModal = React.forwardRef( | |
const onOkHandler = useCallback(() => { | ||
activate({ | ||
stmtFingerprint: statement, | ||
planGist: filterPerPlanGist ? selectedPlanGist : null, | ||
minExecutionLatencySeconds: getMinExecLatency( | ||
conditional, | ||
minExecLatency, | ||
|
@@ -102,20 +106,30 @@ export const ActivateStatementDiagnosticsModal = React.forwardRef( | |
expires, | ||
expiresAfter, | ||
traceSampleRate, | ||
filterPerPlanGist, | ||
selectedPlanGist, | ||
]); | ||
|
||
const onCancelHandler = useCallback(() => setVisible(false), []); | ||
|
||
useImperativeHandle(ref, () => { | ||
return { | ||
showModalFor: (forwardStatement: string) => { | ||
showModalFor: ( | ||
forwardStatement: string, | ||
forwardPlanGists: string[], | ||
) => { | ||
setStatement(forwardStatement); | ||
setPlanGists(forwardPlanGists); | ||
setVisible(true); | ||
onOpenModal && onOpenModal(forwardStatement); | ||
onOpenModal && onOpenModal(forwardStatement, forwardPlanGists); | ||
}, | ||
}; | ||
}); | ||
|
||
if (planGists && selectedPlanGist == "") { | ||
setSelectedPlanGist(planGists[0]); | ||
} | ||
|
||
return ( | ||
<Modal | ||
visible={visible} | ||
|
@@ -218,6 +232,51 @@ export const ActivateStatementDiagnosticsModal = React.forwardRef( | |
</Button.Group> | ||
</Radio.Group> | ||
<Divider type="horizontal" /> | ||
|
||
<Radio.Group | ||
value={filterPerPlanGist} | ||
className={cx("diagnostic__plan-gist-group")} | ||
> | ||
<Button.Group className={cx("diagnostic__btn-group")}> | ||
<Radio | ||
value={false} | ||
className={cx("diagnostic__radio-btn", "margin-bottom")} | ||
onChange={() => setFilterPerPlanGist(false)} | ||
> | ||
For all plan gists | ||
</Radio> | ||
<br /> | ||
<Radio | ||
value={true} | ||
className={cx("diagnostic__radio-btn")} | ||
onChange={() => setFilterPerPlanGist(true)} | ||
> | ||
For the following plan gist: | ||
<div className={cx("diagnostic__plan-gist-container")}> | ||
<Select | ||
disabled={!filterPerPlanGist} | ||
value={selectedPlanGist} | ||
defaultValue={planGists ? planGists[0] : ""} | ||
onChange={(selected: string) => | ||
setSelectedPlanGist(selected) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can skip creating the anon function here and just pass in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was getting a lint error, because the default is int, so I need to create this way to get the parameter as string |
||
} | ||
className={cx("diagnostic__select__plan-gist")} | ||
size="large" | ||
showSearch={true} | ||
> | ||
{planGists?.map((gist: string) => { | ||
return ( | ||
<Option value={gist} key={gist}> | ||
{gist} | ||
</Option> | ||
); | ||
})} | ||
</Select> | ||
</div> | ||
</Radio> | ||
</Button.Group> | ||
</Radio.Group> | ||
<Divider type="horizontal" /> | ||
<Checkbox checked={expires} onChange={() => setExpires(!expires)}> | ||
<div className={cx("diagnostic__checkbox-text")}> | ||
Diagnostics request expires after: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is plan_gists always going to exists or do we need to do some optional chaining here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
always going to exist