fix: use constant url for bitbucket update/create secret

This commit is contained in:
Scott Wilson
2024-11-11 10:56:26 -08:00
parent d4c911a28f
commit 7b8551f883
11 changed files with 29 additions and 41 deletions
@@ -3632,15 +3632,13 @@ const syncSecretsBitBucket = async ({
let hasNextPage = true; let hasNextPage = true;
let variablesUrl: string; const rootUrl = integration.targetServiceId
? // scope: deployment environment
`${IntegrationUrls.BITBUCKET_API_URL}/2.0/repositories/${integration.targetEnvironmentId}/${integration.appId}/deployments_config/environments/${integration.targetServiceId}/variables`
: // scope: repository
`${IntegrationUrls.BITBUCKET_API_URL}/2.0/repositories/${integration.targetEnvironmentId}/${integration.appId}/pipelines_config/variables`;
if (integration.targetServiceId) { let variablesUrl = rootUrl;
// scope: deployment environment
variablesUrl = `${IntegrationUrls.BITBUCKET_API_URL}/2.0/repositories/${integration.targetEnvironmentId}/${integration.appId}/deployments_config/environments/${integration.targetServiceId}/variables`;
} else {
// scope: repository
variablesUrl = `${IntegrationUrls.BITBUCKET_API_URL}/2.0/repositories/${integration.targetEnvironmentId}/${integration.appId}/pipelines_config/variables`;
}
while (hasNextPage) { while (hasNextPage) {
const { data }: { data: VariablesResponse } = await request.get(variablesUrl, { const { data }: { data: VariablesResponse } = await request.get(variablesUrl, {
@@ -3667,7 +3665,7 @@ const syncSecretsBitBucket = async ({
if (key in res) { if (key in res) {
// update existing secret // update existing secret
await request.put( await request.put(
`${variablesUrl}/${res[key].uuid}`, `${rootUrl}/${res[key].uuid}`,
{ {
key, key,
value: secrets[key].value, value: secrets[key].value,
@@ -3683,7 +3681,7 @@ const syncSecretsBitBucket = async ({
} else { } else {
// create new secret // create new secret
await request.post( await request.post(
variablesUrl, rootUrl,
{ {
key, key,
value: secrets[key].value, value: secrets[key].value,
@@ -7,7 +7,7 @@ import Select, {
Props Props
} from "react-select"; } from "react-select";
import { faCheckCircle, faCircleXmark } from "@fortawesome/free-regular-svg-icons"; import { faCheckCircle, faCircleXmark } from "@fortawesome/free-regular-svg-icons";
import { faChevronDown, faX } from "@fortawesome/free-solid-svg-icons"; import { faChevronDown, faXmark } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { twMerge } from "tailwind-merge"; import { twMerge } from "tailwind-merge";
@@ -30,7 +30,7 @@ const ClearIndicator = <T,>(props: ClearIndicatorProps<T>) => {
const MultiValueRemove = (props: MultiValueRemoveProps) => { const MultiValueRemove = (props: MultiValueRemoveProps) => {
return ( return (
<components.MultiValueRemove {...props}> <components.MultiValueRemove {...props}>
<FontAwesomeIcon icon={faX} size="xs" /> <FontAwesomeIcon icon={faXmark} size="xs" />
</components.MultiValueRemove> </components.MultiValueRemove>
); );
}; };
@@ -46,10 +46,10 @@ const Option = <T,>({ isSelected, children, ...props }: OptionProps<T>) => {
); );
}; };
export const MultiSelect = <T,>({ isMulti = true, ...props }: Props<T>) => ( export const FilterableSelect = <T,>({ isMulti, closeMenuOnSelect, ...props }: Props<T>) => (
<Select <Select
isMulti={isMulti} isMulti={isMulti}
closeMenuOnSelect={false} closeMenuOnSelect={closeMenuOnSelect ?? !isMulti}
hideSelectedOptions={false} hideSelectedOptions={false}
unstyled unstyled
styles={{ styles={{
@@ -0,0 +1 @@
export * from "./FilterableSelect";
@@ -1 +0,0 @@
export * from "./MultiSelect";
+1 -1
View File
@@ -11,6 +11,7 @@ export * from "./Drawer";
export * from "./Dropdown"; export * from "./Dropdown";
export * from "./EmailServiceSetupModal"; export * from "./EmailServiceSetupModal";
export * from "./EmptyState"; export * from "./EmptyState";
export * from "./FilterableSelect";
export * from "./FontAwesomeSymbol"; export * from "./FontAwesomeSymbol";
export * from "./FormControl"; export * from "./FormControl";
export * from "./HoverCardv2"; export * from "./HoverCardv2";
@@ -18,7 +19,6 @@ export * from "./IconButton";
export * from "./Input"; export * from "./Input";
export * from "./Menu"; export * from "./Menu";
export * from "./Modal"; export * from "./Modal";
export * from "./MultiSelect";
export * from "./NoticeBanner"; export * from "./NoticeBanner";
export * from "./Pagination"; export * from "./Pagination";
export * from "./Popoverv2"; export * from "./Popoverv2";
+1 -1
View File
@@ -282,7 +282,7 @@ export const AppLayout = ({ children }: LayoutProps) => {
); );
const { data: projectTemplates = [] } = useListProjectTemplates({ const { data: projectTemplates = [] } = useListProjectTemplates({
enabled: canReadProjectTemplates && subscription?.projectTemplates enabled: Boolean(canReadProjectTemplates && subscription?.projectTemplates)
}); });
const onCreateProject = async ({ name, addMembers, kmsKeyId, template }: TAddProjectFormData) => { const onCreateProject = async ({ name, addMembers, kmsKeyId, template }: TAddProjectFormData) => {
@@ -10,9 +10,9 @@ import {
Button, Button,
Card, Card,
CardTitle, CardTitle,
FilterableSelect,
FormControl, FormControl,
Input, Input,
MultiSelect,
Spinner Spinner
} from "@app/components/v2"; } from "@app/components/v2";
import { useWorkspace } from "@app/context"; import { useWorkspace } from "@app/context";
@@ -174,9 +174,7 @@ export default function BitBucketCreateIntegrationPage() {
isError={Boolean(error)} isError={Boolean(error)}
label="Project Environment" label="Project Environment"
> >
<MultiSelect <FilterableSelect
closeMenuOnSelect
isMulti={false}
getOptionValue={(option) => option.slug} getOptionValue={(option) => option.slug}
value={value} value={value}
getOptionLabel={(option) => option.name} getOptionLabel={(option) => option.name}
@@ -210,9 +208,7 @@ export default function BitBucketCreateIntegrationPage() {
isError={Boolean(error)} isError={Boolean(error)}
label="Bitbucket Workspace" label="Bitbucket Workspace"
> >
<MultiSelect <FilterableSelect
closeMenuOnSelect
isMulti={false}
getOptionValue={(option) => option.slug} getOptionValue={(option) => option.slug}
value={value} value={value}
getOptionLabel={(option) => option.name} getOptionLabel={(option) => option.name}
@@ -231,9 +227,7 @@ export default function BitBucketCreateIntegrationPage() {
name="targetRepo" name="targetRepo"
render={({ field: { value, onChange }, fieldState: { error } }) => ( render={({ field: { value, onChange }, fieldState: { error } }) => (
<FormControl errorText={error?.message} isError={Boolean(error)} label="Bitbucket Repo"> <FormControl errorText={error?.message} isError={Boolean(error)} label="Bitbucket Repo">
<MultiSelect <FilterableSelect
closeMenuOnSelect
isMulti={false}
getOptionValue={(option) => option.appId!} getOptionValue={(option) => option.appId!}
value={value} value={value}
getOptionLabel={(option) => option.name} getOptionLabel={(option) => option.name}
@@ -252,9 +246,7 @@ export default function BitBucketCreateIntegrationPage() {
name="scope" name="scope"
render={({ field: { value, onChange }, fieldState: { error } }) => ( render={({ field: { value, onChange }, fieldState: { error } }) => (
<FormControl errorText={error?.message} isError={Boolean(error)} label="Scope"> <FormControl errorText={error?.message} isError={Boolean(error)} label="Scope">
<MultiSelect <FilterableSelect
closeMenuOnSelect
isMulti={false}
value={value} value={value}
getOptionValue={(option) => option.value} getOptionValue={(option) => option.value}
getOptionLabel={(option) => option.label} getOptionLabel={(option) => option.label}
@@ -275,9 +267,7 @@ export default function BitBucketCreateIntegrationPage() {
isError={Boolean(error)} isError={Boolean(error)}
label="Bitbucket Deployment Environment" label="Bitbucket Deployment Environment"
> >
<MultiSelect <FilterableSelect
closeMenuOnSelect
isMulti={false}
getOptionValue={(option) => option.uuid} getOptionValue={(option) => option.uuid}
value={value} value={value}
getOptionLabel={(option) => option.name} getOptionLabel={(option) => option.name}
@@ -589,7 +589,7 @@ const OrganizationPage = () => {
); );
const { data: projectTemplates = [] } = useListProjectTemplates({ const { data: projectTemplates = [] } = useListProjectTemplates({
enabled: canReadProjectTemplates && subscription?.projectTemplates enabled: Boolean(canReadProjectTemplates && subscription?.projectTemplates)
}); });
const isAddingProjectsAllowed = subscription?.workspaceLimit const isAddingProjectsAllowed = subscription?.workspaceLimit
@@ -15,10 +15,10 @@ import {
DropdownMenuContent, DropdownMenuContent,
DropdownMenuItem, DropdownMenuItem,
DropdownMenuTrigger, DropdownMenuTrigger,
FilterableSelect,
FormControl, FormControl,
Modal, Modal,
ModalContent, ModalContent
MultiSelect
} from "@app/components/v2"; } from "@app/components/v2";
import { useOrganization, useWorkspace } from "@app/context"; import { useOrganization, useWorkspace } from "@app/context";
import { import {
@@ -153,7 +153,7 @@ export const AddMemberModal = ({ popUp, handlePopUpToggle }: Props) => {
errorText={errors.orgMemberships?.[0]?.message} errorText={errors.orgMemberships?.[0]?.message}
label="Invite users to project" label="Invite users to project"
> >
<MultiSelect <FilterableSelect
className="w-full" className="w-full"
placeholder="Add one or more users..." placeholder="Add one or more users..."
isMulti isMulti
@@ -6,7 +6,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { z } from "zod"; import { z } from "zod";
import { createNotification } from "@app/components/notifications"; import { createNotification } from "@app/components/notifications";
import { Button, FormControl, Input, MultiSelect } from "@app/components/v2"; import { Button, FilterableSelect, FormControl, Input } from "@app/components/v2";
import { InfisicalSecretInput } from "@app/components/v2/InfisicalSecretInput"; import { InfisicalSecretInput } from "@app/components/v2/InfisicalSecretInput";
import { ProjectPermissionActions, ProjectPermissionSub, useProjectPermission } from "@app/context"; import { ProjectPermissionActions, ProjectPermissionSub, useProjectPermission } from "@app/context";
import { getKeyValue } from "@app/helpers/parseEnvVar"; import { getKeyValue } from "@app/helpers/parseEnvVar";
@@ -148,7 +148,7 @@ export const CreateSecretForm = ({
) )
} }
> >
<MultiSelect <FilterableSelect
className="w-full" className="w-full"
placeholder="Select tags to assign to secret..." placeholder="Select tags to assign to secret..."
isMulti isMulti
@@ -10,10 +10,10 @@ import { createNotification } from "@app/components/notifications";
import { import {
Button, Button,
Checkbox, Checkbox,
FilterableSelect,
FormControl, FormControl,
FormLabel, FormLabel,
Input, Input,
MultiSelect,
Tooltip Tooltip
} from "@app/components/v2"; } from "@app/components/v2";
import { InfisicalSecretInput } from "@app/components/v2/InfisicalSecretInput"; import { InfisicalSecretInput } from "@app/components/v2/InfisicalSecretInput";
@@ -249,7 +249,7 @@ export const CreateSecretForm = ({ secretPath = "/", getSecretByKey, onClose }:
) )
} }
> >
<MultiSelect <FilterableSelect
className="w-full" className="w-full"
placeholder="Select tags to assign to secrets..." placeholder="Select tags to assign to secrets..."
isMulti isMulti