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

feat(joyride): show guided tour upon cryostat upgrades #971

Merged
merged 3 commits into from
Apr 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/About/AboutCryostatModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const AboutCryostatModal = ({ isOpen, onClose }) => {
return (
<AboutModal
appendTo={portalRoot}
productName={build.productName}
productName={`${build.productName} ${build.version}`}
brandImageSrc={cryostatLogo}
brandImageAlt="Cryostat Logo"
isOpen={isOpen}
Expand Down
10 changes: 9 additions & 1 deletion src/app/AppLayout/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ import { SessionState } from '@app/Shared/Services/Login.service';
import { NotificationCategory } from '@app/Shared/Services/NotificationChannel.service';
import { ServiceContext } from '@app/Shared/Services/Services';
import { FeatureLevel } from '@app/Shared/Services/Settings.service';
import { saveToLocalStorage } from '@app/utils/LocalStorage';
import { useSubscriptions } from '@app/utils/useSubscriptions';
import { useTheme } from '@app/utils/useTheme';
import { cleanDataId, openTabForUrl, portalRoot } from '@app/utils/utils';
import { cleanDataId, isAssetNew, openTabForUrl, portalRoot } from '@app/utils/utils';
import {
Alert,
AlertActionCloseButton,
Expand Down Expand Up @@ -586,6 +587,13 @@ const AppLayout: React.FC<AppLayoutProps> = ({ children }) => {
[handleCloseNotificationCenter]
);

React.useEffect(() => {
if (showUserIcon && isAssetNew(build.version)) {
handleOpenGuidedTour();
saveToLocalStorage('ASSET_VERSION', build.version);
}
}, [handleOpenGuidedTour, showUserIcon]);

return (
<GlobalQuickStartDrawer>
<CryostatJoyride>
Expand Down
2 changes: 1 addition & 1 deletion src/app/Joyride/CryostatJoyride.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const CryostatJoyride: React.FC<CryostatJoyrideProps> = (props) => {
width={300}
/>
<h1>
Welcome to <strong>Cryostat</strong>!
Welcome to <strong>Cryostat {build.version}</strong>!
</h1>
</div>
),
Expand Down
61 changes: 0 additions & 61 deletions src/app/Topology/Shared/HintBanner.tsx

This file was deleted.

17 changes: 1 addition & 16 deletions src/app/Topology/Topology.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,18 @@

import { BreadcrumbPage } from '@app/BreadcrumbPage/BreadcrumbPage';
import { ErrorView } from '@app/ErrorView/ErrorView';
import { FeatureFlag } from '@app/Shared/FeatureFlag/FeatureFlag';
import { LinearDotSpinner } from '@app/Shared/LinearDotSpinner';
import { ViewMode } from '@app/Shared/Redux/Configurations/TopologyConfigSlice';
import { RootState } from '@app/Shared/Redux/ReduxStore';
import { NotificationCategory } from '@app/Shared/Services/NotificationChannel.service';
import { ServiceContext } from '@app/Shared/Services/Services';
import { FeatureLevel } from '@app/Shared/Services/Settings.service';
import { getFromLocalStorage, saveToLocalStorage } from '@app/utils/LocalStorage';
import { useSubscriptions } from '@app/utils/useSubscriptions';
import { Bullseye, Card, CardBody } from '@patternfly/react-core';
import * as React from 'react';
import { useSelector } from 'react-redux';
import { Link, withRouter } from 'react-router-dom';
import { withRouter } from 'react-router-dom';
import { TopologyGraphView } from './GraphView/TopologyGraphView';
import { TopologyListView } from './ListView/TopologyListView';
import { HintBanner } from './Shared/HintBanner';
import { DiscoveryTreeContext, SearchExprService, SearchExprServiceContext } from './Shared/utils';
import { DEFAULT_EMPTY_UNIVERSE } from './typings';

Expand All @@ -75,19 +71,13 @@ export const Topology: React.FC<TopologyProps> = ({ ..._props }) => {

const [discoveryTree, setDiscoveryTree] = React.useState(DEFAULT_EMPTY_UNIVERSE);

const [shouldShowBanner, setShouldShowBanner] = React.useState(getFromLocalStorage('TOPOLOGY_SHOW_BANNER', true));
const isGraphView = useSelector((state: RootState) => {
const _currentMode: ViewMode = state.topologyConfigs.viewMode;
return _currentMode === 'graph';
});

const [error, setError] = React.useState<Error>();

const closeBanner = React.useCallback(() => {
setShouldShowBanner(false);
saveToLocalStorage('TOPOLOGY_SHOW_BANNER', false);
}, [setShouldShowBanner]);

const _refreshDiscoveryTree = React.useCallback(
(onSuccess?: () => void) => {
addSubscription(
Expand Down Expand Up @@ -178,11 +168,6 @@ export const Topology: React.FC<TopologyProps> = ({ ..._props }) => {

return (
<>
<FeatureFlag level={FeatureLevel.BETA}>
<HintBanner onClose={closeBanner} show={shouldShowBanner}>
For topology guides, see <Link to={'/quickstarts'}>Quickstarts</Link>.
</HintBanner>
</FeatureFlag>
<BreadcrumbPage pageTitle={'Topology'} {..._props}>
<Card isFullHeight id="topology-card">
<CardBody style={{ padding: 0 }}>
Expand Down
25 changes: 0 additions & 25 deletions src/app/Topology/styles/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -250,31 +250,6 @@ Below CSS rules only apply to Topology components
font-weight: 700;
}

.topology__hint-banner {
position: relative;
box-sizing: border-box;
text-align: center;
padding: 0.2em 0 0.2em 0;
background-color: var(--pf-global--palette--blue-400);
color: var(--pf-global--palette--white);
font-size: 0.9em;
margin-bottom: -1em;
}

.topology__hint-banner a {
color: var(--pf-global--palette--white);
text-decoration: solid underline var(--pf-global--palette--white) 1px;
}

.topology__hint-banner .close-icon {
position: relative;
float: right;
font-size: 1em;
margin-right: 1em;
transform: translateY(calc(50% - 0.25em));
cursor: pointer;
}

#topology__visualization-container.topology__main-container {
padding: 1em;
}
Expand Down
3 changes: 2 additions & 1 deletion src/app/build.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"fileIssueUrl": "https://github.com/cryostatio/cryostat/issues/new?labels=user+report,bug&body=Affects+__REPLACE_VERSION__",
"mailingListName": "Google Groups",
"mailingListUrl": "https://groups.google.com/g/cryostat-development",
"licenseUrl": "https://github.com/cryostatio/cryostat/blob/main/LICENSE"
"licenseUrl": "https://github.com/cryostatio/cryostat/blob/main/LICENSE",
"version": "2.4.0-dev"
tthvo marked this conversation as resolved.
Show resolved Hide resolved
}
2 changes: 1 addition & 1 deletion src/app/utils/LocalStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
*/
/* eslint-disable @typescript-eslint/no-explicit-any */
export enum LocalStorageKey {
ASSET_VERSION,
FEATURE_LEVEL,
DASHBOARD_CFG,
AUTOMATED_ANALYSIS_FILTERS,
TARGET_RECORDING_FILTERS,
CREDENTIAL_LOCATION,
TARGET,
TARGET_FAVORITES,
TOPOLOGY_SHOW_BANNER,
TOPOLOGY_GRAPH_POSITONS,
TOPOLOGY_NODE_POSITIONS,
TOPOLOGY_CONFIG,
Expand Down
43 changes: 43 additions & 0 deletions src/app/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { ISortBy, SortByDirection } from '@patternfly/react-table';
import _ from 'lodash';
import { useHistory } from 'react-router-dom';
import { BehaviorSubject, Observable } from 'rxjs';
import { getFromLocalStorage } from './LocalStorage';

const SECOND_MILLIS = 1000;
const MINUTE_MILLIS = 60 * SECOND_MILLIS;
Expand Down Expand Up @@ -266,3 +267,45 @@ export const getActiveTab = <T>(search: string, key: string, supportedTabs: T[],
};

export const clickOutside = () => document.body.click();

export interface SemVer {
major: number;
minor: number;
patch: number;
}

// https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
export const semverRegex =
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;

export const getSemVer = (str: string): SemVer | undefined => {
const matched = str.match(semverRegex);
if (matched) {
const [_, major, minor, patch] = matched;
return {
major: Number(major),
minor: Number(minor),
patch: Number(patch),
};
}
return undefined;
};

const convert = (ver: SemVer) => ver.major * 100 + ver.minor * 10 + ver.patch;

export const compareSemVer = (ver1: SemVer, ver2: SemVer): number => {
const _ver1 = convert(ver1);
const _ver2 = convert(ver2);
return _ver1 > _ver2 ? 1 : _ver1 < _ver2 ? -1 : 0;
};

export const isAssetNew = (currVerStr: string) => {
const oldVer = getSemVer(getFromLocalStorage('ASSET_VERSION', '0.0.0'));
const currVer = getSemVer(currVerStr);

if (!currVer) {
throw new Error(`Invalid asset version: ${currVer}`);
}
// Invalid (old) version is ignored.
return !oldVer || compareSemVer(currVer, oldVer) > 0;
};