Skip to content

Commit

Permalink
Introduce registries selection
Browse files Browse the repository at this point in the history
  • Loading branch information
marusak committed Jul 21, 2020
1 parent 8699ba4 commit cacd432
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
26 changes: 20 additions & 6 deletions src/ImageSearchModal.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import { ListGroup, ListGroupItem, Modal } from 'patternfly-react';
import { Button, InputGroup, InputGroupText } from '@patternfly/react-core';
import { SearchIcon } from '@patternfly/react-icons';
import { Button, InputGroup } from '@patternfly/react-core';

import * as Select from '../lib/cockpit-components-select.jsx';
import { ErrorNotification } from './Notification.jsx';
import cockpit from 'cockpit';
import rest from './rest.js';
Expand All @@ -22,6 +22,7 @@ export class ImageSearchModal extends React.Component {
searchInProgress: false,
searchFinished: false,
isSystem: props.systemServiceAvailable,
registry: "",
};
this.onDownloadClicked = this.onDownloadClicked.bind(this);
this.onItemSelected = this.onItemSelected.bind(this);
Expand Down Expand Up @@ -77,7 +78,7 @@ export class ImageSearchModal extends React.Component {
path: "/v1.12/libpod/images/search",
body: "",
params: {
term: this.state.imageIdentifier,
term: this.state.registry + this.state.imageIdentifier,
},
};
this.activeConnection.call(options)
Expand Down Expand Up @@ -130,9 +131,22 @@ export class ImageSearchModal extends React.Component {
</form>
}
<InputGroup>
<InputGroupText id="username" aria-label={_("Search")}>
<SearchIcon />
</InputGroupText>
<Select.Select id='registry-select'
initial={this.state.registry}
onChange={value =>
this.setState({ registry: value }, () => this.onSearchTriggered(false))
}>
<Select.SelectEntry data="" key="all">
{_("All registries")}
</Select.SelectEntry>
{ (this.props.registries.search || []).map(r => {
const rx = r[r.length - 1] === "/" ? r : r + "/";
return <Select.SelectEntry data={rx} key={rx}>
{rx}
</Select.SelectEntry>;
})
}
</Select.Select>
<input id='search-image-dialog-name'
autoFocus
className='form-control'
Expand Down
1 change: 1 addition & 0 deletions src/Images.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ class Images extends React.Component {
close={() => this.setState({ showSearchImageModal: false })}
downloadImage={this.downloadImage}
user={this.props.user}
registries={this.props.registries}
userServiceAvailable={this.props.userServiceAvailable}
systemServiceAvailable={this.props.systemServiceAvailable} /> }
{this.state.imageDownloadInProgress && <div className='download-in-progress'> {_("Pulling")} {this.state.imageDownloadInProgress}... </div>}
Expand Down
7 changes: 6 additions & 1 deletion src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,11 @@ class Application extends React.Component {
init(system) {
client.getInfo(system)
.then(reply => {
this.setState({ [system ? "systemServiceAvailable" : "userServiceAvailable"]: true, version: reply.version.Version });
this.setState({
[system ? "systemServiceAvailable" : "userServiceAvailable"]: true,
version: reply.version.Version,
registries: reply.registries,
});
this.updateImagesAfterEvent(system);
this.updateContainersAfterEvent(system, true);
client.streamEvents(system,
Expand Down Expand Up @@ -514,6 +518,7 @@ class Application extends React.Component {
user={permission.user || _("user")}
userServiceAvailable={this.state.userServiceAvailable}
systemServiceAvailable={this.state.systemServiceAvailable}
registries={this.state.registries}
/>;
const containerList =
<Containers
Expand Down
3 changes: 3 additions & 0 deletions src/podman.scss
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,6 @@
font-weight: 400;
}

#registry-select option:first-child {
font-style: italic;
}

0 comments on commit cacd432

Please sign in to comment.