-
Notifications
You must be signed in to change notification settings - Fork 592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add Guided tour tile #5822
add Guided tour tile #5822
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import * as React from 'react'; | ||
import { getGuidedToursWithStatus } from '@console/app/src/components/guided-tours/utils/guided-tour-utils'; | ||
import GuidedTourTile from './GuidedTourTile'; | ||
|
||
const GuidedTourAddAction: React.FC = () => { | ||
const guidedTourList = getGuidedToursWithStatus(); | ||
return guidedTourList.length > 0 ? <GuidedTourTile tours={guidedTourList} /> : null; | ||
}; | ||
|
||
export default GuidedTourAddAction; |
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,27 @@ | ||||||||||||||||
.odc-guidedtour-tile { | ||||||||||||||||
&__card { | ||||||||||||||||
height: 100%; | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The above aligns with the other empty state tile sizes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated. |
||||||||||||||||
} | ||||||||||||||||
&__header { | ||||||||||||||||
padding: 0px var(--pf-global--spacer--md); | ||||||||||||||||
margin: 0px; | ||||||||||||||||
} | ||||||||||||||||
&__body { | ||||||||||||||||
padding: var(--pf-global--spacer--sm); | ||||||||||||||||
} | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
&__tour { | ||||||||||||||||
padding: var(--pf-global--spacer--sm) var(--pf-global--spacer--md); | ||||||||||||||||
text-align: left; | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
} | ||||||||||||||||
&__arrowbtn { | ||||||||||||||||
margin-right: var(--pf-global--spacer--md); | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
} | ||||||||||||||||
&__footer { | ||||||||||||||||
border-top: 1px solid var(--pf-global--BorderColor--100); | ||||||||||||||||
padding: var(--pf-global--spacer--sm) var(--pf-global--spacer--lg); | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
} | ||||||||||||||||
&__title { | ||||||||||||||||
font-weight: var(--pf-global--FontWeight--bold); | ||||||||||||||||
font-size: var(--pf-global--FontSize--lg); | ||||||||||||||||
} | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can use a patternfly
Suggested change
|
||||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,63 @@ | ||||||||||||||
import * as React from 'react'; | ||||||||||||||
import { Link } from 'react-router-dom'; | ||||||||||||||
import { | ||||||||||||||
Card, | ||||||||||||||
CardActions, | ||||||||||||||
CardBody, | ||||||||||||||
CardFooter, | ||||||||||||||
CardHeader, | ||||||||||||||
CardHeaderMain, | ||||||||||||||
Dropdown, | ||||||||||||||
DropdownItem, | ||||||||||||||
GalleryItem, | ||||||||||||||
KebabToggle, | ||||||||||||||
} from '@patternfly/react-core'; | ||||||||||||||
import { ArrowRightIcon } from '@patternfly/react-icons'; | ||||||||||||||
import { | ||||||||||||||
GuidedTourItem, | ||||||||||||||
TourStatus, | ||||||||||||||
} from '@console/app/src/components/guided-tours/utils/guided-tour-typings'; | ||||||||||||||
import './GuidedTourTile.scss'; | ||||||||||||||
|
||||||||||||||
type TourItem = GuidedTourItem & TourStatus; | ||||||||||||||
type GuidedTourTileProps = { | ||||||||||||||
tours: TourItem[]; | ||||||||||||||
}; | ||||||||||||||
|
||||||||||||||
const GuidedTourTile: React.FC<GuidedTourTileProps> = ({ tours }) => { | ||||||||||||||
const [isOpen, setOpen] = React.useState(false); | ||||||||||||||
const onToggle = () => setOpen(!isOpen); | ||||||||||||||
const actionDropdownItem = [<DropdownItem key="link">Remove guided tours</DropdownItem>]; | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This action needs to remove the card and save the setting to local storage. |
||||||||||||||
const orderedTours = tours.length > 3 ? tours.slice(0, 3) : tours; | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not actually ordered tours.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed |
||||||||||||||
return ( | ||||||||||||||
<GalleryItem className="odc-guidedtour-tile"> | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
<Card className="odc-guidedtour-tile__card"> | ||||||||||||||
<CardHeader> | ||||||||||||||
<CardHeaderMain className="odc-guidedtour-tile__title">Guided Tours</CardHeaderMain> | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
<CardActions> | ||||||||||||||
<Dropdown | ||||||||||||||
toggle={<KebabToggle onToggle={onToggle} />} | ||||||||||||||
isOpen={isOpen} | ||||||||||||||
isPlain | ||||||||||||||
dropdownItems={actionDropdownItem} | ||||||||||||||
position={'right'} | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
/> | ||||||||||||||
</CardActions> | ||||||||||||||
</CardHeader> | ||||||||||||||
<CardBody className="odc-guidedtour-tile__body"> | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
{orderedTours.map((tour) => ( | ||||||||||||||
<div key={tour.name} className="odc-guidedtour-tile__tour"> | ||||||||||||||
<Link to="/#">{tour.name}</Link> | ||||||||||||||
</div> | ||||||||||||||
))} | ||||||||||||||
</CardBody> | ||||||||||||||
<CardFooter className="odc-guidedtour-tile__footer"> | ||||||||||||||
<ArrowRightIcon className="odc-guidedtour-tile__arrowbtn" /> | ||||||||||||||
<Link to="/tours">See all guided tours</Link> | ||||||||||||||
</CardFooter> | ||||||||||||||
</Card> | ||||||||||||||
</GalleryItem> | ||||||||||||||
); | ||||||||||||||
}; | ||||||||||||||
|
||||||||||||||
export default GuidedTourTile; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as React from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import { shallow } from 'enzyme'; | ||
import GuidedTourTile from '../GuidedTourTile'; | ||
import { getGuidedToursWithStatus } from '@console/app/src/components/guided-tours/utils/guided-tour-utils'; | ||
import { CardActions, Dropdown, CardBody, CardFooter } from '@patternfly/react-core'; | ||
|
||
type GuidedTourTileProps = React.ComponentProps<typeof GuidedTourTile>; | ||
|
||
describe('GuidedTourTile', () => { | ||
const guidedTourTileProps: GuidedTourTileProps = { | ||
tours: getGuidedToursWithStatus(), | ||
}; | ||
const guidedTourTileWrapper = shallow(<GuidedTourTile {...guidedTourTileProps} />); | ||
it('should show proper CardAction', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be good to have a test for when local storage has removed tile state. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
||
const cardAction = guidedTourTileWrapper.find(CardActions); | ||
expect(cardAction.exists()).toBe(true); | ||
expect(cardAction.find(Dropdown).prop('dropdownItems').length).toEqual(1); | ||
}); | ||
it('should show 3 tour links', () => { | ||
const cardBody = guidedTourTileWrapper.find(CardBody); | ||
expect(cardBody.exists()).toBe(true); | ||
expect(cardBody.find(Link).length).toEqual(3); | ||
}); | ||
it('should show a footer link to GuidedTourCatalog', () => { | ||
const cardFooter = guidedTourTileWrapper.find(CardFooter); | ||
expect(cardFooter.exists()).toBe(true); | ||
expect(cardFooter.find(Link).exists()).toBe(true); | ||
expect(cardFooter.find(Link).prop('to')).toEqual('/tours'); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why exactly do we need this extra component here? It doesn't seem to be doing anything at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've removed this