-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7520 from invincibleJai/odc-5228
Bug 1906685: show sinkbinding as resources in sidebar if owned by source
- Loading branch information
Showing
9 changed files
with
202 additions
and
114 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
frontend/packages/knative-plugin/src/components/overview/EventSourceOwnedList.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,27 @@ | ||
import * as React from 'react'; | ||
import { SidebarSectionHeading, ResourceLink } from '@console/internal/components/utils'; | ||
import { K8sResourceKind, modelFor, referenceFor } from '@console/internal/module/k8s'; | ||
|
||
type EventSourceOwnedListProps = { | ||
source: K8sResourceKind; | ||
}; | ||
|
||
const EventSourceOwnedList: React.FC<EventSourceOwnedListProps> = ({ source }) => { | ||
const sourceModel = modelFor(referenceFor(source)); | ||
return ( | ||
<> | ||
<SidebarSectionHeading text={sourceModel?.label ?? source.kind} /> | ||
<ul className="list-group"> | ||
<li className="list-group-item"> | ||
<ResourceLink | ||
kind={referenceFor(source)} | ||
name={source.metadata?.name} | ||
namespace={source.metadata?.namespace} | ||
/> | ||
</li> | ||
</ul> | ||
</> | ||
); | ||
}; | ||
|
||
export default EventSourceOwnedList; |
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
22 changes: 22 additions & 0 deletions
22
...d/packages/knative-plugin/src/components/overview/__tests__/EventSourceOwnedList.spec.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,22 @@ | ||
import * as React from 'react'; | ||
import { shallow, ShallowWrapper } from 'enzyme'; | ||
import { K8sResourceKind } from '@console/internal/module/k8s'; | ||
import { ResourceLink, SidebarSectionHeading } from '@console/internal/components/utils'; | ||
import EventSourceOwnedList from '../EventSourceOwnedList'; | ||
import { getEventSourceResponse } from '../../../topology/__tests__/topology-knative-test-data'; | ||
import { EventSourceSinkBindingModel } from '../../../models'; | ||
|
||
type EventSourceOwnedListProps = React.ComponentProps<typeof EventSourceOwnedList>; | ||
|
||
describe('EventSourceOwnedList', () => { | ||
const mockData: K8sResourceKind = getEventSourceResponse(EventSourceSinkBindingModel).data[0]; | ||
let wrapper: ShallowWrapper<EventSourceOwnedListProps>; | ||
beforeEach(() => { | ||
wrapper = shallow(<EventSourceOwnedList source={mockData} />); | ||
}); | ||
|
||
it('should render SidebarSectionHeading, ResourceLink', () => { | ||
expect(wrapper.find(SidebarSectionHeading)).toHaveLength(1); | ||
expect(wrapper.find(ResourceLink)).toHaveLength(1); | ||
}); | ||
}); |
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
Oops, something went wrong.