Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions superset-frontend/src/SqlLab/actions/Validator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const strategies = {
isNonEmpty(value, errMsg) {
if (value === '') {
return errMsg;
}
},
minLenth(value, length, errMsg) {
if (value.length < length) {
return errMsg;
}
},
isMobile(value, errMsg) {
if (!/^1[3|5|8][0-9]{9}$/.test(value)) {
return errMsg;
}
},
};

export default class Validator {
constructor() {
this.cache = [];
}

add(value, rule, errMsg) {
const arr = rule.split(':');
this.cache.push(() => {
const strategy = arr.shift();
arr.unshift(value);
arr.push(errMsg);
return strategies[strategy](value, errMsg);
});
}

start() {
for (let i = 0; i < this.cache.length; i++) {
const msg = this.cache[i]();
if (msg) return msg;
}
}
}
4 changes: 0 additions & 4 deletions superset-frontend/src/SqlLab/components/SqlEditor/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,21 @@ const StyledToolbar = styled.div`
justify-content: space-between;
border: 1px solid ${({ theme }) => theme.colors.grayscale.light2};
border-top: 0;

form {
margin-block-end: 0;
}

.leftItems,
.rightItems {
display: flex;
align-items: center;
& > span {
margin-right: ${({ theme }) => theme.gridUnit * 2}px;
display: inline-block;

&:last-child {
margin-right: 0;
}
}
}

.limitDropdown {
white-space: nowrap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import Button from 'src/components/Button';
import { t, styled, css, SupersetTheme } from '@superset-ui/core';
import Collapse from 'src/components/Collapse';
import Icons from 'src/components/Icons';
import { TableSelectorMultiple } from 'src/components/TableSelector';
import { TableSelectorMultiple } from 'src/SqlLab/components/TableSelector';
import { IconTooltip } from 'src/components/IconTooltip';
import { QueryEditor, SchemaOption } from 'src/SqlLab/types';
import useQueryEditor from 'src/SqlLab/hooks/useQueryEditor';
Expand Down
Loading