Skip to content

Commit a17c77e

Browse files
author
Alexander Matyushentsev
authored
feat: allow selecting application on detail page (argoproj#8176)
Signed-off-by: Alexander Matyushentsev <AMatyushentsev@gmail.com>
1 parent dc24d05 commit a17c77e

File tree

3 files changed

+61
-2
lines changed

3 files changed

+61
-2
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import {DataLoader, DropDown} from 'argo-ui';
2+
import * as React from 'react';
3+
4+
import {Context} from '../../../shared/context';
5+
import {services} from '../../../shared/services';
6+
7+
export const ApplicationsDetailsAppDropdown = (props: {appName: string}) => {
8+
const [opened, setOpened] = React.useState(false);
9+
const [appFilter, setAppFilter] = React.useState('');
10+
const ctx = React.useContext(Context);
11+
return (
12+
<DropDown
13+
onOpenStateChange={setOpened}
14+
isMenu={true}
15+
anchor={() => (
16+
<>
17+
<i className='fa fa-search' /> <span>{props.appName}</span>
18+
</>
19+
)}>
20+
{opened && (
21+
<ul>
22+
<li>
23+
<input
24+
className='argo-field'
25+
value={appFilter}
26+
onChange={e => setAppFilter(e.target.value)}
27+
ref={el =>
28+
el &&
29+
setTimeout(() => {
30+
if (el) {
31+
el.focus();
32+
}
33+
}, 100)
34+
}
35+
/>
36+
</li>
37+
<DataLoader load={() => services.applications.list([], {fields: ['items.metadata.name']})}>
38+
{apps =>
39+
apps.items
40+
.filter(app => {
41+
return appFilter.length === 0 || app.metadata.name.toLowerCase().includes(appFilter.toLowerCase());
42+
})
43+
.slice(0, 100) // take top 100 results after filtering to avoid performance issues
44+
.map(app => (
45+
<li key={app.metadata.name} onClick={() => ctx.navigation.goto(`/applications/${app.metadata.name}`)}>
46+
{app.metadata.name} {app.metadata.name === props.appName && ' (current)'}
47+
</li>
48+
))
49+
}
50+
</DataLoader>
51+
</ul>
52+
)}
53+
</DropDown>
54+
);
55+
};

ui/src/app/applications/components/application-details/application-details.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {ApplicationResourceList} from './application-resource-list';
2525
import {Filters} from './application-resource-filter';
2626
import {urlPattern} from '../utils';
2727
import {ResourceStatus} from '../../../shared/models';
28+
import {ApplicationsDetailsAppDropdown} from './application-details-app-dropdown';
2829

2930
require('./application-details.scss');
3031

@@ -217,7 +218,10 @@ export class ApplicationDetails extends React.Component<RouteComponentProps<{nam
217218
useTitleOnly={true}
218219
topBarTitle={this.getPageTitle(pref.view)}
219220
toolbar={{
220-
breadcrumbs: [{title: 'Applications', path: '/applications'}, {title: this.props.match.params.name}],
221+
breadcrumbs: [
222+
{title: 'Applications', path: '/applications'},
223+
{title: <ApplicationsDetailsAppDropdown appName={this.props.match.params.name} />}
224+
],
221225
actionMenu: {items: this.getApplicationActionMenu(application, true)},
222226
tools: (
223227
<React.Fragment key='app-list-tools'>

ui/yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1762,7 +1762,7 @@ are-we-there-yet@~1.1.2:
17621762

17631763
"argo-ui@git+https://github.com/argoproj/argo-ui.git":
17641764
version "1.0.0"
1765-
resolved "git+https://github.com/argoproj/argo-ui.git#2da0b48fbaffc7c64a73f6a7de772ac4a60b8277"
1765+
resolved "git+https://github.com/argoproj/argo-ui.git#4336822c14164f36eb9d0a6b6c3c40560df4c4d7"
17661766
dependencies:
17671767
"@fortawesome/fontawesome-free" "^5.15.2"
17681768
"@tippy.js/react" "^2.1.2"

0 commit comments

Comments
 (0)