mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* add modal scaffolding * add some unit tests * remove dummy api, add some TODO comments * small test refactor * another small test refactor * fix unit tests due to aria-label/data-testid change
68 lines
1.6 KiB
TypeScript
68 lines
1.6 KiB
TypeScript
import { css } from '@emotion/css';
|
|
import React from 'react';
|
|
|
|
import { GrafanaTheme2 } from '@grafana/data';
|
|
import { Button, useStyles2 } from '@grafana/ui';
|
|
import appEvents from 'app/core/app_events';
|
|
import { ShowModalReactEvent } from 'app/types/events';
|
|
|
|
import { useSelectedItemsState } from '../../state';
|
|
|
|
import { DeleteModal } from './DeleteModal';
|
|
import { MoveModal } from './MoveModal';
|
|
|
|
export interface Props {}
|
|
|
|
export function BrowseActions() {
|
|
const styles = useStyles2(getStyles);
|
|
const selectedItems = useSelectedItemsState();
|
|
|
|
const onMove = () => {
|
|
appEvents.publish(
|
|
new ShowModalReactEvent({
|
|
component: MoveModal,
|
|
props: {
|
|
selectedItems,
|
|
onConfirm: (moveTarget: string) => {
|
|
console.log(`MoveModal onConfirm clicked with target ${moveTarget}!`);
|
|
},
|
|
},
|
|
})
|
|
);
|
|
};
|
|
|
|
const onDelete = () => {
|
|
appEvents.publish(
|
|
new ShowModalReactEvent({
|
|
component: DeleteModal,
|
|
props: {
|
|
selectedItems,
|
|
onConfirm: () => {
|
|
console.log('DeleteModal onConfirm clicked!');
|
|
},
|
|
},
|
|
})
|
|
);
|
|
};
|
|
|
|
return (
|
|
<div className={styles.row} data-testid="manage-actions">
|
|
<Button onClick={onMove} variant="secondary">
|
|
Move
|
|
</Button>
|
|
<Button onClick={onDelete} variant="destructive">
|
|
Delete
|
|
</Button>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
const getStyles = (theme: GrafanaTheme2) => ({
|
|
row: css({
|
|
display: 'flex',
|
|
flexDirection: 'row',
|
|
gap: theme.spacing(1),
|
|
marginBottom: theme.spacing(2),
|
|
}),
|
|
});
|