From 4905c8b6369dd62adcf1da1561c708e0eeaea72a Mon Sep 17 00:00:00 2001 From: John Duprey Date: Tue, 11 Feb 2025 08:55:23 -0500 Subject: [PATCH 1/4] fix repo search --- src/pages/tools/community-repos/index.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/pages/tools/community-repos/index.js b/src/pages/tools/community-repos/index.js index f862ba2aa028..d3857768c3f2 100644 --- a/src/pages/tools/community-repos/index.js +++ b/src/pages/tools/community-repos/index.js @@ -82,13 +82,12 @@ const Page = () => { searchMutation.mutate({ url: "/api/ExecGitHubAction", data: { - Search: { - Repository: repo ? repo : "", - User: user ? user : "", - Org: org ? org : "", - SearchTerm: searchTerms, - Type: "repositories", - }, + Action: "Search", + Repository: repo ? repo : "", + User: user ? user : "", + Org: org ? org : "", + SearchTerm: searchTerms, + Type: "repositories", }, }); }; From 9653cc5e97e8aeac13661cafe08f105af59a72d0 Mon Sep 17 00:00:00 2001 From: John Duprey Date: Tue, 11 Feb 2025 09:06:07 -0500 Subject: [PATCH 2/4] add default branch to query params --- src/pages/tools/community-repos/index.js | 2 +- src/pages/tools/community-repos/repo.js | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/pages/tools/community-repos/index.js b/src/pages/tools/community-repos/index.js index d3857768c3f2..044fe1c8e035 100644 --- a/src/pages/tools/community-repos/index.js +++ b/src/pages/tools/community-repos/index.js @@ -43,7 +43,7 @@ const Page = () => { const actions = [ { label: "View Templates", - link: "/tools/community-repos/repo?name=[FullName]", + link: "/tools/community-repos/repo?name=[FullName]&branch=[DefaultBranch]", icon: , }, { diff --git a/src/pages/tools/community-repos/repo.js b/src/pages/tools/community-repos/repo.js index 060915cb2cf5..8d965fef3fd9 100644 --- a/src/pages/tools/community-repos/repo.js +++ b/src/pages/tools/community-repos/repo.js @@ -20,12 +20,12 @@ import React from "react"; const Page = () => { const router = useRouter(); - const { name } = router.query; + const { name, branch } = router.query; const [openJsonDialog, setOpenJsonDialog] = useState(false); const [fileResults, setFileResults] = useState([]); const [jsonContent, setJsonContent] = useState({}); const [branches, setBranches] = useState([]); - const [selectedBranch, setSelectedBranch] = useState(""); + const [selectedBranch, setSelectedBranch] = useState(branch); const [selectedRepo, setSelectedRepo] = useState(name); const searchMutation = ApiPostCall({ @@ -110,10 +110,10 @@ const Page = () => { } }, [selectedBranch]); - const updateQueryParams = (newRepo) => { + const updateQueryParams = (prop, newValue) => { const query = { ...router.query }; - if (query.name !== newRepo) { - query.name = newRepo; + if (query[prop] !== newValue) { + query[prop] = newValue; router.replace( { pathname: router.pathname, @@ -169,7 +169,10 @@ const Page = () => { ? { label: selectedBranch, value: selectedBranch } : { label: "Loading branches", value: "" } } - onChange={(event, newValue) => setSelectedBranch(newValue.value)} + onChange={(event, newValue) => { + setSelectedBranch(newValue.value); + updateQueryParams("branch", newValue.value); + }} options={branches.map((branch) => ({ label: branch.name, value: branch.name }))} multiple={false} label="Select Branch" From c501bcc41901deef66b39da3c82890b2cc665e5d Mon Sep 17 00:00:00 2001 From: John Duprey Date: Tue, 11 Feb 2025 09:12:15 -0500 Subject: [PATCH 3/4] default branch support --- src/pages/tools/templatelib/index.jsx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/pages/tools/templatelib/index.jsx b/src/pages/tools/templatelib/index.jsx index a58adc3e0453..e05689adf61f 100644 --- a/src/pages/tools/templatelib/index.jsx +++ b/src/pages/tools/templatelib/index.jsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useEffect } from "react"; import { Grid, Divider, Typography, CircularProgress, Alert, Chip, Link } from "@mui/material"; import { useForm, useWatch } from "react-hook-form"; import { Layout as DashboardLayout } from "/src/layouts/index.js"; @@ -48,6 +48,15 @@ const TemplateLibrary = () => { }; }; + useEffect(() => { + if (templateRepo?.value) { + formControl.setValue("templateRepoBranch", { + label: templateRepo.addedFields.branch, + value: templateRepo.addedFields.branch, + }); + } + }, [templateRepo?.value]); + return ( { dataKey: "Results", valueField: "FullName", labelField: (option) => `${option.Name} (${option.URL})`, + addedField: { + branch: "DefaultBranch", + }, }} formControl={formControl} multiple={false} From 456973aa5e88290902dfd75a843c27f0743022c0 Mon Sep 17 00:00:00 2001 From: John Duprey Date: Tue, 11 Feb 2025 09:27:34 -0500 Subject: [PATCH 4/4] Update repo.js --- src/pages/tools/community-repos/repo.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pages/tools/community-repos/repo.js b/src/pages/tools/community-repos/repo.js index 8d965fef3fd9..433b534e683b 100644 --- a/src/pages/tools/community-repos/repo.js +++ b/src/pages/tools/community-repos/repo.js @@ -87,12 +87,14 @@ const Page = () => { } }; - const handleJsonView = (url) => { + const handleJsonView = (path) => { fileQuery.mutate({ url: "/api/ExecGitHubAction", data: { Action: "GetFileContents", - Url: url, + FullName: selectedRepo, + Path: path, + Branch: branch, }, }); setOpenJsonDialog(true); @@ -190,7 +192,7 @@ const Page = () => { actions={[ { label: "View Template", - customFunction: (row) => handleJsonView(row.url), + customFunction: (row) => handleJsonView(row.path), noConfirm: true, icon: , hideBulk: true,