• /
  • EnglishEspañolFrançais日本語한국어Português
  • Se connecterDémarrer

Cette traduction automatique est fournie pour votre commodité.

En cas d'incohérence entre la version anglaise et la version traduite, la version anglaise prévaudra. Veuillez visiter cette page pour plus d'informations.

Créer un problème

Étapes

Usage

import { Steps } from 'nr1'

Exemples

Étape active par défaut

<Steps defaultValue="monitor-workflows">
<StepsItem label="Add your data" value="add-data" checked>
Connect your data to New Relic and gain insights in 5 minutes.
</StepsItem>
<StepsItem label="Explore your data" value="explore-data" checked>
Traverse your entire stack in one place.
</StepsItem>
<StepsItem label="Monitor critical workflows" value="monitor-workflows">
<Stack
directionType={Stack.DIRECTION_TYPE.VERTICAL}
gapType={Stack.GAP_TYPE.LARGE}
>
<StackItem>
Detect outages and poor performance before your users notice.
</StackItem>
<StackItem>
<Button sizeType={Button.SIZE_TYPE.SMALL}>Learn more</Button>
</StackItem>
</Stack>
</StepsItem>
<StepsItem label="Configure an alert" value="configure-alert">
Configure an alert and we'll tell you when to worry.
</StepsItem>
<StepsItem label="Query your data" value="query-data">
Write your first query in our powerful New Relic Query Language (NRQL).
</StepsItem>
<StepsItem label="Set up a dashboard" value="setup-dashboard">
Create and share dashboards that matter to you and your team.
</StepsItem>
</Steps>

Étapes linéaires

function render() {
const STEP_IDS = {
ACCOUNT: 'ACCOUNT',
CONDITIONS: 'CONDITIONS',
};
const CONDITIONS = [
'Critical Throughput (web)',
'Critical Error rate',
'Critical Response time (web)',
'Critical Background throughput',
];
const CONDITIONS_DESCRIPTION =
'Recommendations based on the number of similar entities using this condition.';
class ConditionCreationSteps extends React.PureComponent {
constructor() {
super(...arguments);
this.state = {
activeStep: STEP_IDS.CONDITIONS,
conditions: [],
invalid: undefined,
};
this._onClickNext = this._onClickNext.bind(this);
}
_onChangeCondition(evt, condition) {
const { checked } = evt.target;
if (checked) {
return this.setState((state) => ({
conditions: [...state.conditions, condition],
}));
}
this.setState((state) => ({
conditions: state.conditions.filter((curr) => curr !== condition),
}));
}
_onClickNext() {
const { conditions } = this.state;
const conditionsStepCompleted = conditions.length > 0;
if (conditionsStepCompleted) {
return this.setState({
activeStep: STEP_IDS.ACCOUNT,
invalid: null,
});
}
this.setState({ invalid: 'Select at least one condition' });
}
renderConditions() {
const { invalid, activeStep, conditions } = this.state;
const showSummary = activeStep !== STEP_IDS.CONDITIONS;
if (showSummary) {
return (
<ul>
{conditions.map((condition, index) => (
<li key={index}>{condition}</li>
))}
</ul>
);
}
return (
<Stack
directionType={Stack.DIRECTION_TYPE.VERTICAL}
gapType={Stack.GAP_TYPE.LARGE}
>
<StackItem>
<CheckboxGroup
invalid={invalid}
description={CONDITIONS_DESCRIPTION}
>
{CONDITIONS.map((condition, index) => (
<Checkbox
key={index}
label={condition}
checked={conditions.includes(condition)}
onChange={(evt) => this._onChangeCondition(evt, condition)}
/>
))}
</CheckboxGroup>
</StackItem>
<StackItem>
<Button
sizeType={Button.SIZE_TYPE.SMALL}
spacingType={[
Button.SPACING_TYPE.NONE,
Button.SPACING_TYPE.NONE,
Button.SPACING_TYPE.LARGE,
]}
type={Button.TYPE.PRIMARY}
onClick={this._onClickNext}
>
Next
</Button>
</StackItem>
</Stack>
);
}
render() {
const { activeStep, conditions } = this.state;
const conditionsStepCompleted = conditions.length > 0;
return (
<Steps
defaultValue="conditions"
value={activeStep}
onChange={(evt, value) => this.setState({ activeStep: value })}
>
<StepsItem
label="Create recommended conditions"
value={STEP_IDS.CONDITIONS}
checked={conditionsStepCompleted}
expanded
>
{this.renderConditions()}
</StepsItem>
<StepsItem
label="Select an account"
value={STEP_IDS.ACCOUNT}
disabled={
!conditionsStepCompleted || activeStep === STEP_IDS.CONDITIONS
}
>
<Dropdown title="Select an account">
<DropdownItem>Example Account 1</DropdownItem>
<DropdownItem>Example Account 2</DropdownItem>
<DropdownItem>Example Account 3</DropdownItem>
</Dropdown>
</StepsItem>
</Steps>
);
}
}
return <ConditionCreationSteps />;
}

Accessoires

children

OBLIGATOIRE
nœud

Étapes à suivre pour restituer les éléments à l'intérieur du composant.

className

chaîne

Ajoute les noms de classe au composant. Doit être utilisé uniquement à des fins de positionnement et d'espacement.

defaultValue

n'importe lequel

L'étape initiale qui devrait être active.

onChange

fonction

Fonction appelée lorsque l'utilisateur clique sur une étape.

function (
event: React.MouseEvent,

Event source of the callback.

stepValue: any

The value of the step.

)

spacingType

énumération[]

Propriété d'espacement. L'espacement est défini comme un uplet de zéro à quatre valeurs, qui suivent les mêmes conventions que les propriétés CSS comme margin ou padding. Pour omettre une valeur, utilisez SPACING_TYPE.OMIT.

<Array of
<One of

Steps.SPACING_TYPE.EXTRA_LARGE, Steps.SPACING_TYPE.LARGE, Steps.SPACING_TYPE.MEDIUM, Steps.SPACING_TYPE.NONE, Steps.SPACING_TYPE.OMIT, Steps.SPACING_TYPE.SMALL,

>
>

style

objet

Style en ligne pour un style personnalisé. Doit être utilisé uniquement à des fins de positionnement et d'espacement.

testId

chaîne

Ajoute un attribut data-test-id . Utilisez-le pour cibler le composant dans les tests unitaires et E2E. Pour qu'un identifiant de test soit valide, préfixez-le avec votre identifiant nerdpack, suivi d'un point. Par exemple, my-nerdpack.some-element. Remarque : vous ne verrez peut-être pas l'attribut data-test-id car ils sont supprimés du DOM. Pour les déboguer, transmettez un paramètre de requête e2e-test à l'URL.

value

n'importe lequel

L'étape avec la valeur correspondante sera marquée comme active. Les étapes actives sont automatiquement développées. Si vous ne souhaitez pas que l'étape soit développée, vous devez la marquer comme disabled. Si elle est définie, elle transforme le composant en un composant contrôlé.

Droits d'auteur © 2025 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.