Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Clash Verge
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Clash Verge
Commits
5b779b4f
There was an error fetching the commit references. Please try again later.
Unverified
Commit
5b779b4f
authored
3 years ago
by
GyDi
Browse files
Options
Downloads
Patches
Plain Diff
feat: new profile able to edit name and desc
parent
fc48aa71
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/profile/profile-new.tsx
+64
-0
64 additions, 0 deletions
src/components/profile/profile-new.tsx
src/pages/profiles.tsx
+15
-6
15 additions, 6 deletions
src/pages/profiles.tsx
with
79 additions
and
6 deletions
src/components/profile/profile-new.tsx
0 → 100644
+
64
−
0
View file @
5b779b4f
import
{
useState
}
from
"
react
"
;
import
{
Button
,
Dialog
,
DialogActions
,
DialogContent
,
DialogTitle
,
TextField
,
}
from
"
@mui/material
"
;
import
Notice
from
"
../base/base-notice
"
;
interface
Props
{
open
:
boolean
;
onClose
:
()
=>
void
;
onSubmit
:
(
name
:
string
,
desc
:
string
)
=>
void
;
}
const
ProfileNew
=
(
props
:
Props
)
=>
{
const
{
open
,
onClose
,
onSubmit
}
=
props
;
const
[
name
,
setName
]
=
useState
(
""
);
const
[
desc
,
setDesc
]
=
useState
(
""
);
const
onCreate
=
()
=>
{
if
(
!
name
.
trim
())
{
Notice
.
error
(
"
`Name` should not be null
"
);
return
;
}
onSubmit
(
name
,
desc
);
};
return
(
<
Dialog
open
=
{
open
}
onClose
=
{
onClose
}
>
<
DialogTitle
>
Create Profile
</
DialogTitle
>
<
DialogContent
sx
=
{
{
width
:
320
,
pb
:
0.5
}
}
>
<
TextField
autoFocus
fullWidth
label
=
"Name"
margin
=
"dense"
variant
=
"outlined"
value
=
{
name
}
onChange
=
{
(
e
)
=>
setName
(
e
.
target
.
value
)
}
/>
<
TextField
fullWidth
label
=
"Descriptions"
margin
=
"normal"
variant
=
"outlined"
value
=
{
desc
}
onChange
=
{
(
e
)
=>
setDesc
(
e
.
target
.
value
)
}
/>
</
DialogContent
>
<
DialogActions
sx
=
{
{
px
:
2
,
pb
:
2
}
}
>
<
Button
onClick
=
{
onClose
}
>
Cancel
</
Button
>
<
Button
onClick
=
{
onCreate
}
variant
=
"contained"
>
Create
</
Button
>
</
DialogActions
>
</
Dialog
>
);
};
export
default
ProfileNew
;
This diff is collapsed.
Click to expand it.
src/pages/profiles.tsx
+
15
−
6
View file @
5b779b4f
...
...
@@ -10,9 +10,10 @@ import {
}
from
"
../services/cmds
"
;
import
{
getProxies
,
updateProxy
}
from
"
../services/api
"
;
import
noop
from
"
../utils/noop
"
;
import
Notice
from
"
../components/notice
"
;
import
BasePage
from
"
../components/base-page
"
;
import
ProfileItem
from
"
../components/profile-item
"
;
import
Notice
from
"
../components/base/base-notice
"
;
import
BasePage
from
"
../components/base/base-page
"
;
import
ProfileItem
from
"
../components/profile/profile-item
"
;
import
ProfileNew
from
"
../components/profile/profile-new
"
;
const
ProfilePage
=
()
=>
{
const
[
url
,
setUrl
]
=
useState
(
""
);
...
...
@@ -96,13 +97,15 @@ const ProfilePage = () => {
};
const
lockNewRef
=
useRef
(
false
);
const
onNew
=
async
()
=>
{
const
[
dialogOpen
,
setDialogOpen
]
=
useState
(
false
);
const
onNew
=
async
(
name
:
string
,
desc
:
string
)
=>
{
if
(
lockNewRef
.
current
)
return
;
lockNewRef
.
current
=
true
;
try
{
await
newProfile
(
"
New Profile
"
,
"
no
desc
"
);
await
newProfile
(
name
,
desc
);
mutate
(
"
getProfiles
"
);
setDialogOpen
(
false
);
}
catch
(
err
:
any
)
{
err
&&
Notice
.
error
(
err
.
toString
());
}
finally
{
...
...
@@ -131,7 +134,7 @@ const ProfilePage = () => {
>
Import
</
Button
>
<
Button
variant
=
"contained"
onClick
=
{
onNew
}
>
<
Button
variant
=
"contained"
onClick
=
{
()
=>
setDialogOpen
(
true
)
}
>
New
</
Button
>
</
Box
>
...
...
@@ -148,6 +151,12 @@ const ProfilePage = () => {
</
Grid
>
))
}
</
Grid
>
<
ProfileNew
open
=
{
dialogOpen
}
onClose
=
{
()
=>
setDialogOpen
(
false
)
}
onSubmit
=
{
onNew
}
/>
</
BasePage
>
);
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment