mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: filter gitlab repositories by groupName
This commit is contained in:
parent
1be580807f
commit
6c7b1c6c7c
@ -231,6 +231,11 @@ export const SaveGitlabProvider = ({ applicationId }: Props) => {
|
|||||||
<CommandEmpty>No repositories found.</CommandEmpty>
|
<CommandEmpty>No repositories found.</CommandEmpty>
|
||||||
<ScrollArea className="h-96">
|
<ScrollArea className="h-96">
|
||||||
<CommandGroup>
|
<CommandGroup>
|
||||||
|
{repositories && repositories.length === 0 && (
|
||||||
|
<CommandEmpty>
|
||||||
|
No repositories found.
|
||||||
|
</CommandEmpty>
|
||||||
|
)}
|
||||||
{repositories?.map((repo) => {
|
{repositories?.map((repo) => {
|
||||||
return (
|
return (
|
||||||
<CommandItem
|
<CommandItem
|
||||||
|
@ -36,8 +36,9 @@ export default async function handler(
|
|||||||
if (!result.access_token || !result.refresh_token) {
|
if (!result.access_token || !result.refresh_token) {
|
||||||
return res.status(400).json({ error: "Missing or invalid code" });
|
return res.status(400).json({ error: "Missing or invalid code" });
|
||||||
}
|
}
|
||||||
|
|
||||||
const expiresAt = Math.floor(Date.now() / 1000) + result.expires_in;
|
const expiresAt = Math.floor(Date.now() / 1000) + result.expires_in;
|
||||||
const updatedGiltab = await updateGitlabProvider(gitlab.gitlabId, {
|
await updateGitlabProvider(gitlab.gitlabId, {
|
||||||
accessToken: result.access_token,
|
accessToken: result.access_token,
|
||||||
refreshToken: result.refresh_token,
|
refreshToken: result.refresh_token,
|
||||||
expiresAt,
|
expiresAt,
|
||||||
|
@ -141,7 +141,7 @@ export const getBitbucketRepositories = async (
|
|||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
const mappedData = data.values.map((repo) => {
|
const mappedData = data.values.map((repo: any) => {
|
||||||
return {
|
return {
|
||||||
name: repo.name,
|
name: repo.name,
|
||||||
url: repo.links.html.href,
|
url: repo.links.html.href,
|
||||||
@ -194,7 +194,7 @@ export const getBitbucketBranches = async (input: GetBitbucketBranches) => {
|
|||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
const mappedData = data.values.map((branch) => {
|
const mappedData = data.values.map((branch: any) => {
|
||||||
return {
|
return {
|
||||||
name: branch.name,
|
name: branch.name,
|
||||||
commit: {
|
commit: {
|
||||||
|
@ -163,6 +163,7 @@ export const getGitlabRepositories = async (input: {
|
|||||||
await refreshGitlabToken(input.gitlabId);
|
await refreshGitlabToken(input.gitlabId);
|
||||||
|
|
||||||
const gitlabProvider = await getGitlabProvider(input.gitlabId);
|
const gitlabProvider = await getGitlabProvider(input.gitlabId);
|
||||||
|
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`https://gitlab.com/api/v4/projects?membership=true&owned=true&page=${0}&per_page=${100}`,
|
`https://gitlab.com/api/v4/projects?membership=true&owned=true&page=${0}&per_page=${100}`,
|
||||||
{
|
{
|
||||||
@ -181,7 +182,28 @@ export const getGitlabRepositories = async (input: {
|
|||||||
|
|
||||||
const repositories = await response.json();
|
const repositories = await response.json();
|
||||||
|
|
||||||
return repositories as {
|
const filteredRepos = repositories.filter((repo: any) => {
|
||||||
|
const { full_path, kind } = repo.namespace;
|
||||||
|
const groupName = gitlabProvider.groupName?.toLowerCase();
|
||||||
|
|
||||||
|
if (groupName) {
|
||||||
|
return full_path.toLowerCase().includes(groupName) && kind === "group";
|
||||||
|
}
|
||||||
|
return kind === "user";
|
||||||
|
});
|
||||||
|
|
||||||
|
const mappedRepositories = filteredRepos.map((repo: any) => {
|
||||||
|
return {
|
||||||
|
id: repo.id,
|
||||||
|
name: repo.name,
|
||||||
|
url: repo.web_url,
|
||||||
|
owner: {
|
||||||
|
username: repo.namespace.path,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return mappedRepositories as {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
url: string;
|
url: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user