Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
refactor: migrated deprecated Input and ValidationForm group components
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullahwaheed authored Jan 24, 2023
1 parent b923ec9 commit f6fe875
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 62 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: npm install -g npm@${{ matrix.npm }}

- run: npm install -g npm@${{ matrix.npm }}

Expand Down
32 changes: 19 additions & 13 deletions src/payment/__snapshots__/PaymentPage.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2353,20 +2353,26 @@ exports[`<PaymentPage /> Renders correctly in various states should render the b
<div
className="position-relative"
>
<input
className="form-control form-control-sm"
defaultValue={1}
id="code-quantity"
max="100"
min="1"
name="code-quantity"
style={
Object {
"width": "5rem",
<div
className="pgn__form-control-decorator-group form-control-sm"
>
<input
className="has-value form-control"
defaultValue={1}
id="code-quantity"
max="100"
min="1"
name="code-quantity"
onBlur={[Function]}
onChange={[Function]}
style={
Object {
"width": "5rem",
}
}
}
type="number"
/>
type="number"
/>
</div>
<small
className="text-muted small"
style={
Expand Down
8 changes: 4 additions & 4 deletions src/payment/cart/CouponForm.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { Button, Input, ValidationFormGroup } from '@edx/paragon';
import { Button, Form } from '@edx/paragon';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import { sendTrackEvent } from '@edx/frontend-platform/analytics';

Expand Down Expand Up @@ -44,16 +44,16 @@ class CouponForm extends Component {

return (
<form onSubmit={this.handleAddSubmit} className="summary-row d-flex align-items-end">
<ValidationFormGroup for={id} invalid={false} className="mb-0 mr-2">
<Form.Group controlId={id} invalid={false} className="mb-0 mr-2">
<label className="h6 d-block" htmlFor={id}>
<FormattedMessage
id="payment.coupon.label"
defaultMessage="Add coupon code (optional)"
description="Label for the add coupon form"
/>
</label>
<Input name={id} id={id} type="text" defaultValue={code} />
</ValidationFormGroup>
<Form.Control name={id} id={id} type="text" defaultValue={code} />
</Form.Group>
<Button
disabled={isBasketProcessing}
variant="outline-primary"
Expand Down
4 changes: 2 additions & 2 deletions src/payment/cart/UpdateQuantityForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useCallback } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { FormattedMessage } from '@edx/frontend-platform/i18n';
import { StatefulButton, Input } from '@edx/paragon';
import { StatefulButton, Form } from '@edx/paragon';

import { updateQuantity } from '../data/actions';
import { updateQuantityFormSelector } from '../data/selectors';
Expand Down Expand Up @@ -34,7 +34,7 @@ const UpdateQuantityForm = (props) => {
/>
</label>
<div className="position-relative">
<Input
<Form.Control
className="form-control-sm"
name={id}
id={id}
Expand Down
70 changes: 42 additions & 28 deletions src/payment/cart/__snapshots__/Cart.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -198,22 +198,30 @@ exports[`<Cart /> renders a basic, one product cart with coupon form 1`] = `
onSubmit={[Function]}
>
<div
className="form-group mb-0 mr-2"
className="pgn__form-group mb-0 mr-2"
invalid={false}
>
<label
className="h6 d-block"
htmlFor="couponField"
>
Add coupon code (optional)
</label>
<input
aria-describedby=""
className="form-control"
defaultValue=""
id="couponField"
name="couponField"
type="text"
/>
Array [
<label
className="h6 d-block"
htmlFor="couponField"
>
Add coupon code (optional)
</label>,
<div
className="pgn__form-control-decorator-group"
>
<input
className="form-control"
defaultValue=""
id="couponField"
name="couponField"
onBlur={[Function]}
onChange={[Function]}
type="text"
/>
</div>,
]
</div>
<button
className="btn btn-outline-primary"
Expand Down Expand Up @@ -325,20 +333,26 @@ exports[`<Cart /> renders a bulk enrollment cart 1`] = `
<div
className="position-relative"
>
<input
className="form-control form-control-sm"
defaultValue={1}
id="code-quantity"
max="100"
min="1"
name="code-quantity"
style={
Object {
"width": "5rem",
<div
className="pgn__form-control-decorator-group form-control-sm"
>
<input
className="has-value form-control"
defaultValue={1}
id="code-quantity"
max="100"
min="1"
name="code-quantity"
onBlur={[Function]}
onChange={[Function]}
style={
Object {
"width": "5rem",
}
}
}
type="number"
/>
type="number"
/>
</div>
<small
className="text-muted small"
style={
Expand Down
38 changes: 23 additions & 15 deletions src/payment/cart/__snapshots__/CouponForm.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,30 @@ exports[`CouponForm should render a form when there is no coupon 1`] = `
onSubmit={[Function]}
>
<div
className="form-group mb-0 mr-2"
className="pgn__form-group mb-0 mr-2"
invalid={false}
>
<label
className="h6 d-block"
htmlFor="couponField"
>
Add coupon code (optional)
</label>
<input
aria-describedby=""
className="form-control"
defaultValue=""
id="couponField"
name="couponField"
type="text"
/>
Array [
<label
className="h6 d-block"
htmlFor="couponField"
>
Add coupon code (optional)
</label>,
<div
className="pgn__form-control-decorator-group"
>
<input
className="form-control"
defaultValue=""
id="couponField"
name="couponField"
onBlur={[Function]}
onChange={[Function]}
type="text"
/>
</div>,
]
</div>
<button
className="btn btn-outline-primary"
Expand Down

0 comments on commit f6fe875

Please sign in to comment.