Skip to content

Commit

Permalink
feat: Supporting regex when matching override name #421
Browse files Browse the repository at this point in the history
  • Loading branch information
sunface committed Apr 20, 2024
1 parent 98ee1e8 commit 61cd5b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
2 changes: 1 addition & 1 deletion datav/frontend/src/utils/dashboard/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const findOverrideRule = (panel: Panel, overideTarget, ruleType) => {
}

export const findOverride = (panel: Panel, overideTarget) => {
return panel.overrides.find((o) => o.target == overideTarget)
return panel.overrides.find((o) => overideTarget.match(o.target))
}

export const findRuleInOverride = (override: OverrideItem, ruleType) => {
Expand Down
27 changes: 10 additions & 17 deletions datav/frontend/src/views/dashboard/edit-panel/PanelOverrides.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { PanelForceRebuildEvent } from 'src/data/bus-events'
import { MobileBreakpoint } from 'src/data/constants'
import { externalPanelPlugins } from '../plugins/external/plugins'
import { builtinPanelPlugins } from '../plugins/built-in/plugins'
import InputSelect from 'components/select/InputSelect'

const PanelOverrides = ({ panel, onChange, data }: PanelEditorProps) => {
const t1 = useStore(panelMsg)
Expand Down Expand Up @@ -115,23 +116,15 @@ const PanelOverrides = ({ panel, onChange, data }: PanelEditorProps) => {
<FaTimes fontSize='0.8rem' />
</Box>
<FormItem title={t1.targetName} alignItems='center'>
<Select
style={{ minWidth: isLargeScreen ? '150px' : '100px' }}
showSearch
size='large'
value={o.target}
onChange={(v) => {
onChange((panel: Panel) => {
const o = panel.overrides[i]
o.target = v
})
}}
options={names.map((name, i) => ({
value: name.value,
label: name.label,
}))}
popupMatchSelectWidth={false}
/>
<InputSelect value={o.target} options={names.map((name, i) => ({
value: name.value,
label: name.label,
}))} onChange={(v) => {
onChange((panel: Panel) => {
const o = panel.overrides[i]
o.target = v
})
}} />
</FormItem>

<VStack
Expand Down

0 comments on commit 61cd5b7

Please sign in to comment.