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
Conversation
@christianvogt Updated to bring it closer to UX design, added Kebab. The UX font size is different than that used in rest of gallery |
<Text component={TextVariants.h3}> Guided Tours</Text> | ||
</FlexItem> | ||
<FlexItem breakpointMods={[{ modifier: FlexModifiers['align-right'] }]}> | ||
<Kebab options={[{ label: 'remove guided tours', callback: () => null }]} /> |
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.
Use CardActions
component. See PF examples: https://patternfly-react.surge.sh/documentation/react/components/card
<CardBody className="odc-guidedtour-tile__body"> | ||
{orderedTours.map((tour) => ( | ||
<div key={tour.name} className="odc-guidedtour-tile__tour"> | ||
<Button variant="link">{tour.name}</Button> |
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.
Use react-router Link
))} | ||
</CardBody> | ||
<CardFooter className="odc-guidedtour-tile__footer"> | ||
<Button |
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.
use isInline
button
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.
Use react-router Link
<CardHeader> | ||
<Flex className="odc-guidedtour-tile__title"> | ||
<FlexItem> | ||
<Text component={TextVariants.h3}> Guided Tours</Text> |
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.
Use CardTitle
. See PF examples: https://patternfly-react.surge.sh/documentation/react/components/card
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.
CardTitle seems to be unavailable with current PF
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.
The PF v4 PR is on its way. Maybe just wait for it to merge otherwise we'll have to change this again as soon as it's in.
Or look at the previous release docs and find common components between the two that works.
e173091
to
a21046a
Compare
@abhinandan13jan needs rebase. Also you can use new pf components now. |
a8e4fa0
to
94765cc
Compare
@christianvogt I've rebased and made changes to accomodate |
<GalleryItem className="odc-guidedtour-tile"> | ||
<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 comment
The reason will be displayed to describe this comment to others. Learn more.
<CardHeaderMain className="odc-guidedtour-tile__title">Guided Tours</CardHeaderMain> | |
<CardHeaderMain> | |
<Title headingLevel="h1" size="xl"> | |
Guided Tours | |
</Title> | |
</CardHeaderMain> |
&__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 comment
The reason will be displayed to describe this comment to others. Learn more.
You can use a patternfly Title
component instead.
&__title { | |
font-weight: var(--pf-global--FontWeight--bold); | |
font-size: var(--pf-global--FontSize--lg); | |
} |
} | ||
&__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 comment
The reason will be displayed to describe this comment to others. Learn more.
padding: var(--pf-global--spacer--sm) var(--pf-global--spacer--lg); | |
padding-top: var(--pf-global--spacer--sm); | |
padding-bottom: var(--pf-global--spacer--sm); |
text-align: left; | ||
} | ||
&__arrowbtn { | ||
margin-right: var(--pf-global--spacer--md); |
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.
margin-right: var(--pf-global--spacer--md); | |
margin-right: var(--pf-global--spacer--sm); |
/> | ||
</CardActions> | ||
</CardHeader> | ||
<CardBody className="odc-guidedtour-tile__body"> |
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.
<CardBody className="odc-guidedtour-tile__body"> | |
<CardBody> |
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 comment
The reason will be displayed to describe this comment to others. Learn more.
padding: var(--pf-global--spacer--sm) var(--pf-global--spacer--md); | |
text-align: left; | |
margin-bottom: var(--pf-global--spacer--sm); |
&__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 comment
The reason will be displayed to describe this comment to others. Learn more.
&__header { | |
padding: 0px var(--pf-global--spacer--md); | |
margin: 0px; | |
} | |
&__body { | |
padding: var(--pf-global--spacer--sm); | |
} |
const actionDropdownItem = [<DropdownItem key="link">Remove guided tours</DropdownItem>]; | ||
const orderedTours = tours.length > 3 ? tours.slice(0, 3) : tours; | ||
return ( | ||
<GalleryItem className="odc-guidedtour-tile"> |
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.
<GalleryItem className="odc-guidedtour-tile"> | |
<GalleryItem> |
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 comment
The 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.
isOpen={isOpen} | ||
isPlain | ||
dropdownItems={actionDropdownItem} | ||
position={'right'} |
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.
position={'right'} | |
position="right" |
@@ -0,0 +1,18 @@ | |||
import { action, ActionType } from 'typesafe-actions'; | |||
|
|||
export const TOUR_TILE_STORAGE_KEY = 'bridge/guided_tour_tile'; |
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.
export const TOUR_TILE_STORAGE_KEY = 'bridge/guided_tour_tile'; | |
export const TOUR_TILE_STORAGE_KEY = 'bridge/hide-guided_tour_tile'; |
tours: TourItem[]; | ||
}; | ||
|
||
const GuidedTourTile: React.FC<GuidedTourTileProps & DispatchProps> = ({ tours, removeTours }) => { |
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.
Using redux for this seems like overkill when there's only 1 spot in the app where we need this functionality.
Wouldn't something simple like this do the trick:
const [showTile, setShowTile] = React.useState(!localStorage.get(HIDE_TOUR_TILE_STORAGE_KEY));
const onRemove = () => {
localStorage.set(HIDE_TOUR_TILE_STORAGE_KEY, true);
setShowTile(false);
};
...
return showTile ? ... : null;
@rohitkrai03 thoughts?
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 agree with @christianvogt here, it doesn't make sense to use redux if the state is only ever going to be used in this component.
&__header { | ||
padding: 0px var(--pf-global--spacer--md); | ||
margin: 0px; | ||
} |
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.
Remove as this is no longer used.
7cedaaf
to
ba80d2d
Compare
type DispatchProps = { | ||
removeTours?: () => void; | ||
}; |
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.
You don't need this.
|
||
const HIDE_TOUR_TILE_STORAGE_KEY = 'bridge/hide-tour-tile'; | ||
const GuidedTourTile: React.FC<GuidedTourTileProps & DispatchProps> = ({ tours }) => { | ||
const isTourTileHidden = !!localStorage.getItem(HIDE_TOUR_TILE_STORAGE_KEY) || false; |
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.
const isTourTileHidden = !!localStorage.getItem(HIDE_TOUR_TILE_STORAGE_KEY) || false; | |
const isTourTileHidden = !!localStorage.getItem(HIDE_TOUR_TILE_STORAGE_KEY) ?? false; |
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.
changed
</DropdownItem>, | ||
]; | ||
|
||
const orderedTours = tours.length > 3 ? tours.slice(0, 3) : 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.
It's not actually ordered tours.
const orderedTours = tours.length > 3 ? tours.slice(0, 3) : tours; | |
const slicedTours = tours.length > 3 ? tours.slice(0, 3) : 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.
changed
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Added
ba80d2d
to
ebdb877
Compare
import { getGuidedToursWithStatus } from '@console/app/src/components/guided-tours/utils/guided-tour-utils'; | ||
import GuidedTourTile from './GuidedTourTile'; | ||
|
||
const GuidedTourAddAction: React.FC = () => { |
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
ebdb877
to
025efc5
Compare
@@ -71,6 +74,9 @@ const ODCEmptyState: React.FC<Props> = ({ | |||
const addActionExtensions = useExtensions<AddAction>( | |||
isAddAction, | |||
).filter(({ properties: { hide } }) => (hide ? hide() : true)); | |||
|
|||
const guidedTourList = getGuidedToursWithStatus(); |
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.
Fetching of tour could easily be handled by GuidedTourTile
component itself. If there are tours it will render the tile else just return null
.
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 didn't care much about where the mock data is coming from but I agree with Rohit here that it makes more sense to have this in GuidedTourTile
.
@@ -0,0 +1,16 @@ | |||
.odc-guidedtour-tile { | |||
&__card { | |||
height: 100%; |
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.
height: $co-m-catalog-tile-height;
width: $co-m-catalog-tile-width;
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.
The above aligns with the other empty state tile sizes.
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.
updated.
@@ -71,6 +74,9 @@ const ODCEmptyState: React.FC<Props> = ({ | |||
const addActionExtensions = useExtensions<AddAction>( | |||
isAddAction, | |||
).filter(({ properties: { hide } }) => (hide ? hide() : true)); | |||
|
|||
const guidedTourList = getGuidedToursWithStatus(); |
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 didn't care much about where the mock data is coming from but I agree with Rohit here that it makes more sense to have this in GuidedTourTile
.
025efc5
to
2be8038
Compare
2be8038
to
76a53de
Compare
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: abhinandan13jan, rohitkrai03 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Adresses
https://issues.redhat.com/browse/ODC-4131
This must go in after -- #5764
Issue
Add guided tour discoverability to dev console
Solution
Created GuidedTourTile component and added to AddActions
ScreenShot
Tests
Added GuidedTourTile specs
Browser Conformation
Chrome