1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Merge remote-tracking branch 'origin/master' into mobx-6.2

# Conflicts:
#	src/renderer/components/+catalog/catalog.tsx
This commit is contained in:
Roman 2021-05-03 18:51:40 +03:00
commit a840eccc28
3 changed files with 31 additions and 26 deletions

View File

@ -64,7 +64,7 @@ export class CatalogEntityItem implements ItemObject {
}
export class CatalogEntityStore extends ItemStore<CatalogEntityItem> {
@observable activeCategory: CatalogCategory;
@observable activeCategory?: CatalogCategory;
constructor() {
super();
@ -73,7 +73,9 @@ export class CatalogEntityStore extends ItemStore<CatalogEntityItem> {
}
@computed get entities() {
if (!this.activeCategory) return [];
if (!this.activeCategory) {
return catalogEntityRegistry.items.map(entity => new CatalogEntityItem(entity));
}
return catalogEntityRegistry.getItemsForCategory(this.activeCategory).map(entity => new CatalogEntityItem(entity));
}

View File

@ -28,7 +28,7 @@ enum sortBy {
export class Catalog extends React.Component {
@observable private catalogEntityStore?: CatalogEntityStore;
@observable private contextMenu: CatalogEntityContextMenuContext;
@observable activeTab: string;
@observable activeTab?: string;
constructor(props: object) {
super(props);
@ -82,14 +82,11 @@ export class Catalog extends React.Component {
}
@action
onTabChange = (tabId: string) => {
this.activeTab = tabId;
onTabChange = (tabId: string | null) => {
const activeCategory = this.categories.find(category => category.getId() === tabId);
const activeCategory = this.categories.find((category) => category.getId() === tabId);
if (activeCategory) {
this.catalogEntityStore.activeCategory = activeCategory;
}
this.catalogEntityStore.activeCategory = activeCategory;
this.activeTab = activeCategory?.getId();
};
renderNavigation() {
@ -97,9 +94,19 @@ export class Catalog extends React.Component {
<Tabs className="flex column" scrollable={false} onChange={this.onTabChange} value={this.activeTab}>
<div className="sidebarHeader">Catalog</div>
<div className="sidebarTabs">
{this.categories.map((category, index) => {
return <Tab value={category.getId()} key={index} label={category.metadata.name} data-testid={`${category.getId()}-tab`}/>;
})}
<Tab
value={undefined}
key="*"
label="Browse"
data-testid="*-tab"
/>
{this.categories.map(category => (
<Tab
value={category.getId()}
key={category.getId()} label={category.metadata.name} data-testid={`${category.getId()}-tab`}
/>
))
}
</div>
</Tabs>
);
@ -108,22 +115,18 @@ export class Catalog extends React.Component {
@autobind()
renderItemMenu(item: CatalogEntityItem) {
const menuItems = this.contextMenu.menuItems.filter((menuItem) => !menuItem.onlyVisibleForSource || menuItem.onlyVisibleForSource === item.entity.metadata.source);
const onOpen = async () => {
await item.onContextMenuOpen(this.contextMenu);
};
return (
<MenuActions onOpen={() => onOpen()}>
<MenuActions onOpen={() => item.onContextMenuOpen(this.contextMenu)}>
<MenuItem key="add-to-hotbar" onClick={() => this.addToHotbar(item)}>
<Icon material="add" small interactive={true} title="Add to hotbar"/> Add to Hotbar
</MenuItem>
{menuItems.map((menuItem, index) => {
return (
{menuItems.map((menuItem, index) => (
<MenuItem key={index} onClick={() => this.onMenuItemClick(menuItem)}>
<Icon material={menuItem.icon} small interactive={true} title={menuItem.title}/> {menuItem.title}
<Icon material={menuItem.icon} small interactive={true} title={menuItem.title} /> {menuItem.title}
</MenuItem>
);
})}
))
}
</MenuActions>
);
}
@ -140,7 +143,7 @@ export class Catalog extends React.Component {
provideBackButtonNavigation={false}
contentGaps={false}>
<ItemListLayout
renderHeaderTitle={this.catalogEntityStore.activeCategory?.metadata.name}
renderHeaderTitle={this.catalogEntityStore.activeCategory?.metadata.name ?? "Browse All"}
isClusterScoped
isSearchable={true}
isSelectable={false}

View File

@ -12897,9 +12897,9 @@ sshpk@^1.7.0:
tweetnacl "~0.14.0"
ssri@^6.0.0, ssri@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/ssri/-/ssri-6.0.1.tgz#2a3c41b28dd45b62b63676ecb74001265ae9edd8"
integrity sha512-3Wge10hNcT1Kur4PDFwEieXSCMCJs/7WvSACcrMYrNp+b8kDL1/0wJch5Ni2WrtwEa2IO8OsVfeKIciKCDx/QA==
version "6.0.2"
resolved "https://registry.yarnpkg.com/ssri/-/ssri-6.0.2.tgz#157939134f20464e7301ddba3e90ffa8f7728ac5"
integrity sha512-cepbSq/neFK7xB6A50KHN0xHDotYzq58wWCa5LeWqnPrHG8GzfEjO/4O8kpmcGW+oaxkvhEJCWgbgNk4/ZV93Q==
dependencies:
figgy-pudding "^3.5.1"