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
cb7886dc
Commit
cb7886dc
authored
Apr 13, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: retire telegram integration in frontend
parent
d00e4fdf
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
473 additions
and
206 deletions
+473
-206
apidocs.swagger.md
server/route/api/v2/apidocs.swagger.md
+470
-80
PreferencesSection.tsx
web/src/components/Settings/PreferencesSection.tsx
+1
-58
WorkspaceSection.tsx
web/src/components/Settings/WorkspaceSection.tsx
+1
-62
en.json
web/src/locales/en.json
+1
-6
No files found.
server/route/api/v2/apidocs.swagger.md
View file @
cb7886dc
This diff is collapsed.
Click to expand it.
web/src/components/Settings/PreferencesSection.tsx
View file @
cb7886dc
import
{
Button
,
Divider
,
Input
,
Option
,
Select
}
from
"@mui/joy"
;
import
{
Divider
,
Option
,
Select
}
from
"@mui/joy"
;
import
{
useState
}
from
"react"
;
import
{
toast
}
from
"react-hot-toast"
;
import
{
Link
}
from
"react-router-dom"
;
import
{
useCommonContext
}
from
"@/layouts/CommonContextProvider"
;
import
{
useCommonContext
}
from
"@/layouts/CommonContextProvider"
;
import
{
useUserStore
}
from
"@/store/v1"
;
import
{
useUserStore
}
from
"@/store/v1"
;
import
{
Visibility
}
from
"@/types/proto/api/v2/memo_service"
;
import
{
Visibility
}
from
"@/types/proto/api/v2/memo_service"
;
...
@@ -9,7 +6,6 @@ import { UserSetting } from "@/types/proto/api/v2/user_service";
...
@@ -9,7 +6,6 @@ import { UserSetting } from "@/types/proto/api/v2/user_service";
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
convertVisibilityFromString
,
convertVisibilityToString
}
from
"@/utils/memo"
;
import
{
convertVisibilityFromString
,
convertVisibilityToString
}
from
"@/utils/memo"
;
import
AppearanceSelect
from
"../AppearanceSelect"
;
import
AppearanceSelect
from
"../AppearanceSelect"
;
import
Icon
from
"../Icon"
;
import
LocaleSelect
from
"../LocaleSelect"
;
import
LocaleSelect
from
"../LocaleSelect"
;
import
VisibilityIcon
from
"../VisibilityIcon"
;
import
VisibilityIcon
from
"../VisibilityIcon"
;
import
WebhookSection
from
"./WebhookSection"
;
import
WebhookSection
from
"./WebhookSection"
;
...
@@ -19,7 +15,6 @@ const PreferencesSection = () => {
...
@@ -19,7 +15,6 @@ const PreferencesSection = () => {
const
commonContext
=
useCommonContext
();
const
commonContext
=
useCommonContext
();
const
userStore
=
useUserStore
();
const
userStore
=
useUserStore
();
const
setting
=
userStore
.
userSetting
as
UserSetting
;
const
setting
=
userStore
.
userSetting
as
UserSetting
;
const
[
telegramUserId
,
setTelegramUserId
]
=
useState
<
string
>
(
setting
.
telegramUserId
);
const
handleLocaleSelectChange
=
async
(
locale
:
Locale
)
=>
{
const
handleLocaleSelectChange
=
async
(
locale
:
Locale
)
=>
{
commonContext
.
setLocale
(
locale
);
commonContext
.
setLocale
(
locale
);
...
@@ -50,25 +45,6 @@ const PreferencesSection = () => {
...
@@ -50,25 +45,6 @@ const PreferencesSection = () => {
);
);
};
};
const
handleSaveTelegramUserId
=
async
()
=>
{
try
{
await
userStore
.
updateUserSetting
(
{
telegramUserId
:
telegramUserId
,
},
[
"telegram_user_id"
],
);
toast
.
success
(
t
(
"message.update-succeed"
));
}
catch
(
error
:
any
)
{
console
.
error
(
error
);
toast
.
error
(
error
.
response
.
data
.
message
);
}
};
const
handleTelegramUserIdChanged
=
async
(
value
:
string
)
=>
{
setTelegramUserId
(
value
);
};
return
(
return
(
<
div
className=
"w-full flex flex-col gap-2 pt-2 pb-4"
>
<
div
className=
"w-full flex flex-col gap-2 pt-2 pb-4"
>
<
p
className=
"font-medium text-gray-700 dark:text-gray-500"
>
{
t
(
"common.basic"
)
}
</
p
>
<
p
className=
"font-medium text-gray-700 dark:text-gray-500"
>
{
t
(
"common.basic"
)
}
</
p
>
...
@@ -105,39 +81,6 @@ const PreferencesSection = () => {
...
@@ -105,39 +81,6 @@ const PreferencesSection = () => {
<
Divider
className=
"!my-3"
/>
<
Divider
className=
"!my-3"
/>
<
div
className=
"space-y-2 border rounded-md py-2 px-3 dark:border-zinc-700"
>
<
div
className=
"w-full flex flex-row justify-between items-center"
>
<
div
className=
"w-auto flex items-center"
>
<
span
className=
"mr-1"
>
{
t
(
"setting.preference-section.telegram-user-id"
)
}
</
span
>
</
div
>
<
Button
variant=
"outlined"
color=
"neutral"
onClick=
{
handleSaveTelegramUserId
}
>
{
t
(
"common.save"
)
}
</
Button
>
</
div
>
<
Input
className=
"w-full"
sx=
{
{
fontFamily
:
"monospace"
,
fontSize
:
"14px"
,
}
}
value=
{
telegramUserId
}
onChange=
{
(
event
)
=>
handleTelegramUserIdChanged
(
event
.
target
.
value
)
}
placeholder=
{
t
(
"setting.preference-section.telegram-user-id-placeholder"
)
}
/>
<
div
className=
"w-full"
>
<
Link
className=
"text-gray-500 text-sm inline-flex flex-row justify-start items-center hover:underline hover:text-blue-600"
to=
"https://usememos.com/docs/integration/telegram-bot"
target=
"_blank"
>
{
t
(
"common.learn-more"
)
}
<
Icon
.
ExternalLink
className=
"inline w-4 h-auto ml-1"
/>
</
Link
>
</
div
>
</
div
>
<
Divider
className=
"!my-3"
/>
<
WebhookSection
/>
<
WebhookSection
/>
</
div
>
</
div
>
);
);
...
...
web/src/components/Settings/WorkspaceSection.tsx
View file @
cb7886dc
...
@@ -4,11 +4,7 @@ import { toast } from "react-hot-toast";
...
@@ -4,11 +4,7 @@ import { toast } from "react-hot-toast";
import
{
Link
}
from
"react-router-dom"
;
import
{
Link
}
from
"react-router-dom"
;
import
{
workspaceSettingServiceClient
}
from
"@/grpcweb"
;
import
{
workspaceSettingServiceClient
}
from
"@/grpcweb"
;
import
{
WorkspaceSettingPrefix
,
useWorkspaceSettingStore
}
from
"@/store/v1"
;
import
{
WorkspaceSettingPrefix
,
useWorkspaceSettingStore
}
from
"@/store/v1"
;
import
{
import
{
WorkspaceGeneralSetting
,
WorkspaceMemoRelatedSetting
}
from
"@/types/proto/api/v2/workspace_setting_service"
;
WorkspaceGeneralSetting
,
WorkspaceMemoRelatedSetting
,
WorkspaceTelegramIntegrationSetting
,
}
from
"@/types/proto/api/v2/workspace_setting_service"
;
import
{
WorkspaceSettingKey
}
from
"@/types/proto/store/workspace_setting"
;
import
{
WorkspaceSettingKey
}
from
"@/types/proto/store/workspace_setting"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
{
showCommonDialog
}
from
"../Dialog/CommonDialog"
;
import
{
showCommonDialog
}
from
"../Dialog/CommonDialog"
;
...
@@ -28,12 +24,6 @@ const WorkspaceSection = () => {
...
@@ -28,12 +24,6 @@ const WorkspaceSection = () => {
workspaceSettingStore
.
getWorkspaceSettingByKey
(
WorkspaceSettingKey
.
WORKSPACE_SETTING_MEMO_RELATED
)?.
memoRelatedSetting
||
{},
workspaceSettingStore
.
getWorkspaceSettingByKey
(
WorkspaceSettingKey
.
WORKSPACE_SETTING_MEMO_RELATED
)?.
memoRelatedSetting
||
{},
),
),
);
);
const
[
workspaceTelegramIntegrationSetting
,
setWorkspaceTelegramIntegrationSetting
]
=
useState
<
WorkspaceTelegramIntegrationSetting
>
(
WorkspaceTelegramIntegrationSetting
.
fromPartial
(
workspaceSettingStore
.
getWorkspaceSettingByKey
(
WorkspaceSettingKey
.
WORKSPACE_SETTING_TELEGRAM_INTEGRATION
)
?.
telegramIntegrationSetting
||
{},
),
);
const
handleAllowSignUpChanged
=
async
(
value
:
boolean
)
=>
{
const
handleAllowSignUpChanged
=
async
(
value
:
boolean
)
=>
{
const
setting
=
{
...
workspaceGeneralSetting
,
disallowSignup
:
!
value
};
const
setting
=
{
...
workspaceGeneralSetting
,
disallowSignup
:
!
value
};
...
@@ -96,23 +86,6 @@ const WorkspaceSection = () => {
...
@@ -96,23 +86,6 @@ const WorkspaceSection = () => {
toast
.
success
(
"Instance URL updated"
);
toast
.
success
(
"Instance URL updated"
);
};
};
const
handleTelegramBotTokenChanged
=
(
value
:
string
)
=>
{
setWorkspaceTelegramIntegrationSetting
({
...
workspaceTelegramIntegrationSetting
,
botToken
:
value
});
};
const
handleSaveTelegramBotToken
=
async
()
=>
{
try
{
await
workspaceSettingStore
.
setWorkspaceSetting
({
name
:
`
${
WorkspaceSettingPrefix
}${
WorkspaceSettingKey
.
WORKSPACE_SETTING_TELEGRAM_INTEGRATION
}
`
,
telegramIntegrationSetting
:
workspaceTelegramIntegrationSetting
,
});
toast
.
success
(
"Telegram Bot Token updated"
);
}
catch
(
error
:
any
)
{
console
.
error
(
error
);
toast
.
error
(
error
.
details
);
}
};
const
handleAdditionalStyleChanged
=
(
value
:
string
)
=>
{
const
handleAdditionalStyleChanged
=
(
value
:
string
)
=>
{
setWorkspaceGeneralSetting
({
...
workspaceGeneralSetting
,
additionalStyle
:
value
});
setWorkspaceGeneralSetting
({
...
workspaceGeneralSetting
,
additionalStyle
:
value
});
};
};
...
@@ -290,40 +263,6 @@ const WorkspaceSection = () => {
...
@@ -290,40 +263,6 @@ const WorkspaceSection = () => {
onChange=
{
(
event
)
=>
handleMemoDisplayWithUpdatedTs
(
event
.
target
.
checked
)
}
onChange=
{
(
event
)
=>
handleMemoDisplayWithUpdatedTs
(
event
.
target
.
checked
)
}
/>
/>
</
div
>
</
div
>
<
Divider
className=
"!my-3"
/>
<
p
className=
"font-medium text-gray-700 dark:text-gray-500"
>
Integrations
</
p
>
<
div
className=
"space-y-2 border rounded-md py-2 px-3 dark:border-zinc-700"
>
<
div
className=
"w-full flex flex-row justify-between items-center"
>
<
div
className=
"flex flex-row items-center"
>
<
div
className=
"w-auto flex items-center"
>
<
span
className=
"mr-1"
>
{
t
(
"setting.system-section.telegram-bot-token"
)
}
</
span
>
</
div
>
</
div
>
<
Button
variant=
"outlined"
color=
"neutral"
onClick=
{
handleSaveTelegramBotToken
}
>
{
t
(
"common.save"
)
}
</
Button
>
</
div
>
<
Input
className=
"w-full"
sx=
{
{
fontFamily
:
"monospace"
,
fontSize
:
"14px"
,
}
}
placeholder=
{
t
(
"setting.system-section.telegram-bot-token-placeholder"
)
}
value=
{
workspaceTelegramIntegrationSetting
.
botToken
}
onChange=
{
(
event
)
=>
handleTelegramBotTokenChanged
(
event
.
target
.
value
)
}
/>
<
div
className=
"w-full"
>
<
Link
className=
"text-gray-500 text-sm inline-flex flex-row justify-start items-center hover:underline hover:text-blue-600"
to=
"https://usememos.com/docs/integration/telegram-bot"
target=
"_blank"
>
{
t
(
"common.learn-more"
)
}
<
Icon
.
ExternalLink
className=
"inline w-4 h-auto ml-1"
/>
</
Link
>
</
div
>
</
div
>
</
div
>
</
div
>
);
);
};
};
...
...
web/src/locales/en.json
View file @
cb7886dc
...
@@ -194,9 +194,7 @@
...
@@ -194,9 +194,7 @@
"preference-section"
:
{
"preference-section"
:
{
"theme"
:
"Theme"
,
"theme"
:
"Theme"
,
"default-memo-visibility"
:
"Default memo visibility"
,
"default-memo-visibility"
:
"Default memo visibility"
,
"default-memo-sort-option"
:
"Memo display time"
,
"default-memo-sort-option"
:
"Memo display time"
"telegram-user-id"
:
"Telegram UserID"
,
"telegram-user-id-placeholder"
:
"Send any words to your Telegram Bot as a memo"
},
},
"storage-section"
:
{
"storage-section"
:
{
"current-storage"
:
"Current object storage"
,
"current-storage"
:
"Current object storage"
,
...
@@ -262,9 +260,6 @@
...
@@ -262,9 +260,6 @@
"additional-script"
:
"Additional script"
,
"additional-script"
:
"Additional script"
,
"additional-style-placeholder"
:
"Additional CSS code"
,
"additional-style-placeholder"
:
"Additional CSS code"
,
"additional-script-placeholder"
:
"Additional JavaScript code"
,
"additional-script-placeholder"
:
"Additional JavaScript code"
,
"telegram-bot-token"
:
"Telegram Bot Token"
,
"telegram-bot-token-description"
:
"Telegram Bot Token or API Proxy like `http…/bot<token>`"
,
"telegram-bot-token-placeholder"
:
"Your Telegram Bot token"
,
"display-with-updated-time"
:
"Display with updated time"
"display-with-updated-time"
:
"Display with updated time"
},
},
"appearance-option"
:
{
"appearance-option"
:
{
...
...
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