-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Lens] Drag and drop info bottom bar POC implementation
- Loading branch information
Showing
5 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,3 +134,8 @@ | |
} | ||
} | ||
} | ||
|
||
.lnsDragDrop-bottomBar { | ||
text-align: center; | ||
font-weight: $euiFontWeightBold; | ||
} |
77 changes: 77 additions & 0 deletions
77
x-pack/plugins/lens/public/drag_drop/providers/bottom_bar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { EuiBottomBar } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { DropIdentifier, DraggingIdentifier } from './types'; | ||
|
||
interface BottomBarProps { | ||
dragging: DraggingIdentifier; | ||
activeDropTarget?: DropIdentifier; | ||
} | ||
|
||
const DEFAULT_DRAGGING_MESSAGE = i18n.translate('xpack.lens.dragDrop.bottomBar.dragging', { | ||
defaultMessage: `Drop a configuration to replace an existing one or add to a different dimension. (This copy doesn't say anything about reordering)`, | ||
}); | ||
|
||
const REPLACE_INCOMPATIBLE_MESSAGE = i18n.translate( | ||
'xpack.lens.dragDrop.bottomBar.replaceIncompatible', | ||
{ | ||
defaultMessage: `A partial replace can only keep the field, not the function.`, | ||
} | ||
); | ||
|
||
const MOVE_INCOMPATIBLE_MESSAGE = i18n.translate('xpack.lens.dragDrop.bottomBar.moveIncompatible', { | ||
defaultMessage: `A partial move can only keep the field, not the function.`, | ||
}); | ||
|
||
const MOVE_COMPATIBLE_MESSAGE = i18n.translate('xpack.lens.dragDrop.bottomBar.moveCompatible', { | ||
defaultMessage: `Drop to move to new dimension.`, | ||
}); | ||
|
||
const REPLACE_COMPATIBLE_MESSAGE = i18n.translate( | ||
'xpack.lens.dragDrop.bottomBar.replaceCompatible', | ||
{ | ||
defaultMessage: `Drop to replace the existing dimension.`, | ||
} | ||
); | ||
|
||
const REORDER_MESSAGE = i18n.translate('xpack.lens.dragDrop.bottomBar.reorder', { | ||
defaultMessage: `Drop to reorder.`, | ||
}); | ||
const DUPLICATE_INGROUP_MESSAGE = i18n.translate('xpack.lens.dragDrop.bottomBar.duplicateInGroup', { | ||
defaultMessage: `Drop to duplicate.`, | ||
}); | ||
|
||
const getMessage = ({ activeDropTarget }: BottomBarProps) => { | ||
if (activeDropTarget) { | ||
switch (activeDropTarget.dropType) { | ||
case 'replace_incompatible': | ||
return REPLACE_INCOMPATIBLE_MESSAGE; | ||
case 'move_incompatible': | ||
return MOVE_INCOMPATIBLE_MESSAGE; | ||
case 'move_compatible': | ||
return MOVE_COMPATIBLE_MESSAGE; | ||
case 'replace_compatible': | ||
return REPLACE_COMPATIBLE_MESSAGE; | ||
case 'reorder': | ||
return REORDER_MESSAGE; | ||
case 'duplicate_in_group': | ||
return DUPLICATE_INGROUP_MESSAGE; | ||
} | ||
} | ||
return DEFAULT_DRAGGING_MESSAGE; | ||
}; | ||
|
||
export const BottomBar = ({ dragging, activeDropTarget }: BottomBarProps) => { | ||
return ( | ||
<EuiBottomBar className="lnsDragDrop-bottomBar" paddingSize="m"> | ||
<span>{getMessage({ dragging, activeDropTarget })}</span> | ||
</EuiBottomBar> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters