diff --git a/containers/ClusterForms/shared/AuthForm/AuthForm.tsx b/containers/ClusterForms/shared/AuthForm/AuthForm.tsx index 278b4b59..43a227f8 100644 --- a/containers/ClusterForms/shared/AuthForm/AuthForm.tsx +++ b/containers/ClusterForms/shared/AuthForm/AuthForm.tsx @@ -43,12 +43,12 @@ import { hasProjectId } from '@/utils/hasProjectId'; import { getDigitalOceanUser } from '@/redux/thunks/digitalOcean.thunk'; import { GIT_PROVIDER_DISPLAY_NAME } from '@/constants'; import { useDebouncedPromise } from '@/hooks/useDebouncedPromise'; +import { setadminteamname, setdeveloperteamname, setgitreponame, setmetaphorname } from '@/redux/slices/git.slice'; const AuthForm: FunctionComponent = () => { const [showGoogleKeyFile, setShowGoogleKeyFile] = useState(false); const dispatch = useAppDispatch(); - const { gitProvider, githubUser, @@ -60,7 +60,11 @@ const AuthForm: FunctionComponent = () => { isGitSelected, installMethod, token = '', - } = useAppSelector(({ config, installation, git, digitalOcean }) => ({ + gitopsreponame, + metaphorreponame, + adminteamname, + developerteamname + } = useAppSelector(({ config, installation, git, digitalOcean, }) => ({ currentStep: installation.installationStep, installationType: installation.installType, gitProvider: installation.gitProvider, @@ -69,6 +73,10 @@ const AuthForm: FunctionComponent = () => { installMethod: config.installMethod, ...git, ...digitalOcean, + gitopsreponame: git.gitopsreponame, + metaphorreponame: git.metaphorreponame, + adminteamname: git.adminteamname, + developerteamname: git.developerteamname })); const { apiKeyInfo } = useInstallation( @@ -132,6 +140,22 @@ const AuthForm: FunctionComponent = () => { }, [isGitHub, dispatch, setError, clearErrors, resetField], ); + const handleGitrepochange= (e: { target: { value: string; }; }) =>{ + dispatch(setgitreponame(e.target.value)) + }; + + const handleMetachange= (e: { target: { value: string; }; }) => { + dispatch(setmetaphorname(e.target.value)) + }; + + const handleAdminchange= (e: { target: { value: any; }; }) => { + dispatch(setadminteamname(e.target.value)) + }; + + const handleDeveloperchange= (e: { target: { value: any; }; }) => { + dispatch(setdeveloperteamname(e.target.value)) + }; + const handleGitProviderChange = (provider: GitProvider) => { reset({ gitToken: '', gitOwner: '' }); @@ -263,7 +287,8 @@ const AuthForm: FunctionComponent = () => { {isGitHub ? ( - + { label={`${gitLabel} organization name`} onClick={() => trigger('gitToken', { shouldFocus: true })} /> + + + + + {/* */} + + + ) : ( { onClick={() => trigger('gitToken', { shouldFocus: true })} /> )} + + {installationType === InstallationType.GOOGLE && ( <> diff --git a/containers/ClusterForms/shared/SetupForm.tsx b/containers/ClusterForms/shared/SetupForm.tsx index e3a64173..6002413d 100644 --- a/containers/ClusterForms/shared/SetupForm.tsx +++ b/containers/ClusterForms/shared/SetupForm.tsx @@ -69,7 +69,7 @@ const SetupForm: FunctionComponent = () => { formState: { errors }, watch, } = useFormContext(); - + console.log(cloudRegions); const [domainName, subDomain, dnsProvider, cloudRegion, cloudflareToken, cloudZone] = watch([ 'domainName', 'subDomain', diff --git a/redux/slices/git.slice.ts b/redux/slices/git.slice.ts index b204122d..fe92c396 100644 --- a/redux/slices/git.slice.ts +++ b/redux/slices/git.slice.ts @@ -15,12 +15,17 @@ import { GitLabGroup, GitLabUser } from '@/types/gitlab'; import { KUBEFIRST_REPOSITORIES, KUBEFIRST_TEAMS } from '@/constants'; import { createGitOrgErrorMessage } from '@/utils/createGitOrgErrorMessage'; import { GitProvider } from '@/types'; +import { action } from '@storybook/addon-actions/*'; export interface GitState { githubUser: GithubUser | null; githubUserOrganizations: Array; gitlabUser: GitLabUser | null; gitlabGroups: Array; + gitopsreponame: string; + metaphorreponame: string; + adminteamname: string; + developerteamname: string; isLoading: boolean; isTokenValid: boolean; errors: Array; @@ -36,6 +41,10 @@ export const initialState: GitState = { gitlabUser: null, gitlabGroups: [], isLoading: false, + gitopsreponame:"gitops", + metaphorreponame:"metaphor", + adminteamname:"admins", + developerteamname:"developers", isTokenValid: false, errors: [], }; @@ -68,6 +77,18 @@ const gitSlice = createSlice({ clearResponseError: (state) => { state.responseError = undefined; }, + setgitreponame :(state,action)=>{ + state.gitopsreponame = action.payload; + }, + setmetaphorname : (state,action)=>{ + state.metaphorreponame = action.payload; + }, + setadminteamname : (state,action)=>{ + state.adminteamname=action.payload; + }, + setdeveloperteamname : (state,action)=>{ + state.developerteamname=action.payload; + } }, extraReducers: (builder) => { builder @@ -111,8 +132,9 @@ const gitSlice = createSlice({ getGitHubOrgRepositories.fulfilled, (state, { meta, payload: organizationRepos }) => { state.gitOwner = meta.arg.organization; + const repos = [state.gitopsreponame,state.metaphorreponame]; const kubefirstRepos = organizationRepos.filter(({ name }) => - KUBEFIRST_REPOSITORIES.includes(name), + repos.includes(name), ); if (kubefirstRepos.length) { state.errors.push( @@ -135,8 +157,9 @@ const gitSlice = createSlice({ }) .addCase(getGitHubOrgTeams.fulfilled, (state, { payload: organizationTeams }) => { state.isLoading = false; + const teams = [state.adminteamname,state.metaphorreponame]; const kubefirstTeams = organizationTeams.filter(({ name }) => - KUBEFIRST_TEAMS.includes(name), + teams.includes(name), ); if (kubefirstTeams.length) { @@ -234,7 +257,7 @@ const gitSlice = createSlice({ }, }); -export const { clearGitState, clearUserError, setIsGitSelected, clearResponseError, setGitOwner } = +export const { clearGitState, clearUserError, setIsGitSelected, clearResponseError, setGitOwner, setadminteamname, setdeveloperteamname, setmetaphorname,setgitreponame } = gitSlice.actions; export const gitReducer = gitSlice.reducer; diff --git a/redux/store.ts b/redux/store.ts index b241ced9..95d64f09 100644 --- a/redux/store.ts +++ b/redux/store.ts @@ -5,7 +5,6 @@ import { createWrapper } from 'next-redux-wrapper'; import { persistStore, persistReducer } from 'redux-persist'; import storage from 'redux-persist/lib/storage/session'; import { getPersistConfig } from 'redux-deep-persist'; - import { consoleApi } from './api'; import { apiReducer, diff --git a/redux/thunks/api.thunk.ts b/redux/thunks/api.thunk.ts index ef247c25..014b909c 100644 --- a/redux/thunks/api.thunk.ts +++ b/redux/thunks/api.thunk.ts @@ -31,6 +31,7 @@ export const createCluster = createAsyncThunk< >('api/cluster/provisioning', async (_, { getState }) => { const { installation: { installType, gitProvider, values }, + git } = getState(); const params = { @@ -42,7 +43,11 @@ export const createCluster = createAsyncThunk< subdomain_name: values?.subDomain, git_provider: gitProvider, gitops_template_url: values?.gitopsTemplateUrl, - gitops_template_branch: values?.gitopsTemplateBranch, + gitops_template_branch: "feat-custom-repo", + gitopsRepoName: git.gitopsreponame, + metaphorRepoName: git.metaphorreponame, + adminTeamName: git.adminteamname, + developerTeamName: git.developerteamname, git_protocol: values?.useHttps ? GitProtocol.HTTPS : GitProtocol.SSH, dns_provider: values?.dnsProvider, ecr: values?.imageRepository === ImageRepository.ECR,