-
Notifications
You must be signed in to change notification settings - Fork 667
Added a external link to noobaa details card #2520
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -11,10 +11,11 @@ import { | |
| DashboardItemProps, | ||
| withDashboardResources, | ||
| } from '@console/internal/components/dashboards-page/with-dashboard-resources'; | ||
| import { FirehoseResource } from '@console/internal/components/utils'; | ||
| import { FirehoseResource, ExternalLink } from '@console/internal/components/utils'; | ||
| import { InfrastructureModel, SubscriptionModel } from '@console/internal/models/index'; | ||
| import { referenceForModel, K8sResourceKind } from '@console/internal/module/k8s'; | ||
| import { getInfrastructurePlatform } from '@console/ceph-storage-plugin/src/selectors'; | ||
| import { getMetric } from '../../utils'; | ||
|
|
||
| const NOOBAA_SYSTEM_NAME_QUERY = 'NooBaa_system_info'; | ||
|
|
||
|
|
@@ -55,11 +56,15 @@ export const ObjectServiceDetailsCard: React.FC<DashboardItemProps> = ({ | |
|
|
||
| const queryResult = prometheusResults.getIn([NOOBAA_SYSTEM_NAME_QUERY, 'result']); | ||
|
|
||
| const systemName = _.get(queryResult, 'data.result[0].metric.system_name'); | ||
| const systemName = getMetric(queryResult, 'system_name'); | ||
| const systemAddress = getMetric(queryResult, 'system_address'); | ||
| const systemLink = | ||
| systemName && systemAddress ? `${systemAddress}fe/systems/${systemName}` : undefined; | ||
|
|
||
| const infrastructure = _.get(resources, 'infrastructure'); | ||
| const infrastructureLoaded = _.get(infrastructure, 'loaded', false); | ||
| const infrastructureData = _.get(infrastructure, 'data') as K8sResourceKind; | ||
| const infrastructurePlatform = getInfrastructurePlatform(infrastructureData); | ||
|
|
||
| const subscription = _.get(resources, 'subscription'); | ||
| const subscriptionLoaded = _.get(subscription, 'loaded'); | ||
|
|
@@ -72,30 +77,33 @@ export const ObjectServiceDetailsCard: React.FC<DashboardItemProps> = ({ | |
| </DashboardCardHeader> | ||
| <DashboardCardBody> | ||
| <DetailsBody> | ||
| <DetailItem | ||
| key="service_name" | ||
| title="Service Name" | ||
| value="OpenShift Container Storage" | ||
| isLoading={false} | ||
| /> | ||
| <DetailItem key="service_name" title="Service Name" error={false} isLoading={false}> | ||
| OpenShift Container Storage | ||
| </DetailItem> | ||
| <DetailItem | ||
| key="system_name" | ||
| title="System Name" | ||
| value={systemName} | ||
| isLoading={!queryResult} | ||
| /> | ||
| error={!systemLink} | ||
| > | ||
| <ExternalLink href={systemLink} text={systemName} /> | ||
|
||
| </DetailItem> | ||
| <DetailItem | ||
| key="provider" | ||
| title="Provider" | ||
| value={getInfrastructurePlatform(infrastructureData)} | ||
| error={!infrastructurePlatform} | ||
| isLoading={!infrastructureLoaded} | ||
| /> | ||
| > | ||
| {infrastructurePlatform} | ||
| </DetailItem> | ||
| <DetailItem | ||
| key="version" | ||
| title="Version" | ||
| value={ocsVersion} | ||
| isLoading={!subscriptionLoaded} | ||
| /> | ||
| error={!ocsVersion} | ||
| > | ||
| {ocsVersion} | ||
| </DetailItem> | ||
| </DetailsBody> | ||
| </DashboardCardBody> | ||
| </DashboardCard> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,28 @@ | ||
| import * as React from 'react'; | ||
| import classNames from 'classnames'; | ||
|
|
||
| import { LoadingInline } from '../../utils'; | ||
|
|
||
| export const DetailItem: React.FC<DetailItemProps> = React.memo(({ title, value, isLoading }) => ( | ||
| <React.Fragment> | ||
| <dt className="co-details-card__item-title">{title}</dt> | ||
| <dd className={classNames('co-details-card__item-value', {'text-secondary': !value})}> | ||
| {isLoading ? <LoadingInline /> : value || 'Unavailable'} | ||
| </dd> | ||
| </React.Fragment> | ||
| )); | ||
| export const DetailItem: React.FC<DetailItemProps> = React.memo( | ||
| ({ title, isLoading = false, children, error = false }) => { | ||
| let status: React.ReactNode; | ||
| if (isLoading) { | ||
| status = <LoadingInline />; | ||
| } else if (error) { | ||
| status = <span className="text-secondary">Unavailable</span>; | ||
| } else { | ||
| status = children; | ||
| } | ||
| return ( | ||
| <React.Fragment> | ||
| <dt className="co-details-card__item-title">{title}</dt> | ||
| <dd className="co-details-card__item-value">{status}</dd> | ||
| </React.Fragment> | ||
| ); | ||
| } | ||
| ); | ||
|
|
||
| type DetailItemProps = { | ||
| title: string; | ||
| value?: string; | ||
| isLoading: boolean; | ||
| isLoading?: boolean; | ||
| error?: boolean; | ||
| children: React.ReactNode; | ||
|
||
| }; | ||
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.
@rawagner Please be advised, @jtomasek adds this to
console-sharedselectors in his PR #2558.https://github.com/openshift/console/pull/2558/files#diff-25304ce4310324e88754e9516a46ac5c
Once #2558 is merged, we should update our existing code to use this shared selector.
This also applies to code below.
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.
ok, I will update the existing code then
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.
Hmm, I'm wondering if there are any duplicate code detectors for TypeScript / JavaScript, which can calculate code similarity (e.g. percentage) between files.