-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9dbf9dd
commit 2f5daee
Showing
8 changed files
with
234 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
frontend/packages/knative-plugin/src/components/eventing/BrokerDetailsPage.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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import * as React from 'react'; | ||
import { DetailsPage, ListPage } from '@console/internal/components/factory'; | ||
import { navFactory, Kebab, Page } from '@console/internal/components/utils'; | ||
|
||
import { DetailsForKind } from '@console/internal/components/default-resource'; | ||
import { EventingBrokerModel, EventingTriggerModel } from '../../models'; | ||
import TriggerList from './triggers-list/TriggerList'; | ||
import { referenceForModel } from '@console/internal/module/k8s'; | ||
// import BrokerTriggers from './BrokerTriggers'; | ||
|
||
const BrokerDetailsPage: React.FC<React.ComponentProps<typeof DetailsPage>> = (props) => { | ||
const pages: Page[] = [ | ||
navFactory.details(DetailsForKind(props.kind)), | ||
navFactory.editYaml(), | ||
{ | ||
href: 'triggers', | ||
name: 'Triggers', | ||
component: ListPage, | ||
pageData: { | ||
canCreate: false, | ||
showTitle: false, | ||
kind: referenceForModel(EventingTriggerModel), | ||
ListComponent: TriggerList, | ||
}, | ||
}, | ||
]; | ||
|
||
const customData = { | ||
broker: props.name, | ||
}; | ||
|
||
const commonActions = Kebab.factory.common.map((action) => action); | ||
const menuActionsCreator = [ | ||
...Kebab.getExtensionsActionsForKind(EventingBrokerModel), | ||
...commonActions, | ||
]; | ||
|
||
return ( | ||
<DetailsPage | ||
{...props} | ||
pages={pages} | ||
menuActions={menuActionsCreator} | ||
customData={customData} | ||
/> | ||
); | ||
}; | ||
|
||
export default BrokerDetailsPage; |
49 changes: 49 additions & 0 deletions
49
frontend/packages/knative-plugin/src/components/eventing/triggers-list/TriggerHeaders.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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { sortable } from '@patternfly/react-table'; | ||
import { tableColumnClasses } from './trigger-table'; | ||
|
||
const TriggerHeaders = () => { | ||
return [ | ||
{ | ||
id: 'name', | ||
title: 'Name', | ||
sortField: 'metadata.name', | ||
transforms: [sortable], | ||
props: { className: tableColumnClasses[0] }, | ||
}, | ||
{ | ||
id: 'namespace', | ||
title: 'Namespace', | ||
sortField: 'metadata.namespace', | ||
transforms: [sortable], | ||
props: { className: tableColumnClasses[1] }, | ||
}, | ||
{ | ||
id: 'ready', | ||
title: 'Ready', | ||
props: { className: tableColumnClasses[2] }, | ||
}, | ||
{ | ||
id: 'condition', | ||
title: 'Condition', | ||
props: { className: tableColumnClasses[3] }, | ||
}, | ||
{ | ||
id: 'filters', | ||
title: 'Filters', | ||
props: { className: tableColumnClasses[4] }, | ||
}, | ||
{ | ||
id: 'subscriber', | ||
title: 'Subscriber', | ||
props: { className: tableColumnClasses[5] }, | ||
}, | ||
{ | ||
title: 'Created', | ||
sortField: 'metadata.creationTimestamp', | ||
transforms: [sortable], | ||
props: { className: tableColumnClasses[6] }, | ||
}, | ||
]; | ||
}; | ||
|
||
export default TriggerHeaders; |
10 changes: 10 additions & 0 deletions
10
frontend/packages/knative-plugin/src/components/eventing/triggers-list/TriggerList.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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import * as React from 'react'; | ||
import { Table, TableProps } from '@console/internal/components/factory'; | ||
import TriggerHeaders from './TriggerHeaders'; | ||
import TriggerRow from './TriggerRow'; | ||
|
||
const TriggerList: React.FC<TableProps> = (props) => ( | ||
<Table {...props} aria-label="Triggers" Header={TriggerHeaders} Row={TriggerRow} virtualize /> | ||
); | ||
|
||
export default TriggerList; |
16 changes: 16 additions & 0 deletions
16
frontend/packages/knative-plugin/src/components/eventing/triggers-list/TriggerListPage.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as React from 'react'; | ||
import { ListPage } from '@console/internal/components/factory'; | ||
import { referenceForModel } from '@console/internal/module/k8s'; | ||
import { EventingTriggerModel } from '../../../models'; | ||
import TriggerList from './TriggerList'; | ||
|
||
const TriggerListPage: React.FC<React.ComponentProps<typeof ListPage>> = (props) => ( | ||
<ListPage | ||
canCreate={false} | ||
{...props} | ||
kind={referenceForModel(EventingTriggerModel)} | ||
ListComponent={TriggerList} | ||
/> | ||
); | ||
|
||
export default TriggerListPage; |
71 changes: 71 additions & 0 deletions
71
frontend/packages/knative-plugin/src/components/eventing/triggers-list/TriggerRow.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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import * as React from 'react'; | ||
import { TableRow, TableData, RowFunction } from '@console/internal/components/factory'; | ||
import { Kebab, ResourceKebab, ResourceLink, Timestamp } from '@console/internal/components/utils'; | ||
import { referenceFor } from '@console/internal/module/k8s'; | ||
import { EventingTriggerModel } from '../../../models'; | ||
import { getConditionString, getCondition } from '../../../utils/condition-utils'; | ||
import { EventTriggerKind, TriggerConditionTypes } from '../../../types'; | ||
import { tableColumnClasses } from './trigger-table'; | ||
|
||
type TriggerRowType = { | ||
broker?: string; | ||
}; | ||
const TriggerRow: RowFunction<EventTriggerKind, TriggerRowType> = ({ | ||
obj, | ||
index, | ||
key, | ||
style, | ||
customData, | ||
}) => { | ||
const { | ||
metadata: { name, namespace, creationTimestamp, uid }, | ||
spec: { subscriber, filter, broker: connectedBroker }, | ||
} = obj; | ||
|
||
if (customData?.broker && customData.broker === connectedBroker) { | ||
return null; | ||
} | ||
|
||
const objReference = referenceFor(obj); | ||
const menuActions = [ | ||
...Kebab.getExtensionsActionsForKind(EventingTriggerModel), | ||
...Kebab.factory.common, | ||
]; | ||
const readyCondition = obj.status | ||
? getCondition(obj.status.conditions, TriggerConditionTypes.Ready) | ||
: null; | ||
return ( | ||
<TableRow id={uid} index={index} trKey={key} style={style}> | ||
<TableData columnID="name" className={tableColumnClasses[0]}> | ||
<ResourceLink kind={objReference} name={name} namespace={namespace} title={uid} /> | ||
</TableData> | ||
<TableData columnID="namespace" className={tableColumnClasses[1]}> | ||
<ResourceLink kind="Namespace" name={namespace} /> | ||
</TableData> | ||
<TableData columnID="ready" className={tableColumnClasses[2]}> | ||
{(readyCondition && readyCondition.status) || '-'} | ||
</TableData> | ||
<TableData columnID="condition" className={tableColumnClasses[3]}> | ||
{obj.status ? getConditionString(obj.status.conditions) : '-'} | ||
</TableData> | ||
<TableData columnID="filters" className={tableColumnClasses[4]}> | ||
{filter.attributes | ||
? Object.entries(filter.attributes).map(([fkey, val]) => ( | ||
<div key={fkey}>{`${fkey}:${val}`}</div> | ||
)) | ||
: '-'} | ||
</TableData> | ||
<TableData columnID="subscriber" className={tableColumnClasses[5]}> | ||
<ResourceLink kind={subscriber.ref.kind} name={subscriber.ref.name} namespace={namespace} /> | ||
</TableData> | ||
<TableData columnID="created" className={tableColumnClasses[6]}> | ||
<Timestamp timestamp={creationTimestamp} /> | ||
</TableData> | ||
<TableData className={tableColumnClasses[7]}> | ||
<ResourceKebab actions={menuActions} kind={objReference} resource={obj} /> | ||
</TableData> | ||
</TableRow> | ||
); | ||
}; | ||
|
||
export default TriggerRow; |
13 changes: 13 additions & 0 deletions
13
frontend/packages/knative-plugin/src/components/eventing/triggers-list/trigger-table.ts
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,13 @@ | ||
import * as cx from 'classnames'; | ||
import { Kebab } from '@console/internal/components/utils'; | ||
|
||
export const tableColumnClasses = [ | ||
'', // name | ||
'', // namespace | ||
cx('pf-m-hidden', 'pf-m-visible-on-xl'), // ready | ||
cx('pf-m-hidden', 'pf-m-visible-on-xl'), // condition | ||
cx('pf-m-hidden', 'pf-m-visible-on-sm'), // filters | ||
'', // subscriber | ||
cx('pf-m-hidden', 'pf-m-visible-on-lg'), // created | ||
Kebab.columnClass, // kebab menu | ||
]; |
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