Skip to content

Commit 6626f0f

Browse files
Edit remote name is removed (#96)
1 parent dae81fd commit 6626f0f

File tree

2 files changed

+64
-72
lines changed

2 files changed

+64
-72
lines changed

ui/package-lock.json

Lines changed: 54 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/src/Components/DashBoard/Repository/RepoComponents/RepoDetails/RepoDetailBackdrop/RemoteConfigComponent/RemoteCard.js

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,23 @@ export default function RemoteCard(props) {
2929
setStatusCheck,
3030
setRemoteOperation,
3131
} = props;
32-
const remoteFormName = useRef();
32+
3333
const remoteFormUrl = useRef();
3434

35-
const [remoteNameState, setRemoteNameState] = useState(remoteName);
3635
const [remoteUrlState, setRemoteUrlState] = useState(remoteUrl);
3736
const [editRemote, setEditRemote] = useState(false);
3837
const [deleteRemote, setDeleteRemote] = useState(false);
3938

4039
var globalUrl = remoteUrl;
4140

42-
const changeState = (newRemoteName, oldRemoteName, url) => {
41+
const changeState = (remoteName, url) => {
4342
axios({
4443
url: globalAPIEndpoint,
4544
method: "POST",
4645
data: {
4746
query: `
4847
mutation {
49-
editRemote(repoId: "${repoId}", remoteName: "${oldRemoteName}", remoteUrl: "${url}"){
48+
editRemote(repoId: "${repoId}", remoteName: "${remoteName}", remoteUrl: "${url}"){
5049
status
5150
}
5251
}
@@ -69,7 +68,6 @@ export default function RemoteCard(props) {
6968
setRemoteOperation("edit");
7069
});
7170

72-
setRemoteNameState(newRemoteName);
7371
setRemoteUrlState(url);
7472
setEditRemote(false);
7573
setFieldMissing(false);
@@ -145,6 +143,10 @@ export default function RemoteCard(props) {
145143
<div className="w-full">
146144
{editRemote ? (
147145
<div className="flex items-center w-full py-6 mx-auto my-1 align-middle rounded-md shadow bg-gray-50">
146+
<div className="flex items-center justify-center w-1/5 mx-auto text-base text-gray-700 text-sans xl:text-lg lg:text-lg md:text-base">
147+
{getRemoteLogo(remoteUrlState)}
148+
<div className="w-1/2">{remoteName}</div>
149+
</div>
148150
<div className="flex items-center justify-center w-1/2 mx-auto text-base text-center text-gray-700 text-sans xl:text-lg lg:text-lg md:text-base">
149151
<input
150152
type="text"
@@ -169,23 +171,13 @@ export default function RemoteCard(props) {
169171
<div
170172
className="items-center w-5/12 p-1 py-2 mx-auto text-base font-semibold bg-blue-500 rounded cursor-pointer xl:text-lg lg:text-lg md:text-base hover:bg-blue-700"
171173
onClick={() => {
172-
let newRemoteName;
173-
let oldRemoteName = remoteNameState.trim();
174174
let url = !remoteFormUrl.current.value
175175
? remoteUrlState.trim()
176176
: remoteFormUrl.current.value.trim();
177177
if (url.match(/(\s)/g) || url.length === 0) {
178178
setInvalidUrl(true);
179179
} else {
180-
if (
181-
!remoteFormName.current.value ||
182-
remoteFormName.current.value === remoteNameState
183-
) {
184-
newRemoteName = oldRemoteName;
185-
} else {
186-
newRemoteName = remoteFormName.current.value.trim();
187-
}
188-
changeState(newRemoteName, oldRemoteName, url);
180+
changeState(remoteName.trim(), url);
189181
}
190182
}}
191183
>
@@ -219,7 +211,7 @@ export default function RemoteCard(props) {
219211
<div className="flex items-center w-full py-6 mx-auto my-1 align-middle rounded-md shadow bg-gray-50">
220212
<div className="flex items-center justify-center w-1/4 mx-auto text-base text-gray-700 text-sans xl:text-lg lg:text-lg md:text-base">
221213
{getRemoteLogo(remoteUrlState)}
222-
<div className="w-1/2">{remoteNameState}</div>
214+
<div className="w-1/2">{remoteName}</div>
223215
</div>
224216
<div className="flex items-center justify-center w-7/12 mx-auto text-base text-center text-gray-700 text-sans xl:text-lg lg:text-lg md:text-base">
225217
{remoteUrlHandler(remoteUrlState)}
@@ -252,7 +244,7 @@ export default function RemoteCard(props) {
252244
data: {
253245
query: `
254246
mutation {
255-
deleteRemote(repoId: "${repoId}", remoteName: "${remoteNameState}"){
247+
deleteRemote(repoId: "${repoId}", remoteName: "${remoteName}"){
256248
status
257249
}
258250
}

0 commit comments

Comments
 (0)