Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions containers/ClusterForms/shared/AuthForm/AuthForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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(
Expand Down Expand Up @@ -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: '' });
Expand Down Expand Up @@ -263,7 +287,8 @@ const AuthForm: FunctionComponent = () => {
</GitFieldsContainer>

{isGitHub ? (
<ControlledAutocomplete
<div>
<ControlledAutocomplete
control={control}
required
name="gitOwner"
Expand All @@ -277,6 +302,14 @@ const AuthForm: FunctionComponent = () => {
label={`${gitLabel} organization name`}
onClick={() => trigger('gitToken', { shouldFocus: true })}
/>
<input value={gitopsreponame} onChange={handleGitrepochange}></input>
<input value={metaphorreponame} onChange={handleMetachange}></input>
<input value={adminteamname} onChange={handleAdminchange}></input>
<input value={developerteamname} onChange={handleDeveloperchange}></input>
{/* <input value=></input> */}
</div>


) : (
<ControlledAutocomplete
control={control}
Expand All @@ -292,6 +325,8 @@ const AuthForm: FunctionComponent = () => {
onClick={() => trigger('gitToken', { shouldFocus: true })}
/>
)}


{installationType === InstallationType.GOOGLE && (
<>
<Column style={{ gap: '10px' }}>
Expand Down
2 changes: 1 addition & 1 deletion containers/ClusterForms/shared/SetupForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const SetupForm: FunctionComponent = () => {
formState: { errors },
watch,
} = useFormContext<InstallValues>();

console.log(cloudRegions);
const [domainName, subDomain, dnsProvider, cloudRegion, cloudflareToken, cloudZone] = watch([
'domainName',
'subDomain',
Expand Down
29 changes: 26 additions & 3 deletions redux/slices/git.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<GithubUserOrganization>;
gitlabUser: GitLabUser | null;
gitlabGroups: Array<GitLabGroup>;
gitopsreponame: string;
metaphorreponame: string;
adminteamname: string;
developerteamname: string;
isLoading: boolean;
isTokenValid: boolean;
errors: Array<string>;
Expand All @@ -36,6 +41,10 @@ export const initialState: GitState = {
gitlabUser: null,
gitlabGroups: [],
isLoading: false,
gitopsreponame:"gitops",
metaphorreponame:"metaphor",
adminteamname:"admins",
developerteamname:"developers",
isTokenValid: false,
errors: [],
};
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
1 change: 0 additions & 1 deletion redux/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion redux/thunks/api.thunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const createCluster = createAsyncThunk<
>('api/cluster/provisioning', async (_, { getState }) => {
const {
installation: { installType, gitProvider, values },
git
} = getState();

const params = {
Expand All @@ -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,
Expand Down