Skip to content

Commit

Permalink
Update walkthrough configurations to support RHPDS generated users (#578
Browse files Browse the repository at this point in the history
)

* initial workshop support

* fix linting errors

* update service list urls

* update fuse name for os4

* bump version
  • Loading branch information
Dimitra Zuccarelli authored May 5, 2020
1 parent 44355a5 commit 3bcee3c
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "integreatly-web-app",
"version": "2.22.8",
"version": "2.23.0",
"private": true,
"proxy": "http://localhost:5001/",
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ function getConfigData(req) {
threescaleWildcardDomain: '${process.env.THREESCALE_WILDCARD_DOMAIN || ''}',
integreatlyVersion: '${process.env.INTEGREATLY_VERSION || ''}',
clusterType: '${process.env.CLUSTER_TYPE || ''}',
installationType: '${process.env.INSTALLATION_TYPE || ''}',
optionalWatchServices: ${JSON.stringify(arrayFromString(process.env.OPTIONAL_WATCH_SERVICES || '', ','))},
optionalProvisionServices: ${JSON.stringify(arrayFromString(process.env.OPTIONAL_PROVISION_SERVICES || '', ','))},
openshiftVersion: ${openshiftVersion},
Expand Down
42 changes: 37 additions & 5 deletions src/common/docsHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,34 @@ const retrieveRouteAttributes = (resourceId, route) => {
return routeAttrs;
};

const getMiddlewareServiceAttrs = middlewareServices => {
const getOpenshiftHost = middlewareServices => {
let threescaleUrl;
if (window.OPENSHIFT_CONFIG.threescaleWildcardDomain && window.OPENSHIFT_CONFIG.threescaleWildcardDomain.length > 0) {
threescaleUrl = window.OPENSHIFT_CONFIG.threescaleWildcardDomain;
} else {
threescaleUrl = getUrlFromMiddlewareServices(middlewareServices, DEFAULT_SERVICES.THREESCALE);
}
return threescaleUrl ? threescaleUrl.replace('https://3scale-admin.', '') : threescaleUrl;
};

const getMiddlewareServiceAttrs = middlewareServices => {
const openshiftHost = getOpenshiftHost(middlewareServices);
const username = middlewareServices.provisioningUser;
const fuseName =
window.OPENSHIFT_CONFIG && window.OPENSHIFT_CONFIG.openshiftVersion === 4
? DEFAULT_SERVICES.FUSE_MANAGED
: DEFAULT_SERVICES.FUSE;

const output = {
'openshift-app-host': threescaleUrl ? threescaleUrl.replace('https://3scale-admin.', '') : threescaleUrl,
'fuse-url': getUrlFromMiddlewareServices(middlewareServices, DEFAULT_SERVICES.FUSE),
'openshift-app-host': openshiftHost,
'fuse-url': isWorkshopInstallation
? getWorkshopUrl(DEFAULT_SERVICES.FUSE_MANAGED, username, openshiftHost)
: getUrlFromMiddlewareServices(middlewareServices, fuseName),
'launcher-url': getUrlFromMiddlewareServices(middlewareServices, DEFAULT_SERVICES.LAUNCHER),
'che-url': getUrlFromMiddlewareServices(middlewareServices, DEFAULT_SERVICES.CHE),
'api-management-url': getUrlFromMiddlewareServices(middlewareServices, DEFAULT_SERVICES.THREESCALE),
'api-management-url': isWorkshopInstallation
? getWorkshopUrl(DEFAULT_SERVICES.THREESCALE, username, openshiftHost)
: getUrlFromMiddlewareServices(middlewareServices, DEFAULT_SERVICES.THREESCALE),
'enmasse-url': getUrlFromMiddlewareServices(middlewareServices, DEFAULT_SERVICES.ENMASSE),
'amq-url': getUrlFromMiddlewareServices(middlewareServices, DEFAULT_SERVICES.AMQ),
'user-sso-url': getUrlFromMiddlewareServices(middlewareServices, DEFAULT_SERVICES.USER_RHSSO),
Expand Down Expand Up @@ -107,8 +121,26 @@ const getUrlFromMiddlewareServices = (middlewareServices, serviceName) => {
return getDashboardUrl(service);
};

const getWorkshopUrl = (serviceName, user, openshiftHost) => {
const username = cleanUsername(user);

// per-user fuse
if (serviceName === DEFAULT_SERVICES.FUSE_MANAGED) {
return `https://syndesis-${username}-fuse.${openshiftHost}`;
}

// per-user threescale
if (serviceName === DEFAULT_SERVICES.THREESCALE) {
return `https://${username}-tenant-admin.${openshiftHost}`;
}

return '';
};

const isWorkshopInstallation = window.OPENSHIFT_CONFIG && window.OPENSHIFT_CONFIG.installationType === 'workshop';

const getDefaultAdocAttrs = walkthroughId => ({
imagesdir: `/walkthroughs/${walkthroughId}/files/`
});

export { getDocsForWalkthrough, getDefaultAdocAttrs };
export { getDocsForWalkthrough, getDefaultAdocAttrs, getWorkshopUrl, getOpenshiftHost, isWorkshopInstallation };
41 changes: 36 additions & 5 deletions src/components/installedAppsView/InstalledAppsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
import { ChartPieIcon, ErrorCircleOIcon, HelpIcon, OnRunningIcon, OffIcon } from '@patternfly/react-icons';
import { getProductDetails, getServiceSortOrder } from '../../services/middlewareServices';
import { SERVICE_STATUSES, SERVICE_TYPES } from '../../redux/constants/middlewareConstants';
import { DEFAULT_SERVICES } from '../../common/serviceInstanceHelpers';
import { getWorkshopUrl, isWorkshopInstallation } from '../../common/docsHelpers';

class InstalledAppsView extends React.Component {
state = {
Expand Down Expand Up @@ -110,6 +112,12 @@ class InstalledAppsView extends React.Component {
};

getRouteForApp = app => {
if (
isWorkshopInstallation &&
(app.name === DEFAULT_SERVICES.FUSE_MANAGED || app.name === DEFAULT_SERVICES.THREESCALE)
) {
return getWorkshopUrl(app.name, this.props.username, this.props.openshiftHost);
}
if (app.type === SERVICE_TYPES.PROVISIONED_SERVICE) {
return app.url;
}
Expand Down Expand Up @@ -414,14 +422,33 @@ class InstalledAppsView extends React.Component {
this.handleLaunchClicked.bind(this)
);
const managedTooltip = 'Managed services are delivered as a hosted service and supported by Red Hat.';
// const selfManagedTooltip = 'Self-managed services are available for use, but not managed by Red Hat.';
const selfManagedTooltip = 'Self-managed services are available for use, but not managed by Red Hat.';

return (
<div>
<div className="integr8ly-tutorial-dashboard-title pf-l-flex pf-u-py-sm">
<span className="pf-l-flex pf-m-inline-flex">
<h2 className="pf-c-title pf-m-3xl pf-u-mt-sm pf-u-mb-sm">Managed services</h2>
<Tooltip position="top" content={<div>{managedTooltip}</div>}>
<h2 className="pf-c-title pf-m-3xl pf-u-mt-sm pf-u-mb-sm">
{window.OPENSHIFT_CONFIG &&
(window.OPENSHIFT_CONFIG.openshiftVersion === 3 ||
(window.OPENSHIFT_CONFIG.installationType === 'workshop' ||
window.OPENSHIFT_CONFIG.installationType === 'managed'))
? 'Managed services'
: 'Self-managed services'}
</h2>
<Tooltip
position="top"
content={
<div>
{window.OPENSHIFT_CONFIG &&
(window.OPENSHIFT_CONFIG.openshiftVersion === 3 ||
(window.OPENSHIFT_CONFIG.installationType === 'workshop' ||
window.OPENSHIFT_CONFIG.installationType === 'managed'))
? managedTooltip
: selfManagedTooltip}
</div>
}
>
<span>
<HelpIcon className="integr8ly-dev-resources-icon" />
</span>
Expand Down Expand Up @@ -480,12 +507,16 @@ InstalledAppsView.propTypes = {
).isRequired,
showUnready: PropTypes.array,
handleLaunch: PropTypes.func.isRequired,
enableLaunch: PropTypes.bool
enableLaunch: PropTypes.bool,
username: PropTypes.string,
openshiftHost: PropTypes.string
};

InstalledAppsView.defaultProps = {
showUnready: [],
enableLaunch: true
enableLaunch: true,
username: '',
openshiftHost: ''
};

export default InstalledAppsView;
4 changes: 4 additions & 0 deletions src/pages/landing/landingPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { provisionAMQOnline, provisionAMQOnlineV4 } from '../../services/amqOnli
import { currentUser } from '../../services/openshiftServices';
import { DEFAULT_SERVICES } from '../../common/serviceInstanceHelpers';
import { DISPLAY_SERVICES } from '../../services/middlewareServices';
import { getOpenshiftHost } from '../../common/docsHelpers';
import {
getUsersSharedNamespaceName,
getUsersSharedNamespaceDisplayName,
Expand Down Expand Up @@ -76,6 +77,7 @@ class LandingPage extends React.Component {
render() {
const { walkthroughServices, middlewareServices, user } = this.props;
const launchFn = isOpenShift4() ? this.handleServiceLaunchV4.bind(this) : this.handleServiceLaunch.bind(this);
const openshiftHost = getOpenshiftHost(middlewareServices);

return (
<React.Fragment>
Expand Down Expand Up @@ -111,6 +113,8 @@ class LandingPage extends React.Component {
<GridItem sm={12} md={12}>
<InstalledAppsView
apps={Object.values(middlewareServices.data)}
username={this.state.currentUserName}
openshiftHost={openshiftHost}
enableLaunch={!window.OPENSHIFT_CONFIG.mockData}
showUnready={middlewareServices.customServices.showUnreadyServices || DISPLAY_SERVICES}
customApps={middlewareServices.customServices.services}
Expand Down

0 comments on commit 3bcee3c

Please sign in to comment.