Skip to content
Snippets Groups Projects
Commit 9f3e6637 authored by Sameer Al-Sakran's avatar Sameer Al-Sakran Committed by GitHub
Browse files

Merge pull request #4815 from metabase/drill-polish

Drill polish
parents 08101f0e bdbc327f
No related branches found
No related tags found
No related merge requests found
Showing
with 418 additions and 148 deletions
......@@ -49,7 +49,6 @@ node-5() {
run_step lein eastwood
run_step yarn run lint
run_step yarn run test
run_step yarn run test-jest
run_step yarn run flow
}
node-6() {
......
......@@ -29,6 +29,7 @@ export default class Popover extends Component {
// target: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
tetherOptions: PropTypes.object,
sizeToFit: PropTypes.bool,
pinInitialAttachment: PropTypes.bool,
};
static defaultProps = {
......@@ -206,39 +207,43 @@ export default class Popover extends Component {
...this.props.tetherOptions
});
} else {
let best = {
attachmentX: "center",
attachmentY: "top",
targetAttachmentX: "center",
targetAttachmentY: "bottom",
offsetX: 0,
offsetY: 0
};
// horizontal
best = this._getBestAttachmentOptions(
tetherOptions, best, this.props.horizontalAttachments, ["left", "right"],
(best, attachmentX) => ({
...best,
attachmentX: attachmentX,
if (!this._best || !this.props.pinInitialAttachment) {
let best = {
attachmentX: "center",
attachmentY: "top",
targetAttachmentX: "center",
offsetX: ({ "center": 0, "left": -(this.props.targetOffsetX), "right": this.props.targetOffsetX })[attachmentX]
})
);
// vertical
best = this._getBestAttachmentOptions(
tetherOptions, best, this.props.verticalAttachments, ["top", "bottom"],
(best, attachmentY) => ({
...best,
attachmentY: attachmentY,
targetAttachmentY: (attachmentY === "top" ? "bottom" : "top"),
offsetY: ({ "top": this.props.targetOffsetY, "bottom": -(this.props.targetOffsetY) })[attachmentY]
})
);
targetAttachmentY: "bottom",
offsetX: 0,
offsetY: 0
};
// horizontal
best = this._getBestAttachmentOptions(
tetherOptions, best, this.props.horizontalAttachments, ["left", "right"],
(best, attachmentX) => ({
...best,
attachmentX: attachmentX,
targetAttachmentX: "center",
offsetX: ({ "center": 0, "left": -(this.props.targetOffsetX), "right": this.props.targetOffsetX })[attachmentX]
})
);
// vertical
best = this._getBestAttachmentOptions(
tetherOptions, best, this.props.verticalAttachments, ["top", "bottom"],
(best, attachmentY) => ({
...best,
attachmentY: attachmentY,
targetAttachmentY: (attachmentY === "top" ? "bottom" : "top"),
offsetY: ({ "top": this.props.targetOffsetY, "bottom": -(this.props.targetOffsetY) })[attachmentY]
})
);
this._best = best;
}
// finally set the best options
this._setTetherOptions(tetherOptions, best);
this._setTetherOptions(tetherOptions, this._best);
}
if (this.props.sizeToFit) {
......
......@@ -33,6 +33,10 @@
color: var(--default-font-color);
}
.text-default-hover:hover {
color: var(--default-font-color);
}
.text-danger { color: #EEA5A5; }
/* brand */
......
......@@ -19,6 +19,7 @@ export var ICON_PATHS = {
backArrow: 'M11.7416687,19.0096 L18.8461178,26.4181004 L14.2696969,30.568 L0.38960831,16.093881 L0,15.6875985 L0.49145276,15.241949 L14.6347557,1 L19.136,5.22693467 L11.3214393,13.096 L32,13.096 L32,19.0096 L11.7416687,19.0096 Z',
bar: 'M2 23.467h6.4V32H2v-8.533zm10.667-12.8h6.4V32h-6.4V10.667zM23.333 0h6.4v32h-6.4V0z',
beaker: 'M4.31736354,31.1631075 C3.93810558,30.6054137 3.89343681,29.6635358 4.20559962,29.0817181 L11.806982,14.9140486 L11.8069821,10.5816524 L10.7015144,10.4653256 C10.0309495,10.394763 9.48734928,9.78799739 9.48734928,9.12166999 L9.48734928,7.34972895 C9.48734928,6.67821106 10.0368737,6.13383825 10.7172248,6.13383825 L21.8462005,6.13383825 C22.525442,6.13383825 23.0760761,6.68340155 23.0760761,7.34972895 L23.0760761,9.12166999 C23.0760761,9.79318788 22.5250158,10.3375607 21.856025,10.3375607 L20.9787023,10.3375607 L20.9787024,14.9281806 L28.77277,29.0827118 C29.0983515,29.6739888 29.0709073,30.6193105 28.7174156,31.1846409 L28.852457,30.9686726 C28.4963041,31.538259 27.6541076,32 26.9865771,32 L6.10749779,32 C5.43315365,32 4.58248747,31.5529687 4.19978245,30.9902061 L4.31736354,31.1631075 Z M15.5771418,17.6040443 C16.5170398,17.6040443 17.2789777,16.8377777 17.2789777,15.89254 C17.2789777,14.9473023 16.5170398,14.1810358 15.5771418,14.1810358 C14.6372438,14.1810358 13.8753059,14.9473023 13.8753059,15.89254 C13.8753059,16.8377777 14.6372438,17.6040443 15.5771418,17.6040443 Z M16.5496195,12.8974079 C17.8587633,12.8974079 18.9200339,11.830108 18.9200339,10.5135268 C18.9200339,9.1969457 17.8587633,8.1296458 16.5496195,8.1296458 C15.2404758,8.1296458 14.1792052,9.1969457 14.1792052,10.5135268 C14.1792052,11.830108 15.2404758,12.8974079 16.5496195,12.8974079 Z M5.71098553,30.2209651 L10.9595331,20.5151267 C10.9595331,20.5151267 12.6834557,21.2672852 14.3734184,21.2672852 C16.0633811,21.2672852 16.8198616,19.2872624 17.588452,18.6901539 C18.3570425,18.0930453 19.9467191,17.1113296 19.9467191,17.1113296 L27.0506095,30.1110325 L5.71098553,30.2209651 Z M13.6608671,4.37817079 C14.4114211,4.37817079 15.0198654,3.78121712 15.0198654,3.04483745 C15.0198654,2.30845779 14.4114211,1.71150412 13.6608671,1.71150412 C12.9103132,1.71150412 12.3018689,2.30845779 12.3018689,3.04483745 C12.3018689,3.78121712 12.9103132,4.37817079 13.6608671,4.37817079 Z M17.9214578,2.45333328 C18.6119674,2.45333328 19.1717361,1.90413592 19.1717361,1.22666664 C19.1717361,0.549197362 18.6119674,0 17.9214578,0 C17.2309481,0 16.6711794,0.549197362 16.6711794,1.22666664 C16.6711794,1.90413592 17.2309481,2.45333328 17.9214578,2.45333328 Z',
breakout: 'M.025 12.864s7.682-.008 10.09-.008c2.407 0 6.815 1.072 9.87 3.155 3.055 2.084 6.63 6.03 6.63 6.03l3.22-3.146L32 32l-13.279-2.058 3.31-3.38c-1.263-1.328-4.24-4.964-7.857-6.441-3.617-1.478-10.762-.75-14.15-.98-.055-.003 0-6.277 0-6.277zM31.979 0l-2.123 13.164-3.754-3.62-4.74 4.491c-1.31-1.176-5.238-2.634-5.238-2.634 2.62-1.366 6.32-5.581 6.32-5.581l-3.7-3.824L31.98 0z',
bubble: 'M18.155 20.882c-5.178-.638-9.187-5.051-9.187-10.402C8.968 4.692 13.66 0 19.448 0c5.789 0 10.48 4.692 10.48 10.48 0 3.05-1.302 5.797-3.383 7.712a7.127 7.127 0 1 1-8.39 2.69zm-6.392 10.14a2.795 2.795 0 1 1 0-5.59 2.795 2.795 0 0 1 0 5.59zm-6.079-6.288a4.541 4.541 0 1 1 0-9.083 4.541 4.541 0 0 1 0 9.083z',
cards: 'M16.5,11 C16.1340991,11 15.7865579,10.9213927 15.4733425,10.7801443 L7.35245972,21.8211652 C7.7548404,22.264891 8,22.8538155 8,23.5 C8,24.8807119 6.88071187,26 5.5,26 C4.11928813,26 3,24.8807119 3,23.5 C3,22.1192881 4.11928813,21 5.5,21 C5.87370843,21 6.22826528,21.0819977 6.5466604,21.2289829 L14.6623495,10.1950233 C14.2511829,9.74948188 14,9.15407439 14,8.5 C14,7.11928813 15.1192881,6 16.5,6 C17.8807119,6 19,7.11928813 19,8.5 C19,8.96980737 18.8704088,9.4093471 18.6450228,9.78482291 L25.0405495,15.4699905 C25.4512188,15.1742245 25.9552632,15 26.5,15 C27.8807119,15 29,16.1192881 29,17.5 C29,18.8807119 27.8807119,20 26.5,20 C25.1192881,20 24,18.8807119 24,17.5 C24,17.0256697 24.1320984,16.5821926 24.3615134,16.2043506 L17.9697647,10.5225413 C17.5572341,10.8228405 17.0493059,11 16.5,11 Z M5.5,25 C6.32842712,25 7,24.3284271 7,23.5 C7,22.6715729 6.32842712,22 5.5,22 C4.67157288,22 4,22.6715729 4,23.5 C4,24.3284271 4.67157288,25 5.5,25 Z M26.5,19 C27.3284271,19 28,18.3284271 28,17.5 C28,16.6715729 27.3284271,16 26.5,16 C25.6715729,16 25,16.6715729 25,17.5 C25,18.3284271 25.6715729,19 26.5,19 Z M16.5,10 C17.3284271,10 18,9.32842712 18,8.5 C18,7.67157288 17.3284271,7 16.5,7 C15.6715729,7 15,7.67157288 15,8.5 C15,9.32842712 15.6715729,10 16.5,10 Z',
calendar: {
......@@ -55,6 +56,7 @@ export var ICON_PATHS = {
database: 'M1.18285296e-08,10.5127919 C-1.47856568e-08,7.95412848 1.18285298e-08,4.57337284 1.18285298e-08,4.57337284 C1.18285298e-08,4.57337284 1.58371041,5.75351864e-10 15.6571342,0 C29.730558,-5.7535027e-10 31.8900148,4.13849684 31.8900148,4.57337284 L31.8900148,10.4843058 C31.8900148,10.4843058 30.4448001,15.1365942 16.4659751,15.1365944 C2.48715012,15.1365947 2.14244494e-08,11.4353349 1.18285296e-08,10.5127919 Z M0.305419478,21.1290071 C0.305419478,21.1290071 0.0405133833,21.2033291 0.0405133833,21.8492606 L0.0405133833,27.3032816 C0.0405133833,27.3032816 1.46515486,31.941655 15.9641228,31.941655 C30.4630908,31.941655 32,27.3446712 32,27.3446712 C32,27.3446712 32,21.7986104 32,21.7986105 C32,21.2073557 31.6620557,21.0987647 31.6620557,21.0987647 C31.6620557,21.0987647 29.7146434,25.22314 16.0318829,25.22314 C2.34912233,25.22314 0.305419478,21.1290071 0.305419478,21.1290071 Z M0.305419478,12.656577 C0.305419478,12.656577 0.0405133833,12.730899 0.0405133833,13.3768305 L0.0405133833,18.8308514 C0.0405133833,18.8308514 1.46515486,23.4692249 15.9641228,23.4692249 C30.4630908,23.4692249 32,18.8722411 32,18.8722411 C32,18.8722411 32,13.3261803 32,13.3261803 C32,12.7349256 31.6620557,12.6263346 31.6620557,12.6263346 C31.6620557,12.6263346 29.7146434,16.7507099 16.0318829,16.7507099 C2.34912233,16.7507099 0.305419478,12.656577 0.305419478,12.656577 Z',
dashboard: 'M32,29 L32,4 L32,0 L0,0 L0,8 L28,8 L28,28 L4,28 L4,8 L0,8 L0,29.5 L0,32 L32,32 L32,29 Z M7.27272727,18.9090909 L17.4545455,18.9090909 L17.4545455,23.2727273 L7.27272727,23.2727273 L7.27272727,18.9090909 Z M7.27272727,12.0909091 L24.7272727,12.0909091 L24.7272727,16.4545455 L7.27272727,16.4545455 L7.27272727,12.0909091 Z M20.3636364,18.9090909 L24.7272727,18.9090909 L24.7272727,23.2727273 L20.3636364,23.2727273 L20.3636364,18.9090909 Z',
dashboards: 'M17,5.49100518 L17,10.5089948 C17,10.7801695 17.2276528,11 17.5096495,11 L26.4903505,11 C26.7718221,11 27,10.7721195 27,10.5089948 L27,5.49100518 C27,5.21983051 26.7723472,5 26.4903505,5 L17.5096495,5 C17.2281779,5 17,5.22788048 17,5.49100518 Z M18.5017326,14 C18.225722,14 18,13.77328 18,13.4982674 L18,26.5017326 C18,26.225722 18.22672,26 18.5017326,26 L5.49826741,26 C5.77427798,26 6,26.22672 6,26.5017326 L6,13.4982674 C6,13.774278 5.77327997,14 5.49826741,14 L18.5017326,14 Z M14.4903505,6 C14.2278953,6 14,5.78028538 14,5.49100518 L14,10.5089948 C14,10.2167107 14.2224208,10 14.4903505,10 L5.50964952,10 C5.77210473,10 6,10.2197146 6,10.5089948 L6,5.49100518 C6,5.78328929 5.77757924,6 5.50964952,6 L14.4903505,6 Z M26.5089948,22 C26.2251201,22 26,21.7774008 26,21.4910052 L26,26.5089948 C26,26.2251201 26.2225992,26 26.5089948,26 L21.4910052,26 C21.7748799,26 22,26.2225992 22,26.5089948 L22,21.4910052 C22,21.7748799 21.7774008,22 21.4910052,22 L26.5089948,22 Z M26.5089948,14 C26.2251201,14 26,13.7774008 26,13.4910052 L26,18.5089948 C26,18.2251201 26.2225992,18 26.5089948,18 L21.4910052,18 C21.7748799,18 22,18.2225992 22,18.5089948 L22,13.4910052 C22,13.7748799 21.7774008,14 21.4910052,14 L26.5089948,14 Z M26.4903505,6 C26.2278953,6 26,5.78028538 26,5.49100518 L26,10.5089948 C26,10.2167107 26.2224208,10 26.4903505,10 L17.5096495,10 C17.7721047,10 18,10.2197146 18,10.5089948 L18,5.49100518 C18,5.78328929 17.7775792,6 17.5096495,6 L26.4903505,6 Z M5,13.4982674 L5,26.5017326 C5,26.7769181 5.21990657,27 5.49826741,27 L18.5017326,27 C18.7769181,27 19,26.7800934 19,26.5017326 L19,13.4982674 C19,13.2230819 18.7800934,13 18.5017326,13 L5.49826741,13 C5.22308192,13 5,13.2199066 5,13.4982674 Z M5,5.49100518 L5,10.5089948 C5,10.7801695 5.22765279,11 5.50964952,11 L14.4903505,11 C14.7718221,11 15,10.7721195 15,10.5089948 L15,5.49100518 C15,5.21983051 14.7723472,5 14.4903505,5 L5.50964952,5 C5.22817786,5 5,5.22788048 5,5.49100518 Z M21,21.4910052 L21,26.5089948 C21,26.7801695 21.2278805,27 21.4910052,27 L26.5089948,27 C26.7801695,27 27,26.7721195 27,26.5089948 L27,21.4910052 C27,21.2198305 26.7721195,21 26.5089948,21 L21.4910052,21 C21.2198305,21 21,21.2278805 21,21.4910052 Z M21,13.4910052 L21,18.5089948 C21,18.7801695 21.2278805,19 21.4910052,19 L26.5089948,19 C26.7801695,19 27,18.7721195 27,18.5089948 L27,13.4910052 C27,13.2198305 26.7721195,13 26.5089948,13 L21.4910052,13 C21.2198305,13 21,13.2278805 21,13.4910052 Z',
distribution: 'M1.457 4.731v21.807h29.815a.73.73 0 0 1 .728.73.73.73 0 0 1-.728.732H0V4.731A.73.73 0 0 1 .728 4a.73.73 0 0 1 .729.731zM5.795 21.53a1.824 1.824 0 0 1-1.82-1.828c0-1.01.814-1.828 1.82-1.828 2.094 0 2.965-1.21 4.205-5.255l.147-.484c1.609-5.271 2.99-7.353 6.779-7.353 3.792 0 5.17 2.084 6.765 7.362l.145.48c1.227 4.043 2.093 5.25 4.181 5.25 1.006 0 1.821.819 1.821 1.828 0 1.01-.815 1.828-1.82 1.828-4.305 0-6.005-2.37-7.666-7.841l-.146-.483c-1.14-3.77-1.8-4.769-3.28-4.769-1.483 0-2.147 1-3.297 4.769l-.148.487c-1.675 5.469-3.382 7.837-7.686 7.837z',
document: 'M29,10.1052632 L29,28.8325291 C29,30.581875 27.5842615,32 25.8337327,32 L7.16626728,32 C5.41758615,32 4,30.5837102 4,28.8441405 L4,3.15585953 C4,1.41292644 5.42339685,9.39605581e-15 7.15970573,8.42009882e-15 L20.713352,8.01767853e-16 L20.713352,8.42105263 L22.3846872,8.42105263 L22.3846872,0.310375032 L28.7849894,8.42105263 L20.713352,8.42105263 L20.713352,10.1052632 L29,10.1052632 Z M7.3426704,12.8000006 L25.7273576,12.8000006 L25.7273576,14.4842112 L7.3426704,14.4842112 L7.3426704,12.8000006 Z M7.3426704,17.3473687 L25.7273576,17.3473687 L25.7273576,19.0315793 L7.3426704,19.0315793 L7.3426704,17.3473687 Z M7.3426704,21.8947352 L25.7273576,21.8947352 L25.7273576,23.5789458 L7.3426704,23.5789458 L7.3426704,21.8947352 Z M7.43137255,26.2736849 L16.535014,26.2736849 L16.535014,27.9578954 L7.43137255,27.9578954 L7.43137255,26.2736849 Z',
downarrow: 'M12.2782161,19.3207547 L12.2782161,0 L19.5564322,0 L19.5564322,19.3207547 L26.8346484,19.3207547 L15.9173242,32 L5,19.3207547 L12.2782161,19.3207547 Z',
download: {
......@@ -92,6 +94,15 @@ export var ICON_PATHS = {
},
funnel: 'M3.18586974,3.64621479 C2.93075885,3.28932022 3.08031197,3 3.5066208,3 L28.3780937,3 C28.9190521,3 29.0903676,3.34981042 28.7617813,3.77995708 L18.969764,16.5985181 L18.969764,24.3460671 C18.969764,24.8899179 18.5885804,25.5564176 18.133063,25.8254534 C18.133063,25.8254534 12.5698889,29.1260709 12.5673818,28.9963552 C12.4993555,25.4767507 12.5749031,16.7812673 12.5749031,16.7812673 L3.18586974,3.64621479 Z',
funneladd: 'M22.5185184,5.27947653 L17.2510286,5.27947653 L17.2510286,9.50305775 L22.5185184,9.50305775 L22.5185184,14.7825343 L26.7325102,14.7825343 L26.7325102,9.50305775 L32,9.50305775 L32,5.27947653 L26.7325102,5.27947653 L26.7325102,0 L22.5185184,0 L22.5185184,5.27947653 Z M14.9369872,0.791920724 C14.9369872,0.791920724 2.77552871,0.83493892 1.86648164,0.83493892 C0.957434558,0.83493892 0.45215388,1.50534608 0.284450368,1.77831828 C0.116746855,2.05129048 -0.317642562,2.91298361 0.398382661,3.9688628 C1.11440788,5.024742 9.74577378,17.8573356 9.74577378,17.8573356 C9.74577378,17.8573356 9.74577394,28.8183645 9.74577378,29.6867194 C9.74577362,30.5550744 9.83306175,31.1834301 10.7557323,31.6997692 C11.6784029,32.2161084 12.4343349,31.9564284 12.7764933,31.7333621 C13.1186517,31.5102958 19.6904355,27.7639669 20.095528,27.4682772 C20.5006204,27.1725875 20.7969652,26.5522071 20.7969651,25.7441659 C20.7969649,24.9361247 20.7969651,18.2224765 20.7969651,18.2224765 L21.6163131,16.9859755 L18.152048,15.0670739 C18.152048,15.0670739 17.3822517,16.199685 17.2562629,16.4000338 C17.1302741,16.6003826 16.8393552,16.9992676 16.8393551,17.7062886 C16.8393549,18.4133095 16.8393551,24.9049733 16.8393551,24.9049733 L13.7519708,26.8089871 C13.7519708,26.8089871 13.7318369,18.3502323 13.7318367,17.820601 C13.7318366,17.2909696 13.8484216,16.6759061 13.2410236,15.87149 C12.6336257,15.0670739 5.59381579,4.76288686 5.59381579,4.76288686 L14.9359238,4.76288686 L14.9369872,0.791920724 Z',
funneloutline: {
path: 'M3.186 3.646C2.93 3.29 3.08 3 3.506 3h24.872c.541 0 .712.35.384.78L18.97 16.599v7.747c0 .544-.381 1.21-.837 1.48 0 0-5.563 3.3-5.566 3.17-.068-3.52.008-12.215.008-12.215L3.185 3.646z',
attrs: {
stroke: "currentcolor",
strokeWidth: "4",
fill: "none",
fillRule: "evenodd"
}
},
folder: "M3.96901618e-15,5.41206355 L0.00949677904,29 L31.8821132,29 L31.8821132,10.8928571 L18.2224205,10.8928571 L15.0267944,5.41206355 L3.96901618e-15,5.41206355 Z M16.8832349,5.42402804 L16.8832349,4.52140947 C16.8832349,3.68115822 17.5639241,3 18.4024298,3 L27.7543992,3 L30.36417,3 C31.2031259,3 31.8832341,3.67669375 31.8832341,4.51317691 L31.8832341,7.86669975 L31.8832349,8.5999999 L18.793039,8.5999999 L16.8832349,5.42402804 Z",
gear: 'M14 0 H18 L19 6 L20.707 6.707 L26 3.293 L28.707 6 L25.293 11.293 L26 13 L32 14 V18 L26 19 L25.293 20.707 L28.707 26 L26 28.707 L20.707 25.293 L19 26 L18 32 L14 32 L13 26 L11.293 25.293 L6 28.707 L3.293 26 L6.707 20.707 L6 19 L0 18 L0 14 L6 13 L6.707 11.293 L3.293 6 L6 3.293 L11.293 6.707 L13 6 L14 0 z M16 10 A6 6 0 0 0 16 22 A6 6 0 0 0 16 10',
grabber: 'M0,5 L32,5 L32,9.26666667 L0,9.26666667 L0,5 Z M0,13.5333333 L32,13.5333333 L32,17.8 L0,17.8 L0,13.5333333 Z M0,22.0666667 L32,22.0666667 L32,26.3333333 L0,26.3333333 L0,22.0666667 Z',
......@@ -150,6 +161,8 @@ export var ICON_PATHS = {
path: 'M0 11.996A3.998 3.998 0 0 1 4.004 8h23.992A4 4 0 0 1 32 11.996v8.008A3.998 3.998 0 0 1 27.996 24H4.004A4 4 0 0 1 0 20.004v-8.008zM22 11h3.99A3.008 3.008 0 0 1 29 14v4c0 1.657-1.35 3-3.01 3H22V11z',
attrs: { fillRule: 'evenodd' }
},
sort: 'M14.615.683c.765-.926 2.002-.93 2.77 0L26.39 11.59c.765.927.419 1.678-.788 1.678H6.398c-1.2 0-1.557-.747-.788-1.678L14.615.683zm2.472 30.774c-.6.727-1.578.721-2.174 0l-9.602-11.63c-.6-.727-.303-1.316.645-1.316h20.088c.956 0 1.24.595.645 1.316l-9.602 11.63z',
sum: 'M3 27.41l1.984 4.422L27.895 32l.04-5.33-17.086-.125 8.296-9.457-.08-3.602L11.25 5.33H27.43V0H5.003L3.08 4.51l10.448 10.9z',
sync: 'M16 2 A14 14 0 0 0 2 16 A14 14 0 0 0 16 30 A14 14 0 0 0 26 26 L 23.25 23 A10 10 0 0 1 16 26 A10 10 0 0 1 6 16 A10 10 0 0 1 16 6 A10 10 0 0 1 23.25 9 L19 13 L30 13 L30 2 L26 6 A14 14 0 0 0 16 2',
question: "M16,32 C24.836556,32 32,24.836556 32,16 C32,7.163444 24.836556,0 16,0 C7.163444,0 0,7.163444 0,16 C0,24.836556 7.163444,32 16,32 L16,32 Z M16,29.0909091 C8.77009055,29.0909091 2.90909091,23.2299095 2.90909091,16 C2.90909091,8.77009055 8.77009055,2.90909091 16,2.90909091 C23.2299095,2.90909091 29.0909091,8.77009055 29.0909091,16 C29.0909091,23.2299095 23.2299095,29.0909091 16,29.0909091 Z M12,9.56020942 C12.2727286,9.34380346 12.5694087,9.1413622 12.8900491,8.95287958 C13.2106896,8.76439696 13.5552807,8.59860455 13.9238329,8.45549738 C14.2923851,8.31239021 14.6885728,8.20069848 15.1124079,8.12041885 C15.5362429,8.04013921 15.9950835,8 16.4889435,8 C17.1818216,8 17.8065083,8.08725916 18.3630221,8.2617801 C18.919536,8.43630105 19.3931184,8.68586225 19.7837838,9.0104712 C20.1744491,9.33508016 20.4748147,9.7260012 20.6848894,10.1832461 C20.8949642,10.6404909 21,11.1483393 21,11.7068063 C21,12.2373499 20.9226052,12.6963331 20.7678133,13.0837696 C20.6130213,13.4712061 20.4176916,13.8080265 20.1818182,14.0942408 C19.9459448,14.3804552 19.6861194,14.6282712 19.4023342,14.8376963 C19.1185489,15.0471215 18.8495099,15.2408368 18.5952088,15.4188482 C18.3409078,15.5968595 18.1197798,15.773123 17.9318182,15.947644 C17.7438566,16.1221649 17.6240789,16.3176254 17.5724816,16.5340314 L17.2628993,18 L14.9189189,18 L14.6756757,16.3141361 C14.6167073,15.9720751 14.653562,15.6736487 14.7862408,15.4188482 C14.9189196,15.1640476 15.1013502,14.9336834 15.3335381,14.7277487 C15.565726,14.521814 15.8255514,14.3263535 16.1130221,14.1413613 C16.4004928,13.9563691 16.6695319,13.7574182 16.9201474,13.5445026 C17.1707629,13.3315871 17.3826773,13.0942421 17.5558968,12.8324607 C17.7291163,12.5706793 17.8157248,12.2582915 17.8157248,11.895288 C17.8157248,11.4764377 17.6701489,11.1431077 17.3789926,10.895288 C17.0878364,10.6474682 16.6879632,10.5235602 16.1793612,10.5235602 C15.7886958,10.5235602 15.462532,10.5619542 15.20086,10.6387435 C14.9391879,10.7155327 14.7143744,10.8010466 14.5264128,10.895288 C14.3384511,10.9895293 14.1744479,11.0750432 14.034398,11.1518325 C13.8943482,11.2286217 13.7543005,11.2670157 13.6142506,11.2670157 C13.2972957,11.2670157 13.0614258,11.1378721 12.9066339,10.8795812 L12,9.56020942 Z M14,22 C14,21.7192968 14.0511359,21.4580909 14.1534091,21.2163743 C14.2556823,20.9746577 14.3958324,20.7641335 14.5738636,20.5847953 C14.7518948,20.4054572 14.96212,20.2631584 15.2045455,20.1578947 C15.4469709,20.0526311 15.7121198,20 16,20 C16.2803044,20 16.5416655,20.0526311 16.7840909,20.1578947 C17.0265164,20.2631584 17.2386355,20.4054572 17.4204545,20.5847953 C17.6022736,20.7641335 17.7443177,20.9746577 17.8465909,21.2163743 C17.9488641,21.4580909 18,21.7192968 18,22 C18,22.2807032 17.9488641,22.5438584 17.8465909,22.7894737 C17.7443177,23.0350889 17.6022736,23.2475625 17.4204545,23.4269006 C17.2386355,23.6062387 17.0265164,23.7465882 16.7840909,23.8479532 C16.5416655,23.9493182 16.2803044,24 16,24 C15.7121198,24 15.4469709,23.9493182 15.2045455,23.8479532 C14.96212,23.7465882 14.7518948,23.6062387 14.5738636,23.4269006 C14.3958324,23.2475625 14.2556823,23.0350889 14.1534091,22.7894737 C14.0511359,22.5438584 14,22.2807032 14,22 Z",
return:'M15.3040432,11.8500793 C22.1434689,13.0450349 27.291257,18.2496116 27.291257,24.4890512 C27.291257,25.7084278 27.0946472,26.8882798 26.7272246,28.0064033 L26.7272246,28.0064033 C25.214579,22.4825472 20.8068367,18.2141694 15.3040432,17.0604596 L15.3040432,25.1841972 L4.70874296,14.5888969 L15.3040432,3.99359668 L15.3040432,3.99359668 L15.3040432,11.8500793 Z',
......@@ -192,6 +205,7 @@ export var ICON_PATHS = {
attrs: { fillRule: "evenodd" }
},
x: 'm11.271709,16 l-3.19744231e-13,4.728291 l4.728291,0 l16,11.271709 l27.271709,2.39808173e-13 l32,4.728291 l20.728291,16 l31.1615012,26.4332102 l26.4332102,31.1615012 l16,20.728291 l5.56678976,31.1615012 l0.838498756,26.4332102 l11.271709,16 z',
zoom: 'M12.416 12.454V8.37h3.256v4.083h4.07v3.266h-4.07v4.083h-3.256V15.72h-4.07v-3.266h4.07zm10.389 13.28c-5.582 4.178-13.543 3.718-18.632-1.37-5.58-5.581-5.595-14.615-.031-20.179 5.563-5.563 14.597-5.55 20.178.031 5.068 5.068 5.545 12.985 1.422 18.563l5.661 5.661a2.08 2.08 0 0 1 .003 2.949 2.085 2.085 0 0 1-2.95-.003l-5.651-5.652zm-1.486-4.371c3.895-3.895 3.885-10.218-.021-14.125-3.906-3.906-10.23-3.916-14.125-.021-3.894 3.894-3.885 10.218.022 14.124 3.906 3.907 10.23 3.916 14.124.022z',
"slack": {
img: "/app/img/slack.png"
}
......
......@@ -5,6 +5,7 @@
import type { Table } from "metabase/meta/types/Table";
import type { Field } from "metabase/meta/types/Field";
import type { Segment } from "metabase/meta/types/Segment";
import type { Metric } from "metabase/meta/types/Metric";
export type FieldValue = {
name: string,
......@@ -50,8 +51,9 @@ export type BreakoutOptions = {
}
export type TableMetadata = Table & {
segments: Segment[],
fields: FieldMetadata[],
segments: Segment[],
metrics: Metric[],
aggregation_options: AggregationOption[],
breakout_options: BreakoutOptions
}
......
/* @flow */
import type { TableId } from "./Table";
export type MetricId = number;
// TODO: incomplete
export type Metric = {
name: string,
id: MetricId,
table_id: TableId,
is_active: bool
};
......@@ -3,10 +3,9 @@
import type { TableId } from "./Table";
import type { FieldId } from "./Field";
import type { SegmentId } from "./Segment";
import type { MetricId } from "./Metric";
import type { ParameterType } from "./Parameter";
export type MetricId = number;
export type ExpressionName = string;
export type StringLiteral = string;
......@@ -77,7 +76,8 @@ type StdDevAgg = ["stddev", ConcreteField];
type SumAgg = ["sum", ConcreteField];
type MinAgg = ["min", ConcreteField];
type MaxAgg = ["max", ConcreteField];
type MetricAgg = ["metric", MetricId];
// NOTE: currently the backend expects METRIC to be uppercase
type MetricAgg = ["METRIC", MetricId];
export type BreakoutClause = Array<Breakout>;
export type Breakout =
......@@ -115,7 +115,8 @@ export type NotNullFilter = ["not-null", ConcreteField];
export type InsideFilter = ["inside", ConcreteField, ConcreteField, NumericLiteral, NumericLiteral, NumericLiteral, NumericLiteral];
export type TimeIntervalFilter = ["time-interval", ConcreteField, RelativeDatetimePeriod, RelativeDatetimeUnit];
export type SegmentFilter = ["segment", SegmentId];
// NOTE: currently the backend expects SEGMENT to be uppercase
export type SegmentFilter = ["SEGMENT", SegmentId];
export type OrderByClause = Array<OrderBy>;
export type OrderBy = ["asc"|"desc", Field];
......
......@@ -4,7 +4,7 @@ import type { DatasetData, Column } from "metabase/meta/types/Dataset";
import type { Card, VisualizationSettings } from "metabase/meta/types/Card";
import type { TableMetadata } from "metabase/meta/types/Metadata";
export type ActionCreator = (props: ClickActionProps) => ?ClickAction
export type ActionCreator = (props: ClickActionProps) => ClickAction[]
export type QueryMode = {
name: string,
......
import React, { Component } from "react";
import querystring from "querystring";
import _ from "underscore";
const OPTION_NAMES = ["bordered"];
export default class MetabaseEmbed extends Component {
render() {
let { className, style, url } = this.props;
let options = querystring.stringify(_.pick(this.props, ...OPTION_NAMES));
if (options) {
url += "#" + options;
}
return (
<iframe
src={url}
className={className}
style={{ backgroundColor: "transparent", ...style }}
frameBorder={0}
allowTransparency
/>
);
}
}
......@@ -121,12 +121,12 @@ export default class TimeseriesFilterWidget extends Component<*, Props, State> {
sizeToFit
>
<DatePicker
className="mt2"
filter={this.state.filter}
onFilterChange={newFilter => {
this.setState({ filter: newFilter });
}}
tableMetadata={tableMetadata}
includeAllTime
/>
<div className="p1">
<Button
......
/* eslint-disable flowtype/require-valid-file-annotation */
import { TYPE } from "metabase/lib/types";
const FLOAT_FIELD = {
id: 1,
display_name: "Mock Float Field",
base_type: TYPE.Float
};
const CATEGORY_FIELD = {
id: 2,
display_name: "Mock Category Field",
base_type: TYPE.Text,
special_type: TYPE.Category
};
const DATE_FIELD = {
id: 3,
display_name: "Mock Date Field",
base_type: TYPE.DateTime
};
const PK_FIELD = {
id: 4,
display_name: "Mock PK Field",
base_type: TYPE.Integer,
special_type: TYPE.PK
};
const foreignTableMetadata = {
id: 20,
db_id: 100,
display_name: "Mock Foreign Table",
fields: []
};
const FK_FIELD = {
id: 5,
display_name: "Mock FK Field",
base_type: TYPE.Integer,
special_type: TYPE.FK,
target: {
id: 25,
table_id: foreignTableMetadata.id,
table: foreignTableMetadata
}
};
export const tableMetadata = {
id: 10,
db_id: 100,
display_name: "Mock Table",
fields: [FLOAT_FIELD, CATEGORY_FIELD, DATE_FIELD, PK_FIELD, FK_FIELD]
};
export const card = {
dataset_query: {
type: "query",
query: {
source_table: 10
}
}
};
export const clickedFloatHeader = {
column: {
...FLOAT_FIELD,
source: "fields"
}
};
export const clickedCategoryHeader = {
column: {
...CATEGORY_FIELD,
source: "fields"
}
};
export const clickedFloatValue = {
column: {
...CATEGORY_FIELD,
source: "fields"
},
value: 1234
};
export const clickedPKValue = {
column: {
...PK_FIELD,
source: "fields"
},
value: 42
};
export const clickedFKValue = {
column: {
...FK_FIELD,
source: "fields"
},
value: 43
};
/* @flow */
import React from "react";
import type {
ClickAction,
ClickActionProps
} from "metabase/meta/types/Visualization";
import { summarize } from "metabase/qb/lib/actions";
export default ({ card, tableMetadata }: ClickActionProps): ClickAction[] => {
return tableMetadata.metrics.slice(0, 5).map(metric => ({
title: <span>View <strong>{metric.name}</strong></span>,
card: () => summarize(card, ["METRIC", metric.id], tableMetadata)
}));
};
/* eslint-disable flowtype/require-valid-file-annotation */
import CommonMetricsAction from "./CommonMetricsAction";
import { card, tableMetadata } from "../__support__/fixtures";
const mockMetric = {
id: 123,
table_id: 10,
name: "Mock Metric"
};
const tableMetadata0Metrics = { ...tableMetadata, metrics: [] };
const tableMetadata1Metric = { ...tableMetadata, metrics: [mockMetric] };
const tableMetadata6Metrics = {
...tableMetadata,
metrics: [
mockMetric,
mockMetric,
mockMetric,
mockMetric,
mockMetric,
mockMetric
]
};
describe("CommonMetricsAction", () => {
it("should not be valid if the table has no metrics", () => {
expect(
CommonMetricsAction({
card,
tableMetadata: tableMetadata0Metrics
})
).toHaveLength(0);
});
it("should return a scalar card for the metric", () => {
const actions = CommonMetricsAction({
card,
tableMetadata: tableMetadata1Metric
});
expect(actions).toHaveLength(1);
const newCard = actions[0].card();
expect(newCard.dataset_query.query).toEqual({
source_table: 10,
aggregation: [["METRIC", 123]]
});
expect(newCard.display).toEqual("scalar");
});
it("should only return up to 5 actions", () => {
expect(
CommonMetricsAction({
card,
tableMetadata: tableMetadata6Metrics
})
).toHaveLength(5);
});
});
/* @flow */
import React from "react";
import type {
ClickAction,
ClickActionProps
} from "metabase/meta/types/Visualization";
import { isDate } from "metabase/lib/schema_metadata";
import { summarize, breakout } from "metabase/qb/lib/actions";
export default ({ card, tableMetadata }: ClickActionProps): ClickAction[] => {
const dateField = tableMetadata.fields.filter(isDate)[0];
if (!dateField) {
return [];
}
return [
{
title: <span>Count of rows by time</span>,
card: () =>
breakout(
summarize(card, ["count"], tableMetadata),
["datetime-field", ["field-id", dateField.id], "as", "day"],
tableMetadata
)
}
];
};
/* eslint-disable flowtype/require-valid-file-annotation */
import CountByTimeAction from "./CountByTimeAction";
import { card, tableMetadata } from "../__support__/fixtures";
const tableMetadata0TimeFields = { ...tableMetadata, fields: [] };
const tableMetadata1TimeField = tableMetadata;
describe("CountByTimeAction", () => {
it("should not be valid if the table has no metrics", () => {
expect(
CountByTimeAction({
card,
tableMetadata: tableMetadata0TimeFields
})
).toHaveLength(0);
});
it("should return a scalar card for the metric", () => {
const actions = CountByTimeAction({
card,
tableMetadata: tableMetadata1TimeField
});
expect(actions).toHaveLength(1);
const newCard = actions[0].card();
expect(newCard.dataset_query.query).toEqual({
source_table: 10,
aggregation: [["count"]],
breakout: [["datetime-field", ["field-id", 3], "as", "day"]]
});
expect(newCard.display).toEqual("line");
});
});
......@@ -20,7 +20,7 @@ type FieldFilter = (field: Field) => boolean;
// PivotByAction displays a breakout picker, and optionally filters by the
// clicked dimesion values (and removes corresponding breakouts)
export default (name: string, icon: string, fieldFilter: FieldFilter) =>
({ card, tableMetadata, clicked }: ClickActionProps): ?ClickAction => {
({ card, tableMetadata, clicked }: ClickActionProps): ClickAction[] => {
const query = Card.getQuery(card);
// Click target types: metric value
......@@ -31,7 +31,7 @@ export default (name: string, icon: string, fieldFilter: FieldFilter) =>
(clicked.value === undefined ||
clicked.column.source !== "aggregation"))
) {
return;
return [];
}
let dimensions = (clicked && clicked.dimensions) || [];
......@@ -61,33 +61,38 @@ export default (name: string, icon: string, fieldFilter: FieldFilter) =>
const customFieldOptions = Query.getExpressions(query);
if (fieldOptions.count === 0) {
return null;
return [];
}
return {
title: (
<span>
Pivot by
{" "}
<span className="text-dark">{name.toLowerCase()}</span>
</span>
),
icon: icon,
// eslint-disable-next-line react/display-name
popover: (
{ onChangeCardAndRun, onClose }: ClickActionPopoverProps
) => (
<BreakoutPopover
tableMetadata={tableMetadata}
fieldOptions={fieldOptions}
customFieldOptions={customFieldOptions}
onCommitBreakout={breakout => {
onChangeCardAndRun(
pivot(card, breakout, tableMetadata, dimensions)
);
}}
onClose={onClose}
/>
)
};
return [
{
section: "breakout",
title: clicked
? name
: <span>
Pivot by
{" "}
<span className="text-dark">
{name.toLowerCase()}
</span>
</span>,
icon: icon,
// eslint-disable-next-line react/display-name
popover: (
{ onChangeCardAndRun, onClose }: ClickActionPopoverProps
) => (
<BreakoutPopover
tableMetadata={tableMetadata}
fieldOptions={fieldOptions}
customFieldOptions={customFieldOptions}
onCommitBreakout={breakout => {
onChangeCardAndRun(
pivot(card, breakout, tableMetadata, dimensions)
);
}}
onClose={onClose}
/>
)
}
];
};
......@@ -7,13 +7,15 @@ import type {
ClickActionProps
} from "metabase/meta/types/Visualization";
export default ({ card, tableMetadata }: ClickActionProps): ?ClickAction => {
export default ({ card, tableMetadata }: ClickActionProps): ClickAction[] => {
if (card.display !== "table") {
return;
return [];
}
return {
title: "Plot a field in this segment",
icon: "bar",
card: () => plotSegmentField(card)
};
return [
{
title: "Plot a field in this segment",
icon: "bar",
card: () => plotSegmentField(card)
}
];
};
......@@ -14,28 +14,32 @@ import type {
ClickActionPopoverProps
} from "metabase/meta/types/Visualization";
export default ({ card, tableMetadata }: ClickActionProps): ?ClickAction => {
export default ({ card, tableMetadata }: ClickActionProps): ClickAction[] => {
const query = Card.getQuery(card);
if (!query) {
return;
return [];
}
return {
title: "Summarize this segment",
icon: "funnel", // FIXME: icon
// eslint-disable-next-line react/display-name
popover: ({ onChangeCardAndRun, onClose }: ClickActionPopoverProps) => (
<AggregationPopover
tableMetadata={tableMetadata}
customFields={Query.getExpressions(query)}
availableAggregations={tableMetadata.aggregation_options}
onCommitAggregation={aggregation => {
onChangeCardAndRun(
summarize(card, aggregation, tableMetadata)
);
onClose && onClose();
}}
/>
)
};
return [
{
title: "Summarize this segment",
icon: "funnel", // FIXME: icon
// eslint-disable-next-line react/display-name
popover: (
{ onChangeCardAndRun, onClose }: ClickActionPopoverProps
) => (
<AggregationPopover
tableMetadata={tableMetadata}
customFields={Query.getExpressions(query)}
availableAggregations={tableMetadata.aggregation_options}
onCommitAggregation={aggregation => {
onChangeCardAndRun(
summarize(card, aggregation, tableMetadata)
);
onClose && onClose();
}}
/>
)
}
];
};
......@@ -2,14 +2,20 @@
import { toUnderlyingData } from "metabase/qb/lib/actions";
import type { ClickActionProps } from "metabase/meta/types/Visualization";
import type {
ClickAction,
ClickActionProps
} from "metabase/meta/types/Visualization";
export default ({ card, tableMetadata }: ClickActionProps) => {
export default ({ card, tableMetadata }: ClickActionProps): ClickAction[] => {
if (card.display !== "table" && card.display !== "scalar") {
return {
title: "View the underlying data",
icon: "table",
card: () => toUnderlyingData(card)
};
return [
{
title: "View the underlying data",
icon: "table",
card: () => toUnderlyingData(card)
}
];
}
return [];
};
......@@ -6,28 +6,31 @@ import { toUnderlyingRecords } from "metabase/qb/lib/actions";
import * as Query from "metabase/lib/query/query";
import * as Card from "metabase/meta/Card";
import type { ClickActionProps } from "metabase/meta/types/Visualization";
import type {
ClickAction,
ClickActionProps
} from "metabase/meta/types/Visualization";
export default ({ card, tableMetadata }: ClickActionProps) => {
export default ({ card, tableMetadata }: ClickActionProps): ClickAction[] => {
const query = Card.getQuery(card);
if (!query) {
return;
}
if (!Query.isBareRows(query)) {
return {
title: (
<span>
View the underlying
{" "}
<span className="text-dark">
{tableMetadata.display_name}
if (query && !Query.isBareRows(query)) {
return [
{
title: (
<span>
View the underlying
{" "}
<span className="text-dark">
{tableMetadata.display_name}
</span>
{" "}
records
</span>
{" "}
records
</span>
),
icon: "table",
card: () => toUnderlyingRecords(card)
};
),
icon: "table",
card: () => toUnderlyingRecords(card)
}
];
}
return [];
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment