mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Fix strict null errors on getting started (#24605)
* fix strict nulls * fix typings
This commit is contained in:
parent
5f45a039b2
commit
1848900070
@ -3,7 +3,7 @@ import { css } from 'emotion';
|
|||||||
import { GrafanaTheme } from '@grafana/data';
|
import { GrafanaTheme } from '@grafana/data';
|
||||||
import { stylesFactory, useTheme } from '@grafana/ui';
|
import { stylesFactory, useTheme } from '@grafana/ui';
|
||||||
import { TutorialCard } from './TutorialCard';
|
import { TutorialCard } from './TutorialCard';
|
||||||
import { Card, SetupStep } from '../types';
|
import { Card, SetupStep, TutorialCardType } from '../types';
|
||||||
import { DocsCard } from './DocsCard';
|
import { DocsCard } from './DocsCard';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@ -21,10 +21,10 @@ export const Step: FC<Props> = ({ step }) => {
|
|||||||
<p>{step.info}</p>
|
<p>{step.info}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.cards}>
|
<div className={styles.cards}>
|
||||||
{step.cards.map((card: Card, index: number) => {
|
{step.cards.map((card: Card | TutorialCardType, index: number) => {
|
||||||
const key = `${card.title}-${index}`;
|
const key = `${card.title}-${index}`;
|
||||||
if (card.type === 'tutorial') {
|
if (card.type === 'tutorial') {
|
||||||
return <TutorialCard key={key} card={card} />;
|
return <TutorialCard key={key} card={card as TutorialCardType} />;
|
||||||
}
|
}
|
||||||
return <DocsCard key={key} card={card} />;
|
return <DocsCard key={key} card={card} />;
|
||||||
})}
|
})}
|
||||||
|
@ -4,10 +4,10 @@ import { Icon, stylesFactory, useTheme } from '@grafana/ui';
|
|||||||
import { css } from 'emotion';
|
import { css } from 'emotion';
|
||||||
import store from 'app/core/store';
|
import store from 'app/core/store';
|
||||||
import { cardContent, cardStyle, iconStyle } from './sharedStyles';
|
import { cardContent, cardStyle, iconStyle } from './sharedStyles';
|
||||||
import { Card } from '../types';
|
import { TutorialCardType } from '../types';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
card: Card;
|
card: TutorialCardType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TutorialCard: FC<Props> = ({ card }) => {
|
export const TutorialCard: FC<Props> = ({ card }) => {
|
||||||
@ -27,7 +27,7 @@ export const TutorialCard: FC<Props> = ({ card }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTutorialClick = (event: MouseEvent<HTMLAnchorElement>, card: Card) => {
|
const handleTutorialClick = (event: MouseEvent<HTMLAnchorElement>, card: TutorialCardType) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const isSet = store.get(card.key);
|
const isSet = store.get(card.key);
|
||||||
if (!isSet) {
|
if (!isSet) {
|
||||||
|
@ -10,10 +10,13 @@ export interface Card {
|
|||||||
check: () => Promise<boolean>;
|
check: () => Promise<boolean>;
|
||||||
done: boolean;
|
done: boolean;
|
||||||
heading: string;
|
heading: string;
|
||||||
|
learnHref?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TutorialCardType extends Card {
|
||||||
info?: string;
|
info?: string;
|
||||||
// For local storage
|
// For local storage
|
||||||
key?: string;
|
key: string;
|
||||||
learnHref?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SetupStep {
|
export interface SetupStep {
|
||||||
@ -21,6 +24,6 @@ export interface SetupStep {
|
|||||||
subheading: string;
|
subheading: string;
|
||||||
title: string;
|
title: string;
|
||||||
info: string;
|
info: string;
|
||||||
cards: Card[];
|
cards: (Card | TutorialCardType)[];
|
||||||
done: boolean;
|
done: boolean;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user