Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
836e496e
Unverified
Commit
836e496e
authored
Apr 03, 2023
by
boojack
Committed by
GitHub
Apr 03, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: allow remove user avatar (#1454)
parent
5aa4ba32
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
40 deletions
+44
-40
UpdateAccountDialog.tsx
web/src/components/UpdateAccountDialog.tsx
+25
-15
UpdateCustomizedProfileDialog.tsx
web/src/components/UpdateCustomizedProfileDialog.tsx
+19
-25
No files found.
web/src/components/UpdateAccountDialog.tsx
View file @
836e496e
...
@@ -36,6 +36,15 @@ const UpdateAccountDialog: React.FC<Props> = ({ destroy }: Props) => {
...
@@ -36,6 +36,15 @@ const UpdateAccountDialog: React.FC<Props> = ({ destroy }: Props) => {
destroy
();
destroy
();
};
};
const
setPartialState
=
(
partialState
:
Partial
<
State
>
)
=>
{
setState
((
state
)
=>
{
return
{
...
state
,
...
partialState
,
};
});
};
const
handleAvatarChanged
=
async
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
handleAvatarChanged
=
async
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
files
=
e
.
target
.
files
;
const
files
=
e
.
target
.
files
;
if
(
files
&&
files
.
length
>
0
)
{
if
(
files
&&
files
.
length
>
0
)
{
...
@@ -46,11 +55,8 @@ const UpdateAccountDialog: React.FC<Props> = ({ destroy }: Props) => {
...
@@ -46,11 +55,8 @@ const UpdateAccountDialog: React.FC<Props> = ({ destroy }: Props) => {
}
}
try
{
try
{
const
base64
=
await
convertFileToBase64
(
image
);
const
base64
=
await
convertFileToBase64
(
image
);
setState
((
state
)
=>
{
setPartialState
({
return
{
...
state
,
avatarUrl
:
base64
,
avatarUrl
:
base64
,
};
});
});
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
error
);
console
.
error
(
error
);
...
@@ -60,20 +66,14 @@ const UpdateAccountDialog: React.FC<Props> = ({ destroy }: Props) => {
...
@@ -60,20 +66,14 @@ const UpdateAccountDialog: React.FC<Props> = ({ destroy }: Props) => {
};
};
const
handleNicknameChanged
=
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
handleNicknameChanged
=
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
setState
((
state
)
=>
{
setPartialState
({
return
{
...
state
,
nickname
:
e
.
target
.
value
as
string
,
nickname
:
e
.
target
.
value
as
string
,
};
});
});
};
};
const
handleUsernameChanged
=
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
handleUsernameChanged
=
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
setState
((
state
)
=>
{
setPartialState
({
return
{
...
state
,
username
:
e
.
target
.
value
as
string
,
username
:
e
.
target
.
value
as
string
,
};
});
});
};
};
...
@@ -133,6 +133,16 @@ const UpdateAccountDialog: React.FC<Props> = ({ destroy }: Props) => {
...
@@ -133,6 +133,16 @@ const UpdateAccountDialog: React.FC<Props> = ({ destroy }: Props) => {
<
UserAvatar
className=
"!w-12 !h-12"
avatarUrl=
{
state
.
avatarUrl
}
/>
<
UserAvatar
className=
"!w-12 !h-12"
avatarUrl=
{
state
.
avatarUrl
}
/>
<
input
type=
"file"
accept=
"image/*"
className=
"absolute invisible w-full h-full inset-0"
onChange=
{
handleAvatarChanged
}
/>
<
input
type=
"file"
accept=
"image/*"
className=
"absolute invisible w-full h-full inset-0"
onChange=
{
handleAvatarChanged
}
/>
</
label
>
</
label
>
{
state
.
avatarUrl
&&
(
<
Icon
.
X
className=
"w-4 h-auto ml-1 cursor-pointer opacity-60 hover:opacity-80"
onClick=
{
()
=>
setPartialState
({
avatarUrl
:
""
,
})
}
/>
)
}
</
div
>
</
div
>
<
p
className=
"text-sm"
>
<
p
className=
"text-sm"
>
{
t
(
"common.username"
)
}
{
t
(
"common.username"
)
}
...
...
web/src/components/UpdateCustomizedProfileDialog.tsx
View file @
836e496e
...
@@ -19,53 +19,47 @@ const UpdateCustomizedProfileDialog: React.FC<Props> = ({ destroy }: Props) => {
...
@@ -19,53 +19,47 @@ const UpdateCustomizedProfileDialog: React.FC<Props> = ({ destroy }: Props) => {
destroy
();
destroy
();
};
};
const
handleNameChanged
=
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
setPartialState
=
(
partialState
:
Partial
<
CustomizedProfile
>
)
=>
{
setState
((
state
)
=>
{
setState
((
state
)
=>
{
return
{
return
{
...
state
,
...
state
,
name
:
e
.
target
.
value
as
string
,
...
partialState
,
};
});
};
};
const
handleNameChanged
=
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
setPartialState
({
name
:
e
.
target
.
value
as
string
,
});
});
};
};
const
handleLogoUrlChanged
=
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
handleLogoUrlChanged
=
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
setState
((
state
)
=>
{
setPartialState
({
return
{
...
state
,
logoUrl
:
e
.
target
.
value
as
string
,
logoUrl
:
e
.
target
.
value
as
string
,
};
});
});
};
};
const
handleDescriptionChanged
=
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
handleDescriptionChanged
=
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
setState
((
state
)
=>
{
setPartialState
({
return
{
...
state
,
description
:
e
.
target
.
value
as
string
,
description
:
e
.
target
.
value
as
string
,
};
});
});
};
};
const
handleLocaleSelectChange
=
(
locale
:
Locale
)
=>
{
const
handleLocaleSelectChange
=
(
locale
:
Locale
)
=>
{
setState
((
state
)
=>
{
setPartialState
({
return
{
...
state
,
locale
:
locale
,
locale
:
locale
,
};
});
});
};
};
const
handleAppearanceSelectChange
=
(
appearance
:
Appearance
)
=>
{
const
handleAppearanceSelectChange
=
(
appearance
:
Appearance
)
=>
{
setState
((
state
)
=>
{
setPartialState
({
return
{
...
state
,
appearance
:
appearance
,
appearance
:
appearance
,
};
});
});
};
};
const
handleRestoreButtonClick
=
()
=>
{
const
handleRestoreButtonClick
=
()
=>
{
setState
({
set
Partial
State
({
name
:
"memos"
,
name
:
"memos"
,
logoUrl
:
"/logo.webp"
,
logoUrl
:
"/logo.webp"
,
description
:
""
,
description
:
""
,
...
@@ -114,9 +108,9 @@ const UpdateCustomizedProfileDialog: React.FC<Props> = ({ destroy }: Props) => {
...
@@ -114,9 +108,9 @@ const UpdateCustomizedProfileDialog: React.FC<Props> = ({ destroy }: Props) => {
<
p
className=
"text-sm mb-1 mt-2"
>
Description
</
p
>
<
p
className=
"text-sm mb-1 mt-2"
>
Description
</
p
>
<
input
type=
"text"
className=
"input-text"
value=
{
state
.
description
}
onChange=
{
handleDescriptionChanged
}
/>
<
input
type=
"text"
className=
"input-text"
value=
{
state
.
description
}
onChange=
{
handleDescriptionChanged
}
/>
<
p
className=
"text-sm mb-1 mt-2"
>
Server locale
</
p
>
<
p
className=
"text-sm mb-1 mt-2"
>
Server locale
</
p
>
<
LocaleSelect
className=
"w-full"
value=
{
state
.
locale
}
onChange=
{
handleLocaleSelectChange
}
/>
<
LocaleSelect
className=
"
!
w-full"
value=
{
state
.
locale
}
onChange=
{
handleLocaleSelectChange
}
/>
<
p
className=
"text-sm mb-1 mt-2"
>
Server appearance
</
p
>
<
p
className=
"text-sm mb-1 mt-2"
>
Server appearance
</
p
>
<
AppearanceSelect
className=
"w-full"
value=
{
state
.
appearance
}
onChange=
{
handleAppearanceSelectChange
}
/>
<
AppearanceSelect
className=
"
!
w-full"
value=
{
state
.
appearance
}
onChange=
{
handleAppearanceSelectChange
}
/>
<
div
className=
"mt-4 w-full flex flex-row justify-between items-center space-x-2"
>
<
div
className=
"mt-4 w-full flex flex-row justify-between items-center space-x-2"
>
<
div
className=
"flex flex-row justify-start items-center"
>
<
div
className=
"flex flex-row justify-start items-center"
>
<
button
className=
"btn-normal"
onClick=
{
handleRestoreButtonClick
}
>
<
button
className=
"btn-normal"
onClick=
{
handleRestoreButtonClick
}
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment