diff --git a/public/app/core/components/PageHeader/PageHeader.tsx b/public/app/core/components/PageHeader/PageHeader.tsx
index da8dfb2b95c..8253d5c671f 100644
--- a/public/app/core/components/PageHeader/PageHeader.tsx
+++ b/public/app/core/components/PageHeader/PageHeader.tsx
@@ -9,8 +9,12 @@ export interface Props {
model: NavModel;
}
-const SelectNav = ({ main, customCss }: { main: NavModelItem; customCss: string }) => {
- const defaultSelectedItem = main.children.find(navItem => {
+const SelectNav = ({ children, customCss }: { children: NavModelItem[]; customCss: string }) => {
+ if (!children || children.length === 0) {
+ return null;
+ }
+
+ const defaultSelectedItem = children.find(navItem => {
return navItem.active === true;
});
@@ -22,15 +26,18 @@ const SelectNav = ({ main, customCss }: { main: NavModelItem; customCss: string
return (
-
+
{/* Label to make it clickable */}
@@ -146,13 +157,14 @@ export default class PageHeader extends React.Component {
}
const main = model.main;
+ const children = main.children;
return (
{this.renderHeaderTitle(main)}
- {main.children && }
+ {children && children.length && }
diff --git a/public/app/core/components/PermissionList/AddPermission.tsx b/public/app/core/components/PermissionList/AddPermission.tsx
index faeed7c22b1..dc787ee9c86 100644
--- a/public/app/core/components/PermissionList/AddPermission.tsx
+++ b/public/app/core/components/PermissionList/AddPermission.tsx
@@ -64,7 +64,7 @@ class AddPermissions extends Component {
};
onPermissionChanged = (permission: SelectableValue) => {
- this.setState({ permission: permission.value });
+ this.setState({ permission: permission!.value });
};
onSubmit = async (evt: React.SyntheticEvent) => {
diff --git a/public/app/core/components/PermissionList/PermissionListItem.tsx b/public/app/core/components/PermissionList/PermissionListItem.tsx
index 9d0e449e8c8..753ee0f3ca5 100644
--- a/public/app/core/components/PermissionList/PermissionListItem.tsx
+++ b/public/app/core/components/PermissionList/PermissionListItem.tsx
@@ -42,7 +42,7 @@ interface Props {
export default class PermissionsListItem extends PureComponent {
onPermissionChanged = (option: SelectableValue) => {
- this.props.onPermissionChanged(this.props.item, option.value);
+ this.props.onPermissionChanged(this.props.item, option!.value);
};
onRemoveItem = () => {
@@ -55,7 +55,7 @@ export default class PermissionsListItem extends PureComponent {
const currentPermissionLevel = dashboardPermissionLevels.find(dp => dp.value === item.permission);
return (
-
+
|
|
diff --git a/public/app/core/components/Select/MetricSelect.tsx b/public/app/core/components/Select/MetricSelect.tsx
index cb982302dbd..a726e470ac0 100644
--- a/public/app/core/components/Select/MetricSelect.tsx
+++ b/public/app/core/components/Select/MetricSelect.tsx
@@ -37,7 +37,7 @@ export class MetricSelect extends React.Component {
}
UNSAFE_componentWillReceiveProps(nextProps: Props) {
- if (nextProps.options.length > 0 || nextProps.variables.length) {
+ if (nextProps.options.length > 0 || nextProps.variables?.length) {
this.setState({ options: this.buildOptions(nextProps) });
}
}
@@ -54,7 +54,7 @@ export class MetricSelect extends React.Component {
getVariablesGroup() {
return {
label: 'Template Variables',
- options: this.props.variables.map(v => ({
+ options: this.props.variables?.map(v => ({
label: `$${v.name}`,
value: `$${v.name}`,
})),
@@ -77,7 +77,7 @@ export class MetricSelect extends React.Component {
isMulti={false}
isClearable={false}
backspaceRemovesValue={false}
- onChange={item => onChange(item.value)}
+ onChange={item => onChange(item.value ?? '')}
options={options}
isSearchable={isSearchable}
maxMenuHeight={500}
diff --git a/public/app/core/utils/flatten.ts b/public/app/core/utils/flatten.ts
index da833e7a8fd..629bb2a1e3f 100644
--- a/public/app/core/utils/flatten.ts
+++ b/public/app/core/utils/flatten.ts
@@ -9,16 +9,16 @@ export default function flatten(target: object, opts?: { delimiter?: any; maxDep
let currentDepth = 1;
const output: any = {};
- function step(object: any, prev: string) {
+ function step(object: any, prev: string | null) {
Object.keys(object).forEach(key => {
const value = object[key];
- const isarray = opts.safe && Array.isArray(value);
+ const isarray = opts?.safe && Array.isArray(value);
const type = Object.prototype.toString.call(value);
const isobject = type === '[object Object]';
const newKey = prev ? prev + delimiter + key : key;
- if (!opts.maxDepth) {
+ if (!opts?.maxDepth) {
maxDepth = currentDepth + 1;
}
diff --git a/public/app/plugins/datasource/loki/datasource.ts b/public/app/plugins/datasource/loki/datasource.ts
index cf9928f1adb..eebd2908408 100644
--- a/public/app/plugins/datasource/loki/datasource.ts
+++ b/public/app/plugins/datasource/loki/datasource.ts
@@ -69,7 +69,7 @@ export class LokiDatasource extends DataSourceApi {
this.languageProvider = new LanguageProvider(this);
const settingsData = instanceSettings.jsonData || {};
- this.maxLines = parseInt(settingsData.maxLines, 10) || DEFAULT_MAX_LINES;
+ this.maxLines = parseInt(settingsData.maxLines ?? '0', 10) || DEFAULT_MAX_LINES;
}
_request(apiUrl: string, data?: any, options?: DatasourceRequestOptions): Observable> {
diff --git a/public/app/plugins/datasource/loki/language_provider.ts b/public/app/plugins/datasource/loki/language_provider.ts
index 002f4dc3a8b..6a4865c8387 100644
--- a/public/app/plugins/datasource/loki/language_provider.ts
+++ b/public/app/plugins/datasource/loki/language_provider.ts
@@ -56,7 +56,7 @@ export function addHistoryMetadata(item: CompletionItem, history: LokiHistoryIte
}
export default class LokiLanguageProvider extends LanguageProvider {
- labelKeys?: string[];
+ labelKeys: string[];
logLabelOptions: any[];
logLabelFetchTs?: number;
started: boolean;
@@ -129,7 +129,7 @@ export default class LokiLanguageProvider extends LanguageProvider {
const { wrapperClasses, value, prefix, text } = input;
// Local text properties
- const empty = value.document.text.length === 0;
+ const empty = value?.document.text.length === 0;
const selectedLines = value.document.getTextsAtRange(value.selection);
const currentLine = selectedLines.size === 1 ? selectedLines.first().getText() : null;
@@ -235,6 +235,9 @@ export default class LokiLanguageProvider extends LanguageProvider {
): Promise {
let context = 'context-labels';
const suggestions: CompletionItemGroup[] = [];
+ if (!value) {
+ return { context, suggestions: [] };
+ }
const line = value.anchorBlock.getText();
const cursorOffset = value.selection.anchor.offset;
const isValueStart = text.match(/^(=|=~|!=|!~)/);
@@ -467,7 +470,7 @@ export default class LokiLanguageProvider extends LanguageProvider {
} else {
this.logLabelOptions = this.addLabelValuesToOptions(key, value);
}
- return value;
+ return value ?? [];
}
private addLabelValuesToOptions = (labelKey: string, values: string[]) => {
diff --git a/scripts/ci-frontend-metrics.sh b/scripts/ci-frontend-metrics.sh
index b64406f1042..7167da0978f 100755
--- a/scripts/ci-frontend-metrics.sh
+++ b/scripts/ci-frontend-metrics.sh
@@ -4,7 +4,7 @@ echo -e "Collecting code stats (typescript errors & more)"
-ERROR_COUNT_LIMIT=771
+ERROR_COUNT_LIMIT=728
DIRECTIVES_LIMIT=172
CONTROLLERS_LIMIT=139