mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 07:27:43 +00:00
Type fix
This commit is contained in:
+8
-8
@@ -20,7 +20,7 @@ import {
|
|||||||
useGitlabConnectionListProjects
|
useGitlabConnectionListProjects
|
||||||
} from "@app/hooks/api/appConnections/gitlab";
|
} from "@app/hooks/api/appConnections/gitlab";
|
||||||
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||||
import { GitlabSyncScope } from "@app/hooks/api/secretSyncs/types/gitlab-sync";
|
import { GitLabSyncScope } from "@app/hooks/api/secretSyncs/types/gitlab-sync";
|
||||||
|
|
||||||
import { TSecretSyncForm } from "../schemas";
|
import { TSecretSyncForm } from "../schemas";
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ export const GitLabSyncFields = () => {
|
|||||||
const shouldMaskSecrets = useWatch({ name: "destinationConfig.shouldMaskSecrets", control });
|
const shouldMaskSecrets = useWatch({ name: "destinationConfig.shouldMaskSecrets", control });
|
||||||
|
|
||||||
const { data: groups, isLoading: isGroupsLoading } = useGitlabConnectionListGroups(connectionId, {
|
const { data: groups, isLoading: isGroupsLoading } = useGitlabConnectionListGroups(connectionId, {
|
||||||
enabled: Boolean(connectionId) && scope === GitlabSyncScope.Group
|
enabled: Boolean(connectionId) && scope === GitLabSyncScope.Group
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data: projects, isLoading: isProjectsLoading } = useGitlabConnectionListProjects(
|
const { data: projects, isLoading: isProjectsLoading } = useGitlabConnectionListProjects(
|
||||||
@@ -82,21 +82,21 @@ export const GitLabSyncFields = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-[calc(100vh-28rem)] overflow-auto">
|
<div className="h-full overflow-auto">
|
||||||
<SecretSyncConnectionField
|
<SecretSyncConnectionField
|
||||||
onChange={() => {
|
onChange={() => {
|
||||||
setValue("destinationConfig.projectId", "");
|
setValue("destinationConfig.projectId", "");
|
||||||
setValue("destinationConfig.projectName", "");
|
setValue("destinationConfig.projectName", "");
|
||||||
setValue("destinationConfig.groupId", "");
|
setValue("destinationConfig.groupId", "");
|
||||||
setValue("destinationConfig.groupName", "");
|
setValue("destinationConfig.groupName", "");
|
||||||
setValue("destinationConfig.scope", GitlabSyncScope.Project);
|
setValue("destinationConfig.scope", GitLabSyncScope.Project);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Controller
|
<Controller
|
||||||
name="destinationConfig.scope"
|
name="destinationConfig.scope"
|
||||||
control={control}
|
control={control}
|
||||||
defaultValue={GitlabSyncScope.Project}
|
defaultValue={GitLabSyncScope.Project}
|
||||||
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
||||||
<FormControl errorText={error?.message} isError={Boolean(error?.message)} label="Scope">
|
<FormControl errorText={error?.message} isError={Boolean(error?.message)} label="Scope">
|
||||||
<Select
|
<Select
|
||||||
@@ -113,7 +113,7 @@ export const GitLabSyncFields = () => {
|
|||||||
placeholder="Select a scope..."
|
placeholder="Select a scope..."
|
||||||
dropdownContainerClassName="max-w-none"
|
dropdownContainerClassName="max-w-none"
|
||||||
>
|
>
|
||||||
{Object.values(GitlabSyncScope).map((projectScope) => (
|
{Object.values(GitLabSyncScope).map((projectScope) => (
|
||||||
<SelectItem className="capitalize" value={projectScope} key={projectScope}>
|
<SelectItem className="capitalize" value={projectScope} key={projectScope}>
|
||||||
{projectScope.replace("-", " ")}
|
{projectScope.replace("-", " ")}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
@@ -123,7 +123,7 @@ export const GitLabSyncFields = () => {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{scope === GitlabSyncScope.Group && (
|
{scope === GitLabSyncScope.Group && (
|
||||||
<Controller
|
<Controller
|
||||||
name="destinationConfig.groupId"
|
name="destinationConfig.groupId"
|
||||||
control={control}
|
control={control}
|
||||||
@@ -166,7 +166,7 @@ export const GitLabSyncFields = () => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{scope === GitlabSyncScope.Project && (
|
{scope === GitLabSyncScope.Project && (
|
||||||
<Controller
|
<Controller
|
||||||
name="destinationConfig.projectId"
|
name="destinationConfig.projectId"
|
||||||
control={control}
|
control={control}
|
||||||
|
|||||||
+3
-2
@@ -3,6 +3,7 @@ import { useFormContext } from "react-hook-form";
|
|||||||
import { GenericFieldLabel } from "@app/components/secret-syncs";
|
import { GenericFieldLabel } from "@app/components/secret-syncs";
|
||||||
import { TSecretSyncForm } from "@app/components/secret-syncs/forms/schemas";
|
import { TSecretSyncForm } from "@app/components/secret-syncs/forms/schemas";
|
||||||
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||||
|
import { GitLabSyncScope } from "@app/hooks/api/secretSyncs/types/gitlab-sync";
|
||||||
|
|
||||||
export const GitLabSyncReviewFields = () => {
|
export const GitLabSyncReviewFields = () => {
|
||||||
const { watch } = useFormContext<TSecretSyncForm & { destination: SecretSync.GitLab }>();
|
const { watch } = useFormContext<TSecretSyncForm & { destination: SecretSync.GitLab }>();
|
||||||
@@ -17,10 +18,10 @@ export const GitLabSyncReviewFields = () => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<GenericFieldLabel label="Scope">{scope}</GenericFieldLabel>
|
<GenericFieldLabel label="Scope">{scope}</GenericFieldLabel>
|
||||||
{scope === GitlabSyncScope.Project && (
|
{scope === GitLabSyncScope.Project && (
|
||||||
<GenericFieldLabel label="Project Name">{projectName}</GenericFieldLabel>
|
<GenericFieldLabel label="Project Name">{projectName}</GenericFieldLabel>
|
||||||
)}
|
)}
|
||||||
{scope === GitlabSyncScope.Group && (
|
{scope === GitLabSyncScope.Group && (
|
||||||
<GenericFieldLabel label="Group Name">{groupName}</GenericFieldLabel>
|
<GenericFieldLabel label="Group Name">{groupName}</GenericFieldLabel>
|
||||||
)}
|
)}
|
||||||
{targetEnvironment && (
|
{targetEnvironment && (
|
||||||
|
|||||||
+3
-3
@@ -2,14 +2,14 @@ import { z } from "zod";
|
|||||||
|
|
||||||
import { BaseSecretSyncSchema } from "@app/components/secret-syncs/forms/schemas/base-secret-sync-schema";
|
import { BaseSecretSyncSchema } from "@app/components/secret-syncs/forms/schemas/base-secret-sync-schema";
|
||||||
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||||
import { GitlabSyncScope } from "@app/hooks/api/secretSyncs/types/gitlab-sync";
|
import { GitLabSyncScope } from "@app/hooks/api/secretSyncs/types/gitlab-sync";
|
||||||
|
|
||||||
export const GitlabSyncDestinationSchema = BaseSecretSyncSchema().merge(
|
export const GitlabSyncDestinationSchema = BaseSecretSyncSchema().merge(
|
||||||
z.object({
|
z.object({
|
||||||
destination: z.literal(SecretSync.GitLab),
|
destination: z.literal(SecretSync.GitLab),
|
||||||
destinationConfig: z.discriminatedUnion("scope", [
|
destinationConfig: z.discriminatedUnion("scope", [
|
||||||
z.object({
|
z.object({
|
||||||
scope: z.literal(GitlabSyncScope.Project),
|
scope: z.literal(GitLabSyncScope.Project),
|
||||||
projectId: z.string().trim().min(1, "Project ID required"),
|
projectId: z.string().trim().min(1, "Project ID required"),
|
||||||
projectName: z.string().trim().min(1, "Project name required"),
|
projectName: z.string().trim().min(1, "Project name required"),
|
||||||
targetEnvironment: z.string().optional(),
|
targetEnvironment: z.string().optional(),
|
||||||
@@ -18,7 +18,7 @@ export const GitlabSyncDestinationSchema = BaseSecretSyncSchema().merge(
|
|||||||
shouldHideSecrets: z.boolean().optional().default(false)
|
shouldHideSecrets: z.boolean().optional().default(false)
|
||||||
}),
|
}),
|
||||||
z.object({
|
z.object({
|
||||||
scope: z.literal(GitlabSyncScope.Group),
|
scope: z.literal(GitLabSyncScope.Group),
|
||||||
targetEnvironment: z.string().optional(),
|
targetEnvironment: z.string().optional(),
|
||||||
groupId: z.string().trim().min(1, "Group ID required"),
|
groupId: z.string().trim().min(1, "Group ID required"),
|
||||||
groupName: z.string().trim().min(1, "Group name required"),
|
groupName: z.string().trim().min(1, "Group name required"),
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import {
|
|||||||
GcpConnectionMethod,
|
GcpConnectionMethod,
|
||||||
GitHubConnectionMethod,
|
GitHubConnectionMethod,
|
||||||
GitHubRadarConnectionMethod,
|
GitHubRadarConnectionMethod,
|
||||||
GitlabConnectionMethod,
|
GitLabConnectionMethod,
|
||||||
HCVaultConnectionMethod,
|
HCVaultConnectionMethod,
|
||||||
HumanitecConnectionMethod,
|
HumanitecConnectionMethod,
|
||||||
LdapConnectionMethod,
|
LdapConnectionMethod,
|
||||||
@@ -102,7 +102,7 @@ export const getAppConnectionMethodDetails = (method: TAppConnection["method"])
|
|||||||
case AzureDevOpsConnectionMethod.OAuth:
|
case AzureDevOpsConnectionMethod.OAuth:
|
||||||
case GitHubConnectionMethod.OAuth:
|
case GitHubConnectionMethod.OAuth:
|
||||||
case HerokuConnectionMethod.OAuth:
|
case HerokuConnectionMethod.OAuth:
|
||||||
case GitlabConnectionMethod.OAuth:
|
case GitLabConnectionMethod.OAuth:
|
||||||
return { name: "OAuth", icon: faPassport };
|
return { name: "OAuth", icon: faPassport };
|
||||||
case AwsConnectionMethod.AccessKey:
|
case AwsConnectionMethod.AccessKey:
|
||||||
case OCIConnectionMethod.AccessKey:
|
case OCIConnectionMethod.AccessKey:
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ import { TRootAppConnection } from "@app/hooks/api/appConnections/types/root-con
|
|||||||
|
|
||||||
import { GitLabAccessTokenType } from "../gitlab";
|
import { GitLabAccessTokenType } from "../gitlab";
|
||||||
|
|
||||||
export enum GitlabConnectionMethod {
|
export enum GitLabConnectionMethod {
|
||||||
AccessToken = "access-token",
|
AccessToken = "access-token",
|
||||||
OAuth = "oauth"
|
OAuth = "oauth"
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TGitlabConnection = TRootAppConnection & { app: AppConnection.Gitlab } & (
|
export type TGitLabConnection = TRootAppConnection & { app: AppConnection.Gitlab } & (
|
||||||
| {
|
| {
|
||||||
method: GitlabConnectionMethod.AccessToken;
|
method: GitLabConnectionMethod.AccessToken;
|
||||||
credentials: {
|
credentials: {
|
||||||
instanceUrl?: string;
|
instanceUrl?: string;
|
||||||
accessToken: string;
|
accessToken: string;
|
||||||
@@ -18,7 +18,7 @@ export type TGitlabConnection = TRootAppConnection & { app: AppConnection.Gitlab
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
method: GitlabConnectionMethod.OAuth;
|
method: GitLabConnectionMethod.OAuth;
|
||||||
credentials: {
|
credentials: {
|
||||||
code: string;
|
code: string;
|
||||||
instanceUrl?: string;
|
instanceUrl?: string;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import { TFlyioConnection } from "./flyio-connection";
|
|||||||
import { TGcpConnection } from "./gcp-connection";
|
import { TGcpConnection } from "./gcp-connection";
|
||||||
import { TGitHubConnection } from "./github-connection";
|
import { TGitHubConnection } from "./github-connection";
|
||||||
import { TGitHubRadarConnection } from "./github-radar-connection";
|
import { TGitHubRadarConnection } from "./github-radar-connection";
|
||||||
import { TGitlabConnection } from "./gitlab-connection";
|
import { TGitLabConnection } from "./gitlab-connection";
|
||||||
import { THCVaultConnection } from "./hc-vault-connection";
|
import { THCVaultConnection } from "./hc-vault-connection";
|
||||||
import { THerokuConnection } from "./heroku-connection";
|
import { THerokuConnection } from "./heroku-connection";
|
||||||
import { THumanitecConnection } from "./humanitec-connection";
|
import { THumanitecConnection } from "./humanitec-connection";
|
||||||
@@ -88,7 +88,7 @@ export type TAppConnection =
|
|||||||
| THerokuConnection
|
| THerokuConnection
|
||||||
| TRenderConnection
|
| TRenderConnection
|
||||||
| TFlyioConnection
|
| TFlyioConnection
|
||||||
| TGitlabConnection
|
| TGitLabConnection
|
||||||
| TCloudflareConnection;
|
| TCloudflareConnection;
|
||||||
|
|
||||||
export type TAvailableAppConnection = Pick<TAppConnection, "name" | "id">;
|
export type TAvailableAppConnection = Pick<TAppConnection, "name" | "id">;
|
||||||
@@ -144,6 +144,6 @@ export type TAppConnectionMap = {
|
|||||||
[AppConnection.Heroku]: THerokuConnection;
|
[AppConnection.Heroku]: THerokuConnection;
|
||||||
[AppConnection.Render]: TRenderConnection;
|
[AppConnection.Render]: TRenderConnection;
|
||||||
[AppConnection.Flyio]: TFlyioConnection;
|
[AppConnection.Flyio]: TFlyioConnection;
|
||||||
[AppConnection.Gitlab]: TGitlabConnection;
|
[AppConnection.Gitlab]: TGitLabConnection;
|
||||||
[AppConnection.Cloudflare]: TCloudflareConnection;
|
[AppConnection.Cloudflare]: TCloudflareConnection;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,16 +2,16 @@ import { AppConnection } from "@app/hooks/api/appConnections/enums";
|
|||||||
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
import { SecretSync } from "@app/hooks/api/secretSyncs";
|
||||||
import { TRootSecretSync } from "@app/hooks/api/secretSyncs/types/root-sync";
|
import { TRootSecretSync } from "@app/hooks/api/secretSyncs/types/root-sync";
|
||||||
|
|
||||||
export enum GitlabSyncScope {
|
export enum GitLabSyncScope {
|
||||||
Project = "project",
|
Project = "project",
|
||||||
Group = "group"
|
Group = "group"
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TGitlabSync = TRootSecretSync & {
|
export type TGitLabSync = TRootSecretSync & {
|
||||||
destination: SecretSync.GitLab;
|
destination: SecretSync.GitLab;
|
||||||
destinationConfig:
|
destinationConfig:
|
||||||
| {
|
| {
|
||||||
scope: GitlabSyncScope.Project;
|
scope: GitLabSyncScope.Project;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
projectName: string;
|
projectName: string;
|
||||||
targetEnvironment?: string;
|
targetEnvironment?: string;
|
||||||
@@ -20,7 +20,7 @@ export type TGitlabSync = TRootSecretSync & {
|
|||||||
shouldHideSecrets?: boolean;
|
shouldHideSecrets?: boolean;
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
scope: GitlabSyncScope.Group;
|
scope: GitLabSyncScope.Group;
|
||||||
groupId: string;
|
groupId: string;
|
||||||
groupName: string;
|
groupName: string;
|
||||||
targetEnvironment?: string;
|
targetEnvironment?: string;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import { TDatabricksSync } from "./databricks-sync";
|
|||||||
import { TFlyioSync } from "./flyio-sync";
|
import { TFlyioSync } from "./flyio-sync";
|
||||||
import { TGcpSync } from "./gcp-sync";
|
import { TGcpSync } from "./gcp-sync";
|
||||||
import { TGitHubSync } from "./github-sync";
|
import { TGitHubSync } from "./github-sync";
|
||||||
import { TGitlabSync } from "./gitlab-sync";
|
import { TGitLabSync } from "./gitlab-sync";
|
||||||
import { THCVaultSync } from "./hc-vault-sync";
|
import { THCVaultSync } from "./hc-vault-sync";
|
||||||
import { THerokuSync } from "./heroku-sync";
|
import { THerokuSync } from "./heroku-sync";
|
||||||
import { THumanitecSync } from "./humanitec-sync";
|
import { THumanitecSync } from "./humanitec-sync";
|
||||||
@@ -52,7 +52,7 @@ export type TSecretSync =
|
|||||||
| THerokuSync
|
| THerokuSync
|
||||||
| TRenderSync
|
| TRenderSync
|
||||||
| TFlyioSync
|
| TFlyioSync
|
||||||
| TGitlabSync
|
| TGitLabSync
|
||||||
| TCloudflarePagesSync;
|
| TCloudflarePagesSync;
|
||||||
|
|
||||||
export type TListSecretSyncs = { secretSyncs: TSecretSync[] };
|
export type TListSecretSyncs = { secretSyncs: TSecretSync[] };
|
||||||
|
|||||||
+19
-19
@@ -22,8 +22,8 @@ import { useGetAppConnectionOption } from "@app/hooks/api/appConnections";
|
|||||||
import { AppConnection } from "@app/hooks/api/appConnections/enums";
|
import { AppConnection } from "@app/hooks/api/appConnections/enums";
|
||||||
import { GitLabAccessTokenType } from "@app/hooks/api/appConnections/gitlab";
|
import { GitLabAccessTokenType } from "@app/hooks/api/appConnections/gitlab";
|
||||||
import {
|
import {
|
||||||
GitlabConnectionMethod,
|
GitLabConnectionMethod,
|
||||||
TGitlabConnection
|
TGitLabConnection
|
||||||
} from "@app/hooks/api/appConnections/types/gitlab-connection";
|
} from "@app/hooks/api/appConnections/types/gitlab-connection";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -32,14 +32,14 @@ import {
|
|||||||
} from "./GenericAppConnectionFields";
|
} from "./GenericAppConnectionFields";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
appConnection?: TGitlabConnection;
|
appConnection?: TGitLabConnection;
|
||||||
onSubmit: (formData: FormData) => Promise<void>;
|
onSubmit: (formData: FormData) => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const formSchema = z.discriminatedUnion("method", [
|
const formSchema = z.discriminatedUnion("method", [
|
||||||
genericAppConnectionFieldsSchema.extend({
|
genericAppConnectionFieldsSchema.extend({
|
||||||
app: z.literal(AppConnection.Gitlab),
|
app: z.literal(AppConnection.Gitlab),
|
||||||
method: z.literal(GitlabConnectionMethod.AccessToken),
|
method: z.literal(GitLabConnectionMethod.AccessToken),
|
||||||
credentials: z.object({
|
credentials: z.object({
|
||||||
accessToken: z.string().min(1, "Access token is required"),
|
accessToken: z.string().min(1, "Access token is required"),
|
||||||
accessTokenType: z.nativeEnum(GitLabAccessTokenType),
|
accessTokenType: z.nativeEnum(GitLabAccessTokenType),
|
||||||
@@ -55,7 +55,7 @@ const formSchema = z.discriminatedUnion("method", [
|
|||||||
}),
|
}),
|
||||||
genericAppConnectionFieldsSchema.extend({
|
genericAppConnectionFieldsSchema.extend({
|
||||||
app: z.literal(AppConnection.Gitlab),
|
app: z.literal(AppConnection.Gitlab),
|
||||||
method: z.literal(GitlabConnectionMethod.OAuth),
|
method: z.literal(GitLabConnectionMethod.OAuth),
|
||||||
credentials: z.object({
|
credentials: z.object({
|
||||||
code: z.string().min(1, "Code is required"),
|
code: z.string().min(1, "Code is required"),
|
||||||
instanceUrl: z
|
instanceUrl: z
|
||||||
@@ -84,12 +84,12 @@ export const GitLabConnectionForm = ({ appConnection, onSubmit: formSubmit }: Pr
|
|||||||
const form = useForm<FormData>({
|
const form = useForm<FormData>({
|
||||||
resolver: zodResolver(formSchema),
|
resolver: zodResolver(formSchema),
|
||||||
defaultValues:
|
defaultValues:
|
||||||
appConnection?.method === GitlabConnectionMethod.OAuth
|
appConnection?.method === GitLabConnectionMethod.OAuth
|
||||||
? { ...appConnection, credentials: { code: "custom" } }
|
? { ...appConnection, credentials: { code: "custom" } }
|
||||||
: (appConnection ??
|
: (appConnection ??
|
||||||
({
|
({
|
||||||
app: AppConnection.Gitlab,
|
app: AppConnection.Gitlab,
|
||||||
method: GitlabConnectionMethod.AccessToken,
|
method: GitLabConnectionMethod.AccessToken,
|
||||||
credentials: {
|
credentials: {
|
||||||
accessToken: "",
|
accessToken: "",
|
||||||
accessTokenType: GitLabAccessTokenType.Personal,
|
accessTokenType: GitLabAccessTokenType.Personal,
|
||||||
@@ -112,11 +112,11 @@ export const GitLabConnectionForm = ({ appConnection, onSubmit: formSubmit }: Pr
|
|||||||
const onSubmit = async (formData: FormData) => {
|
const onSubmit = async (formData: FormData) => {
|
||||||
try {
|
try {
|
||||||
switch (formData.method) {
|
switch (formData.method) {
|
||||||
case GitlabConnectionMethod.AccessToken:
|
case GitLabConnectionMethod.AccessToken:
|
||||||
await formSubmit(formData);
|
await formSubmit(formData);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GitlabConnectionMethod.OAuth:
|
case GitLabConnectionMethod.OAuth:
|
||||||
if (!oauthClientId) {
|
if (!oauthClientId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -165,10 +165,10 @@ export const GitLabConnectionForm = ({ appConnection, onSubmit: formSubmit }: Pr
|
|||||||
let isMissingConfig: boolean;
|
let isMissingConfig: boolean;
|
||||||
|
|
||||||
switch (selectedMethod) {
|
switch (selectedMethod) {
|
||||||
case GitlabConnectionMethod.OAuth:
|
case GitLabConnectionMethod.OAuth:
|
||||||
isMissingConfig = !oauthClientId;
|
isMissingConfig = !oauthClientId;
|
||||||
break;
|
break;
|
||||||
case GitlabConnectionMethod.AccessToken:
|
case GitLabConnectionMethod.AccessToken:
|
||||||
isMissingConfig = false;
|
isMissingConfig = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -210,7 +210,7 @@ export const GitLabConnectionForm = ({ appConnection, onSubmit: formSubmit }: Pr
|
|||||||
APP_CONNECTION_MAP[AppConnection.Gitlab].name
|
APP_CONNECTION_MAP[AppConnection.Gitlab].name
|
||||||
}. This field cannot be changed after creation.`}
|
}. This field cannot be changed after creation.`}
|
||||||
errorText={
|
errorText={
|
||||||
!isLoading && isMissingConfig && selectedMethod === GitlabConnectionMethod.OAuth
|
!isLoading && isMissingConfig && selectedMethod === GitLabConnectionMethod.OAuth
|
||||||
? `Environment variables have not been configured. ${
|
? `Environment variables have not been configured. ${
|
||||||
isInfisicalCloud()
|
isInfisicalCloud()
|
||||||
? "Please contact Infisical."
|
? "Please contact Infisical."
|
||||||
@@ -226,7 +226,7 @@ export const GitLabConnectionForm = ({ appConnection, onSubmit: formSubmit }: Pr
|
|||||||
value={value}
|
value={value}
|
||||||
onValueChange={(val) => {
|
onValueChange={(val) => {
|
||||||
onChange(val);
|
onChange(val);
|
||||||
if (val === GitlabConnectionMethod.OAuth) {
|
if (val === GitLabConnectionMethod.OAuth) {
|
||||||
setValue("credentials.code", "custom");
|
setValue("credentials.code", "custom");
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
@@ -234,11 +234,11 @@ export const GitLabConnectionForm = ({ appConnection, onSubmit: formSubmit }: Pr
|
|||||||
position="popper"
|
position="popper"
|
||||||
dropdownContainerClassName="max-w-none"
|
dropdownContainerClassName="max-w-none"
|
||||||
>
|
>
|
||||||
{Object.values(GitlabConnectionMethod).map((method) => {
|
{Object.values(GitLabConnectionMethod).map((method) => {
|
||||||
return (
|
return (
|
||||||
<SelectItem value={method} key={method}>
|
<SelectItem value={method} key={method}>
|
||||||
{getAppConnectionMethodDetails(method).name}{" "}
|
{getAppConnectionMethodDetails(method).name}{" "}
|
||||||
{method === GitlabConnectionMethod.AccessToken ? " (Recommended)" : ""}
|
{method === GitLabConnectionMethod.AccessToken ? " (Recommended)" : ""}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@@ -247,7 +247,7 @@ export const GitLabConnectionForm = ({ appConnection, onSubmit: formSubmit }: Pr
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{selectedMethod === GitlabConnectionMethod.AccessToken && (
|
{selectedMethod === GitLabConnectionMethod.AccessToken && (
|
||||||
<>
|
<>
|
||||||
<Controller
|
<Controller
|
||||||
name="credentials.accessTokenType"
|
name="credentials.accessTokenType"
|
||||||
@@ -263,7 +263,7 @@ export const GitLabConnectionForm = ({ appConnection, onSubmit: formSubmit }: Pr
|
|||||||
value={value}
|
value={value}
|
||||||
onValueChange={(val) => {
|
onValueChange={(val) => {
|
||||||
onChange(val);
|
onChange(val);
|
||||||
if (val === GitlabConnectionMethod.OAuth) {
|
if (val === GitLabConnectionMethod.OAuth) {
|
||||||
setValue("credentials.code", "custom");
|
setValue("credentials.code", "custom");
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
@@ -313,11 +313,11 @@ export const GitLabConnectionForm = ({ appConnection, onSubmit: formSubmit }: Pr
|
|||||||
isDisabled={
|
isDisabled={
|
||||||
isSubmitting ||
|
isSubmitting ||
|
||||||
(!isUpdate && !isDirty) ||
|
(!isUpdate && !isDirty) ||
|
||||||
(isMissingConfig && selectedMethod === GitlabConnectionMethod.OAuth) ||
|
(isMissingConfig && selectedMethod === GitLabConnectionMethod.OAuth) ||
|
||||||
isRedirecting
|
isRedirecting
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{isRedirecting && selectedMethod === GitlabConnectionMethod.OAuth
|
{isRedirecting && selectedMethod === GitLabConnectionMethod.OAuth
|
||||||
? "Redirecting to GitLab..."
|
? "Redirecting to GitLab..."
|
||||||
: isUpdate
|
: isUpdate
|
||||||
? "Reconnect to GitLab"
|
? "Reconnect to GitLab"
|
||||||
|
|||||||
+5
-5
@@ -11,14 +11,14 @@ import {
|
|||||||
AzureDevOpsConnectionMethod,
|
AzureDevOpsConnectionMethod,
|
||||||
AzureKeyVaultConnectionMethod,
|
AzureKeyVaultConnectionMethod,
|
||||||
GitHubConnectionMethod,
|
GitHubConnectionMethod,
|
||||||
GitlabConnectionMethod,
|
GitLabConnectionMethod,
|
||||||
TAzureAppConfigurationConnection,
|
TAzureAppConfigurationConnection,
|
||||||
TAzureClientSecretsConnection,
|
TAzureClientSecretsConnection,
|
||||||
TAzureDevOpsConnection,
|
TAzureDevOpsConnection,
|
||||||
TAzureKeyVaultConnection,
|
TAzureKeyVaultConnection,
|
||||||
TGitHubConnection,
|
TGitHubConnection,
|
||||||
TGitHubRadarConnection,
|
TGitHubRadarConnection,
|
||||||
TGitlabConnection,
|
TGitLabConnection,
|
||||||
useCreateAppConnection,
|
useCreateAppConnection,
|
||||||
useUpdateAppConnection
|
useUpdateAppConnection
|
||||||
} from "@app/hooks/api/appConnections";
|
} from "@app/hooks/api/appConnections";
|
||||||
@@ -35,7 +35,7 @@ type GithubFormData = BaseFormData & Pick<TGitHubConnection, "name" | "method" |
|
|||||||
type GithubRadarFormData = BaseFormData &
|
type GithubRadarFormData = BaseFormData &
|
||||||
Pick<TGitHubRadarConnection, "name" | "method" | "description">;
|
Pick<TGitHubRadarConnection, "name" | "method" | "description">;
|
||||||
|
|
||||||
type GitlabFormData = BaseFormData & Pick<TGitlabConnection, "name" | "method" | "description">;
|
type GitLabFormData = BaseFormData & Pick<TGitLabConnection, "name" | "method" | "description">;
|
||||||
|
|
||||||
type AzureKeyVaultFormData = BaseFormData &
|
type AzureKeyVaultFormData = BaseFormData &
|
||||||
Pick<TAzureKeyVaultConnection, "name" | "method" | "description"> &
|
Pick<TAzureKeyVaultConnection, "name" | "method" | "description"> &
|
||||||
@@ -65,7 +65,7 @@ type AzureDevOpsFormData = BaseFormData &
|
|||||||
type FormDataMap = {
|
type FormDataMap = {
|
||||||
[AppConnection.GitHub]: GithubFormData & { app: AppConnection.GitHub };
|
[AppConnection.GitHub]: GithubFormData & { app: AppConnection.GitHub };
|
||||||
[AppConnection.GitHubRadar]: GithubRadarFormData & { app: AppConnection.GitHubRadar };
|
[AppConnection.GitHubRadar]: GithubRadarFormData & { app: AppConnection.GitHubRadar };
|
||||||
[AppConnection.Gitlab]: GitlabFormData & { app: AppConnection.Gitlab };
|
[AppConnection.Gitlab]: GitLabFormData & { app: AppConnection.Gitlab };
|
||||||
[AppConnection.AzureKeyVault]: AzureKeyVaultFormData & { app: AppConnection.AzureKeyVault };
|
[AppConnection.AzureKeyVault]: AzureKeyVaultFormData & { app: AppConnection.AzureKeyVault };
|
||||||
[AppConnection.AzureAppConfiguration]: AzureAppConfigurationFormData & {
|
[AppConnection.AzureAppConfiguration]: AzureAppConfigurationFormData & {
|
||||||
app: AppConnection.AzureAppConfiguration;
|
app: AppConnection.AzureAppConfiguration;
|
||||||
@@ -162,7 +162,7 @@ export const OAuthCallbackPage = () => {
|
|||||||
app: AppConnection.Gitlab,
|
app: AppConnection.Gitlab,
|
||||||
name,
|
name,
|
||||||
description,
|
description,
|
||||||
method: GitlabConnectionMethod.OAuth,
|
method: GitLabConnectionMethod.OAuth,
|
||||||
credentials: {
|
credentials: {
|
||||||
code: code as string
|
code: code as string
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,10 +1,10 @@
|
|||||||
import { TGitlabSync } from "@app/hooks/api/secretSyncs/types/gitlab-sync";
|
import { TGitLabSync } from "@app/hooks/api/secretSyncs/types/gitlab-sync";
|
||||||
|
|
||||||
import { getSecretSyncDestinationColValues } from "../helpers";
|
import { getSecretSyncDestinationColValues } from "../helpers";
|
||||||
import { SecretSyncTableCell } from "../SecretSyncTableCell";
|
import { SecretSyncTableCell } from "../SecretSyncTableCell";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
secretSync: TGitlabSync;
|
secretSync: TGitLabSync;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const GitLabSyncDestinationCol = ({ secretSync }: Props) => {
|
export const GitLabSyncDestinationCol = ({ secretSync }: Props) => {
|
||||||
|
|||||||
+3
-3
@@ -5,7 +5,7 @@ import {
|
|||||||
GitHubSyncScope,
|
GitHubSyncScope,
|
||||||
GitHubSyncVisibility
|
GitHubSyncVisibility
|
||||||
} from "@app/hooks/api/secretSyncs/types/github-sync";
|
} from "@app/hooks/api/secretSyncs/types/github-sync";
|
||||||
import { GitlabSyncScope } from "@app/hooks/api/secretSyncs/types/gitlab-sync";
|
import { GitLabSyncScope } from "@app/hooks/api/secretSyncs/types/gitlab-sync";
|
||||||
import { HumanitecSyncScope } from "@app/hooks/api/secretSyncs/types/humanitec-sync";
|
import { HumanitecSyncScope } from "@app/hooks/api/secretSyncs/types/humanitec-sync";
|
||||||
|
|
||||||
// This functional ensures parity across what is displayed in the destination column
|
// This functional ensures parity across what is displayed in the destination column
|
||||||
@@ -130,10 +130,10 @@ export const getSecretSyncDestinationColValues = (secretSync: TSecretSync) => {
|
|||||||
secondaryText = "App ID";
|
secondaryText = "App ID";
|
||||||
break;
|
break;
|
||||||
case SecretSync.GitLab:
|
case SecretSync.GitLab:
|
||||||
if (destinationConfig.scope === GitlabSyncScope.Project) {
|
if (destinationConfig.scope === GitLabSyncScope.Project) {
|
||||||
primaryText = destinationConfig.projectName;
|
primaryText = destinationConfig.projectName;
|
||||||
secondaryText = destinationConfig.projectId;
|
secondaryText = destinationConfig.projectId;
|
||||||
} else if (destinationConfig.scope === GitlabSyncScope.Group) {
|
} else if (destinationConfig.scope === GitLabSyncScope.Group) {
|
||||||
primaryText = destinationConfig.groupName;
|
primaryText = destinationConfig.groupName;
|
||||||
secondaryText = destinationConfig.groupId;
|
secondaryText = destinationConfig.groupId;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+4
-4
@@ -1,8 +1,8 @@
|
|||||||
import { GenericFieldLabel } from "@app/components/secret-syncs";
|
import { GenericFieldLabel } from "@app/components/secret-syncs";
|
||||||
import { GitlabSyncScope, TGitlabSync } from "@app/hooks/api/secretSyncs/types/gitlab-sync";
|
import { GitLabSyncScope, TGitLabSync } from "@app/hooks/api/secretSyncs/types/gitlab-sync";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
secretSync: TGitlabSync;
|
secretSync: TGitLabSync;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const GitLabSyncDestinationSection = ({ secretSync }: Props) => {
|
export const GitLabSyncDestinationSection = ({ secretSync }: Props) => {
|
||||||
@@ -17,7 +17,7 @@ export const GitLabSyncDestinationSection = ({ secretSync }: Props) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{secretSync.destinationConfig.scope === GitlabSyncScope.Project && (
|
{secretSync.destinationConfig.scope === GitLabSyncScope.Project && (
|
||||||
<>
|
<>
|
||||||
<GenericFieldLabel label="Project Name">
|
<GenericFieldLabel label="Project Name">
|
||||||
{secretSync.destinationConfig.projectName}
|
{secretSync.destinationConfig.projectName}
|
||||||
@@ -27,7 +27,7 @@ export const GitLabSyncDestinationSection = ({ secretSync }: Props) => {
|
|||||||
</GenericFieldLabel>
|
</GenericFieldLabel>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{secretSync.destinationConfig.scope === GitlabSyncScope.Group && (
|
{secretSync.destinationConfig.scope === GitLabSyncScope.Group && (
|
||||||
<>
|
<>
|
||||||
<GenericFieldLabel label="Group Name">
|
<GenericFieldLabel label="Group Name">
|
||||||
{secretSync.destinationConfig.groupName}
|
{secretSync.destinationConfig.groupName}
|
||||||
|
|||||||
+2
-2
@@ -4,7 +4,7 @@ import { useNavigate, useSearch } from "@tanstack/react-router";
|
|||||||
import { ROUTE_PATHS } from "@app/const/routes";
|
import { ROUTE_PATHS } from "@app/const/routes";
|
||||||
import { useWorkspace } from "@app/context";
|
import { useWorkspace } from "@app/context";
|
||||||
import { useCreateAppConnection, useUpdateAppConnection } from "@app/hooks/api/appConnections";
|
import { useCreateAppConnection, useUpdateAppConnection } from "@app/hooks/api/appConnections";
|
||||||
import { GitlabConnectionMethod } from "@app/hooks/api/appConnections/types/gitlab-connection";
|
import { GitLabConnectionMethod } from "@app/hooks/api/appConnections/types/gitlab-connection";
|
||||||
|
|
||||||
export const GitLabOAuthCallbackPage = () => {
|
export const GitLabOAuthCallbackPage = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -49,7 +49,7 @@ export const GitLabOAuthCallbackPage = () => {
|
|||||||
// Prepare app connection data with OAuth credentials
|
// Prepare app connection data with OAuth credentials
|
||||||
const connectionData = {
|
const connectionData = {
|
||||||
...formData,
|
...formData,
|
||||||
method: GitlabConnectionMethod.OAuth,
|
method: GitLabConnectionMethod.OAuth,
|
||||||
credentials: {
|
credentials: {
|
||||||
code: code as string
|
code: code as string
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user