mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
added getById() to portForwardStore to eliminate direct items access from outside
Signed-off-by: Jim Ehrismann <jehrismann@mirantis.com>
This commit is contained in:
parent
01faec3a05
commit
b6a1e3b81c
@ -55,9 +55,7 @@ export class PortForwards extends React.Component<Props> {
|
||||
get selectedPortForward() {
|
||||
const { match: { params: { forwardport } } } = this.props;
|
||||
|
||||
return portForwardStore.items.find(pf => {
|
||||
return pf.getForwardPort() == Number(forwardport);
|
||||
});
|
||||
return portForwardStore.getById(forwardport);
|
||||
}
|
||||
|
||||
onDetails = (item: PortForwardItem) => {
|
||||
|
||||
@ -81,6 +81,16 @@ export class PortForwardStore extends ItemStore<PortForwardItem> {
|
||||
async removeSelectedItems() {
|
||||
return Promise.all(this.selectedItems.map(removePortForward));
|
||||
}
|
||||
|
||||
getById(id: string) {
|
||||
const index = this.getIndexById(id);
|
||||
|
||||
if (index === -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.getItems()[index];
|
||||
}
|
||||
}
|
||||
|
||||
interface PortForwardResult {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user