Skip to content
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

Merged

Conversation

abhinandan13jan
Copy link
Contributor

@abhinandan13jan abhinandan13jan commented Jun 25, 2020

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

Screencast from 07-07-2020 06_19_56 PM

Tests

Added GuidedTourTile specs

Browser Conformation

Chrome

@openshift-ci-robot openshift-ci-robot added the component/core Related to console core functionality label Jun 25, 2020
@openshift-ci-robot openshift-ci-robot added the component/dev-console Related to dev-console label Jun 25, 2020
@abhinandan13jan abhinandan13jan changed the title Guided tour tile [WIP] -- add Guided tour tile Jun 25, 2020
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 25, 2020
@christianvogt
Copy link
Contributor

image

vs

image
image

  • Too much white space above and below header
  • Need to add kebab menu to Remove Guided Tours
  • Mis-alignment of list items with title
  • Footer line separator does not span full width

You may want to use a custom Card instead of CatalogTile because this is a very different tile than the rest.

@abhinandan13jan
Copy link
Contributor Author

image

vs

image
image

  • Too much white space above and below header
  • Need to add kebab menu to Remove Guided Tours
  • Mis-alignment of list items with title
  • Footer line separator does not span full width

You may want to use a custom Card instead of CatalogTile because this is a very different tile than the rest.

@christianvogt Updated to bring it closer to UX design, added Kebab. The UX font size is different than that used in rest of gallery

@abhinandan13jan abhinandan13jan changed the title [WIP] -- add Guided tour tile add Guided tour tile Jun 30, 2020
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 30, 2020
<Text component={TextVariants.h3}> Guided Tours</Text>
</FlexItem>
<FlexItem breakpointMods={[{ modifier: FlexModifiers['align-right'] }]}>
<Kebab options={[{ label: 'remove guided tours', callback: () => null }]} />
Copy link
Contributor

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>
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use isInline button

Copy link
Contributor

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>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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

Copy link
Contributor

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.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 1, 2020
@openshift-ci-robot openshift-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jul 2, 2020
@christianvogt
Copy link
Contributor

@abhinandan13jan needs rebase. Also you can use new pf components now.

@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 7, 2020
@abhinandan13jan
Copy link
Contributor Author

@christianvogt I've rebased and made changes to accomodate CardHeaderMain. The CardTitle component is causing misalignments even with display:inline

Screenshot from 2020-07-07 18-11-11

<GalleryItem className="odc-guidedtour-tile">
<Card className="odc-guidedtour-tile__card">
<CardHeader>
<CardHeaderMain className="odc-guidedtour-tile__title">Guided Tours</CardHeaderMain>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<CardHeaderMain className="odc-guidedtour-tile__title">Guided Tours</CardHeaderMain>
<CardHeaderMain>
<Title headingLevel="h1" size="xl">
Guided Tours
</Title>
</CardHeaderMain>

Comment on lines 23 to 26
&__title {
font-weight: var(--pf-global--FontWeight--bold);
font-size: var(--pf-global--FontSize--lg);
}
Copy link
Contributor

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.

Suggested change
&__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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
margin-right: var(--pf-global--spacer--md);
margin-right: var(--pf-global--spacer--sm);

/>
</CardActions>
</CardHeader>
<CardBody className="odc-guidedtour-tile__body">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<CardBody className="odc-guidedtour-tile__body">
<CardBody>

Comment on lines 13 to 14
padding: var(--pf-global--spacer--sm) var(--pf-global--spacer--md);
text-align: left;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
padding: var(--pf-global--spacer--sm) var(--pf-global--spacer--md);
text-align: left;
margin-bottom: var(--pf-global--spacer--sm);

Comment on lines 5 to 11
&__header {
padding: 0px var(--pf-global--spacer--md);
margin: 0px;
}
&__body {
padding: var(--pf-global--spacer--sm);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
&__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">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<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>];
Copy link
Contributor

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'}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
position={'right'}
position="right"

@@ -0,0 +1,18 @@
import { action, ActionType } from 'typesafe-actions';

export const TOUR_TILE_STORAGE_KEY = 'bridge/guided_tour_tile';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 }) => {
Copy link
Contributor

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?

Copy link
Contributor

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.

Comment on lines 5 to 7
&__header {
padding: 0px var(--pf-global--spacer--md);
margin: 0px;
}
Copy link
Contributor

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.

Comment on lines 90 to 92
type DispatchProps = {
removeTours?: () => void;
};
Copy link
Contributor

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const isTourTileHidden = !!localStorage.getItem(HIDE_TOUR_TILE_STORAGE_KEY) || false;
const isTourTileHidden = !!localStorage.getItem(HIDE_TOUR_TILE_STORAGE_KEY) ?? false;

Copy link
Contributor Author

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;
Copy link
Contributor

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.

Suggested change
const orderedTours = tours.length > 3 ? tours.slice(0, 3) : tours;
const slicedTours = tours.length > 3 ? tours.slice(0, 3) : tours;

Copy link
Contributor Author

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', () => {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

import { getGuidedToursWithStatus } from '@console/app/src/components/guided-tours/utils/guided-tour-utils';
import GuidedTourTile from './GuidedTourTile';

const GuidedTourAddAction: React.FC = () => {
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed this

@@ -71,6 +74,9 @@ const ODCEmptyState: React.FC<Props> = ({
const addActionExtensions = useExtensions<AddAction>(
isAddAction,
).filter(({ properties: { hide } }) => (hide ? hide() : true));

const guidedTourList = getGuidedToursWithStatus();
Copy link
Contributor

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.

Copy link
Contributor

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%;
Copy link
Contributor

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;

Copy link
Contributor

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.

Copy link
Contributor Author

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();
Copy link
Contributor

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.

Copy link
Contributor

@rohitkrai03 rohitkrai03 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 9, 2020
@openshift-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 9, 2020
@openshift-merge-robot openshift-merge-robot merged commit f472a52 into openshift:master Jul 9, 2020
@spadgett spadgett added this to the v4.6 milestone Jul 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality component/dev-console Related to dev-console lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants