Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • andersharrisson/ce-deploy-ui
  • ccce/dev/ce-deploy-ui
2 results
Show changes
Commits on Source (2)
......@@ -283,19 +283,6 @@ export function unpackGitProject(project) {
return { ...project };
}
export function unpackAllowedGitProjects(projectList) {
return projectList.map((p) => unpackGitProject(p));
}
export function useAllowedGitProjects() {
const api = useContext(apiContext);
const method = useCallAndUnpack(
(repoUrl) => api.apis.Git.listProjects(),
unpackAllowedGitProjects
);
return useAsync({ fcn: method, call: false, init: [] });
}
export function useUpdateIoc(id, onError) {
const api = useContext(apiContext);
const method = useCallAndUnpack(
......
import React, { useEffect, useState, useContext } from "react";
import { useNavigate } from "react-router-dom";
import { useAllowedGitProjects } from "../../../api/SwaggerApi";
import { useTypingTimer } from "../../common/SearchBoxFilter/TypingTimer";
import { RootPaper } from "@ess-ics/ce-ui-common/dist/components/common/container/RootPaper";
import {
......@@ -33,14 +32,19 @@ export function CreateIOC() {
const [name, setName] = useState();
const [gitId, setGitId] = useState(null);
const [nameQuery, onNameKeyUp] = useTypingTimer({ interval: 500 });
const [
allowedGitProjects,
getAllowedGitProjects,
,
loadingAllowedGitProjects
] = useAllowedGitProjects([]);
const client = useContext(apiContext);
const {
value: allowedGitProjects,
wrapper: getAllowedGitProjects,
loading: loadingAllowedGitProjects,
dataReady: dataReadyAllowedGitProjects
} = useAPIMethod({
fcn: client.apis.Git.listProjects,
call: false
});
const {
value: ioc,
wrapper: createIoc,
......@@ -155,8 +159,8 @@ export function CreateIOC() {
<Autocomplete
autoHighlight
id="gitId"
options={allowedGitProjects}
loading={loadingAllowedGitProjects}
options={allowedGitProjects ?? []}
loading={loadingAllowedGitProjects || !dataReadyAllowedGitProjects}
clearOnBlur={false}
defaultValue={{
id: null,
......@@ -179,7 +183,8 @@ export function CreateIOC() {
...params.InputProps,
endAdornment: (
<React.Fragment>
{loadingAllowedGitProjects ? (
{loadingAllowedGitProjects ||
!dataReadyAllowedGitProjects ? (
<CircularProgress
color="inherit"
size={20}
......
......@@ -13,7 +13,7 @@ import {
Autocomplete,
Alert
} from "@mui/material";
import { useAllowedGitProjects, useUpdateIoc } from "../../../api/SwaggerApi";
import { useUpdateIoc } from "../../../api/SwaggerApi";
import { useTypingTimer } from "../../common/SearchBoxFilter/TypingTimer";
import AccessControl from "../../auth/AccessControl";
import { apiContext } from "../../../api/DeployApi";
......@@ -25,12 +25,7 @@ export default function IOCDetailAdmin({
buttonDisabled
}) {
const [gitId, setGitId] = useState(ioc.gitProjectId);
const [
allowedGitProjects,
getAllowedGitProjects,
,
loadingAllowedGitProjects
] = useAllowedGitProjects([]);
const [nameQuery, onNameKeyUp] = useTypingTimer({ interval: 500 });
const [name, setName] = useState({
uuid: ioc.namingUuid,
......@@ -47,6 +42,17 @@ export default function IOCDetailAdmin({
}
const client = useContext(apiContext);
const {
value: allowedGitProjects,
wrapper: getAllowedGitProjects,
loading: loadingAllowedGitProjects,
dataReady: dataReadyAllowedGitProjects
} = useAPIMethod({
fcn: client.apis.Git.listProjects,
call: false
});
const {
value: names,
wrapper: getNames,
......@@ -163,12 +169,14 @@ export default function IOCDetailAdmin({
function gitRepoAutocomplete(disabled) {
const isDisabled = disabled || iocIsDeployed;
const loading = loadingAllowedGitProjects && !isDisabled;
const loading =
(loadingAllowedGitProjects || !dataReadyAllowedGitProjects) &&
!isDisabled;
return (
<Autocomplete
autoHighlight
id="gitId"
options={allowedGitProjects}
options={allowedGitProjects ?? []}
loading={loading}
clearOnBlur={false}
defaultValue={{
......