|
|
@@ -38,81 +38,81 @@ export default class ImageSelector extends Component<PropsType, StateType> {
|
|
|
clickedImage: null as ImageType | null,
|
|
|
};
|
|
|
|
|
|
- componentDidMount() {
|
|
|
- const { currentProject, setCurrentError } = this.context;
|
|
|
- let images = [] as ImageType[];
|
|
|
- let errors = [] as number[];
|
|
|
- api
|
|
|
- .getProjectRegistries("<token>", {}, { id: currentProject.id })
|
|
|
- .then(async (res) => {
|
|
|
- let registries = res.data;
|
|
|
- if (registries.length === 0) {
|
|
|
- this.setState({ loading: false });
|
|
|
- }
|
|
|
-
|
|
|
- // Loop over connected image registries
|
|
|
- registries.forEach(async (registry: any, i: number) => {
|
|
|
- await new Promise((nextController: (res?: any) => void) => {
|
|
|
- api
|
|
|
- .getImageRepos(
|
|
|
- "<token>",
|
|
|
- {},
|
|
|
- {
|
|
|
- project_id: currentProject.id,
|
|
|
- registry_id: registry.id,
|
|
|
- }
|
|
|
- )
|
|
|
- .then((res) => {
|
|
|
- res.data.sort((a: any, b: any) => (a.name > b.name ? 1 : -1));
|
|
|
- // Loop over found image repositories
|
|
|
- let newImg = res.data.map((img: any) => {
|
|
|
- if (this.props.selectedImageUrl === img.uri) {
|
|
|
- this.setState({
|
|
|
- clickedImage: {
|
|
|
- kind: registry.service,
|
|
|
- source: img.uri,
|
|
|
- name: img.name,
|
|
|
- registryId: registry.id,
|
|
|
- },
|
|
|
- });
|
|
|
- }
|
|
|
- return {
|
|
|
- kind: registry.service,
|
|
|
- source: img.uri,
|
|
|
- name: img.name,
|
|
|
- registryId: registry.id,
|
|
|
- };
|
|
|
- });
|
|
|
- images.push(...newImg);
|
|
|
- errors.push(0);
|
|
|
- })
|
|
|
- .catch(() => errors.push(1))
|
|
|
- .finally(() => {
|
|
|
- if (i == registries.length - 1) {
|
|
|
- let error =
|
|
|
- errors.reduce((a, b) => {
|
|
|
- return a + b;
|
|
|
- }) == registries.length
|
|
|
- ? true
|
|
|
- : false;
|
|
|
-
|
|
|
- this.setState({
|
|
|
- images,
|
|
|
- loading: false,
|
|
|
- error,
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- nextController();
|
|
|
- });
|
|
|
- });
|
|
|
- });
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- console.log(err);
|
|
|
- this.setState({ error: true });
|
|
|
- });
|
|
|
- }
|
|
|
+ // componentDidMount() {
|
|
|
+ // const { currentProject, setCurrentError } = this.context;
|
|
|
+ // let images = [] as ImageType[];
|
|
|
+ // let errors = [] as number[];
|
|
|
+ // api
|
|
|
+ // .getProjectRegistries("<token>", {}, { id: currentProject.id })
|
|
|
+ // .then(async (res) => {
|
|
|
+ // let registries = res.data;
|
|
|
+ // if (registries.length === 0) {
|
|
|
+ // this.setState({ loading: false });
|
|
|
+ // }
|
|
|
+
|
|
|
+ // // Loop over connected image registries
|
|
|
+ // registries.forEach(async (registry: any, i: number) => {
|
|
|
+ // await new Promise((nextController: (res?: any) => void) => {
|
|
|
+ // api
|
|
|
+ // .getImageRepos(
|
|
|
+ // "<token>",
|
|
|
+ // {},
|
|
|
+ // {
|
|
|
+ // project_id: currentProject.id,
|
|
|
+ // registry_id: registry.id,
|
|
|
+ // }
|
|
|
+ // )
|
|
|
+ // .then((res) => {
|
|
|
+ // res.data.sort((a: any, b: any) => (a.name > b.name ? 1 : -1));
|
|
|
+ // // Loop over found image repositories
|
|
|
+ // let newImg = res.data.map((img: any) => {
|
|
|
+ // if (this.props.selectedImageUrl === img.uri) {
|
|
|
+ // this.setState({
|
|
|
+ // clickedImage: {
|
|
|
+ // kind: registry.service,
|
|
|
+ // source: img.uri,
|
|
|
+ // name: img.name,
|
|
|
+ // registryId: registry.id,
|
|
|
+ // },
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // return {
|
|
|
+ // kind: registry.service,
|
|
|
+ // source: img.uri,
|
|
|
+ // name: img.name,
|
|
|
+ // registryId: registry.id,
|
|
|
+ // };
|
|
|
+ // });
|
|
|
+ // images.push(...newImg);
|
|
|
+ // errors.push(0);
|
|
|
+ // })
|
|
|
+ // .catch(() => errors.push(1))
|
|
|
+ // .finally(() => {
|
|
|
+ // if (i == registries.length - 1) {
|
|
|
+ // let error =
|
|
|
+ // errors.reduce((a, b) => {
|
|
|
+ // return a + b;
|
|
|
+ // }) == registries.length
|
|
|
+ // ? true
|
|
|
+ // : false;
|
|
|
+
|
|
|
+ // this.setState({
|
|
|
+ // images,
|
|
|
+ // loading: false,
|
|
|
+ // error,
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+
|
|
|
+ // nextController();
|
|
|
+ // });
|
|
|
+ // });
|
|
|
+ // });
|
|
|
+ // })
|
|
|
+ // .catch((err) => {
|
|
|
+ // console.log(err);
|
|
|
+ // this.setState({ error: true });
|
|
|
+ // });
|
|
|
+ // }
|
|
|
|
|
|
/*
|
|
|
<Highlight onClick={() => this.props.setCurrentView('integrations')}>
|