Don't reload template when navigating to edit form

This commit is contained in:
Keith J. Grant
2021-06-21 11:23:15 -07:00
committed by Shane McDonald
parent f0a6567cd8
commit 487d78cc72
2 changed files with 7 additions and 3 deletions

View File

@@ -10,7 +10,7 @@ import JobTemplateForm from '../shared/JobTemplateForm';
import ContentLoading from '../../../components/ContentLoading'; import ContentLoading from '../../../components/ContentLoading';
import { CardBody } from '../../../components/Card'; import { CardBody } from '../../../components/Card';
function JobTemplateEdit({ template }) { function JobTemplateEdit({ template, reloadTemplate }) {
const history = useHistory(); const history = useHistory();
const [formSubmitError, setFormSubmitError] = useState(null); const [formSubmitError, setFormSubmitError] = useState(null);
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
@@ -64,6 +64,7 @@ function JobTemplateEdit({ template }) {
submitInstanceGroups(instanceGroups, initialInstanceGroups), submitInstanceGroups(instanceGroups, initialInstanceGroups),
submitCredentials(credentials), submitCredentials(credentials),
]); ]);
reloadTemplate();
history.push(detailsUrl); history.push(detailsUrl);
} catch (error) { } catch (error) {
setFormSubmitError(error); setFormSubmitError(error);

View File

@@ -97,7 +97,7 @@ function Template({ setBreadcrumb }) {
useEffect(() => { useEffect(() => {
loadTemplateAndRoles(); loadTemplateAndRoles();
}, [loadTemplateAndRoles, location.pathname]); }, [loadTemplateAndRoles]);
useEffect(() => { useEffect(() => {
if (template) { if (template) {
@@ -205,7 +205,10 @@ function Template({ setBreadcrumb }) {
/> />
</Route> </Route>
<Route key="edit" path="/templates/:templateType/:id/edit"> <Route key="edit" path="/templates/:templateType/:id/edit">
<JobTemplateEdit template={template} /> <JobTemplateEdit
template={template}
reloadTemplate={loadTemplateAndRoles}
/>
</Route> </Route>
<Route key="access" path="/templates/:templateType/:id/access"> <Route key="access" path="/templates/:templateType/:id/access">
<ResourceAccessList <ResourceAccessList