-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update preview panel to align with latest ux (#3115)
- Loading branch information
1 parent
415b3b3
commit b8b44ea
Showing
25 changed files
with
371 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import * as React from 'react'; | ||
import { Label } from '@patternfly/react-core'; | ||
|
||
type Props = { | ||
category: string; | ||
}; | ||
|
||
const CategoryLabel: React.FC<Props> = ({ category }) => <Label color="purple">{category}</Label>; | ||
|
||
export default CategoryLabel; |
131 changes: 100 additions & 31 deletions
131
frontend/src/concepts/connectionTypes/ConnectionTypePreview.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,113 @@ | ||
import * as React from 'react'; | ||
import { Divider, Form, FormGroup, FormSection, Title } from '@patternfly/react-core'; | ||
import FormGroupText from '~/components/FormGroupText'; | ||
import { | ||
Button, | ||
DescriptionList, | ||
DescriptionListDescription, | ||
DescriptionListGroup, | ||
DescriptionListTerm, | ||
Form, | ||
FormGroup, | ||
FormSection, | ||
HelperText, | ||
HelperTextItem, | ||
LabelGroup, | ||
MenuToggleStatus, | ||
Popover, | ||
Title, | ||
} from '@patternfly/react-core'; | ||
import ConnectionTypeFormFields from '~/concepts/connectionTypes/fields/ConnectionTypeFormFields'; | ||
import { ConnectionTypeConfigMapObj } from '~/concepts/connectionTypes/types'; | ||
import NameDescriptionField from '~/concepts/k8s/NameDescriptionField'; | ||
import { getDescriptionFromK8sResource, getDisplayNameFromK8sResource } from '~/concepts/k8s/utils'; | ||
import { getDescriptionFromK8sResource } from '~/concepts/k8s/utils'; | ||
import UnspecifiedValue from '~/concepts/connectionTypes/fields/UnspecifiedValue'; | ||
import SimpleSelect from '~/components/SimpleSelect'; | ||
import CategoryLabel from '~/concepts/connectionTypes/CategoryLabel'; | ||
import TruncatedText from '~/components/TruncatedText'; | ||
|
||
type Props = { | ||
obj?: ConnectionTypeConfigMapObj; | ||
}; | ||
|
||
const ConnectionTypePreview: React.FC<Props> = ({ obj }) => ( | ||
<Form> | ||
<Title headingLevel="h1">Add connection</Title> | ||
<FormSection title="Connection type details" style={{ marginTop: 0 }}> | ||
<FormGroup label="Connection type name" fieldId="connection-type-name"> | ||
<FormGroupText id="connection-type-name"> | ||
{(obj && getDisplayNameFromK8sResource(obj)) || <UnspecifiedValue />} | ||
</FormGroupText> | ||
// TODO consider refactoring this form for reuse when creating connection type instances | ||
const ConnectionTypePreview: React.FC<Props> = ({ obj }) => { | ||
const connectionTypeName = obj && obj.metadata.annotations?.['openshift.io/display-name']; | ||
const connectionTypeDescription = (obj && getDescriptionFromK8sResource(obj)) ?? undefined; | ||
return ( | ||
<Form> | ||
<Title headingLevel="h1">Add connection</Title> | ||
<FormGroup label="Connection type" fieldId="connection-type" isRequired> | ||
<SimpleSelect | ||
id="connection-type" | ||
isFullWidth | ||
toggleLabel={connectionTypeName || 'Unspecified'} | ||
isDisabled={!!connectionTypeName} | ||
toggleProps={connectionTypeName ? undefined : { status: MenuToggleStatus.danger }} | ||
onChange={() => undefined} | ||
/> | ||
<HelperText> | ||
{connectionTypeDescription ? ( | ||
<HelperTextItem> | ||
<TruncatedText maxLines={2} content={connectionTypeDescription} /> | ||
</HelperTextItem> | ||
) : undefined} | ||
<HelperTextItem> | ||
<Popover | ||
headerContent="Connection type details" | ||
bodyContent={ | ||
<DescriptionList> | ||
<DescriptionListGroup> | ||
<DescriptionListTerm>Connection type name</DescriptionListTerm> | ||
<DescriptionListDescription> | ||
{connectionTypeName || <UnspecifiedValue />} | ||
</DescriptionListDescription> | ||
</DescriptionListGroup> | ||
{connectionTypeDescription ? ( | ||
<DescriptionListGroup> | ||
<DescriptionListTerm>Connection type description</DescriptionListTerm> | ||
<DescriptionListDescription> | ||
{connectionTypeDescription || <UnspecifiedValue />} | ||
</DescriptionListDescription> | ||
</DescriptionListGroup> | ||
) : undefined} | ||
<DescriptionListGroup> | ||
<DescriptionListTerm>Category</DescriptionListTerm> | ||
<DescriptionListDescription> | ||
{obj?.data?.category?.length ? ( | ||
<LabelGroup> | ||
{obj.data.category.map((category) => ( | ||
<CategoryLabel key={category} category={category} /> | ||
))} | ||
</LabelGroup> | ||
) : ( | ||
<UnspecifiedValue /> | ||
)} | ||
</DescriptionListDescription> | ||
</DescriptionListGroup> | ||
</DescriptionList> | ||
} | ||
> | ||
<Button variant="link" isInline> | ||
View connection type details | ||
</Button> | ||
</Popover> | ||
</HelperTextItem> | ||
</HelperText> | ||
</FormGroup> | ||
<FormGroup label="Connection type description" fieldId="connection-type-description"> | ||
<FormGroupText id="connection-type-description"> | ||
{(obj && getDescriptionFromK8sResource(obj)) || <UnspecifiedValue />} | ||
</FormGroupText> | ||
</FormGroup> | ||
</FormSection> | ||
<Divider /> | ||
<FormSection title="Connection details" style={{ marginTop: 0 }}> | ||
<NameDescriptionField | ||
nameFieldId="connection-details-name" | ||
descriptionFieldId="connection-details-description" | ||
data={{ | ||
name: '', | ||
description: '', | ||
}} | ||
/> | ||
<ConnectionTypeFormFields fields={obj?.data?.fields} isPreview /> | ||
</FormSection> | ||
</Form> | ||
); | ||
<FormSection title="Connection details" style={{ marginTop: 0 }}> | ||
<NameDescriptionField | ||
nameFieldId="connection-details-name" | ||
descriptionFieldId="connection-details-description" | ||
nameFieldLabel="Connection name" | ||
descriptionFieldLabel="Connection description" | ||
data={{ | ||
name: '', | ||
description: '', | ||
}} | ||
/> | ||
<ConnectionTypeFormFields fields={obj?.data?.fields} isPreview /> | ||
</FormSection> | ||
</Form> | ||
); | ||
}; | ||
|
||
export default ConnectionTypePreview; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.