Submit
Path:
~
/
/
usr
/
share
/
grafana
/
public
/
app
/
plugins
/
datasource
/
elasticsearch
/
components
/
File Content:
AddRemove.tsx
import { css } from '@emotion/css'; import React from 'react'; import { Button } from '@grafana/ui'; interface Props { index: number; elements: unknown[]; onAdd: () => void; onRemove: () => void; } /** * A component used to show add & remove buttons for mutable lists of values. Wether to show or not the add or the remove buttons * depends on the `index` and `elements` props. This enforces a consistent experience whenever this pattern is used. */ export const AddRemove = ({ index, onAdd, onRemove, elements }: Props) => { return ( <div className={css` display: flex; `} > {index === 0 && ( <Button variant="secondary" fill="text" icon="plus" onClick={onAdd} tooltip="Add" aria-label="Add" /> )} {elements.length >= 2 && ( <Button variant="secondary" fill="text" icon="minus" onClick={onRemove} tooltip="Remove" aria-label="Remove" /> )} </div> ); };
Submit
FILE
FOLDER
INFO
Name
Size
Permission
Action
QueryEditor
---
0755
hooks
---
0755
AddRemove.test.tsx
1276 bytes
0644
AddRemove.tsx
945 bytes
0644
MetricPicker.tsx
1072 bytes
0644
reducerTester.ts
2988 bytes
0644
types.ts
134 bytes
0644
N4ST4R_ID | Naxtarrr