Skip to content

Commit

Permalink
refactor(upload): improve workflow with STS tokens (#148)
Browse files Browse the repository at this point in the history
* refactor: wip

* chore: adjust theme
  • Loading branch information
mydearxym authored Oct 15, 2023
1 parent 45918f9 commit aeb0a91
Show file tree
Hide file tree
Showing 50 changed files with 444 additions and 143 deletions.
14 changes: 7 additions & 7 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@
"grey": 11
},
"//--- endpoint configs ---//": "",
"ASSETS_ENDPOINT": "https://assets.groupher.com",
"ICON": "https://assets.groupher.com/icons/static",
"ICON_BASE": "https://assets.groupher.com/icons",
"ICON_CMD": "https://assets.groupher.com/icons/cmd",
"DEFAULT_ICON": "https://assets.groupher.com/icons/cmd/cheatsheet.svg",
"DEFAULT_USER_AVATAR": "https://assets.groupher.com/icons/cmd/alien_user3.svg",
"ASSETS_ENDPOINT": "https://static.groupher.com",
"ICON": "https://static.groupher.com/icons/static",
"ICON_BASE": "https://static.groupher.com/icons",
"ICON_CMD": "https://static.groupher.com/icons/cmd",
"DEFAULT_ICON": "https://static.groupher.com/icons/cmd/cheatsheet.svg",
"DEFAULT_USER_AVATAR": "https://static.groupher.com/icons/cmd/alien_user3.svg",
"GRAPHQL_ENDPOINT": "http://127.0.0.1:4001/graphiql",
"// GRAPHQL_ENDPOINT": "http://localhost:4001/graphiql",
"SITE_URL": "https://groupher.com",
"SITE_NAME": "Groupher",
"SITE_SLOGAN": "让你的产品聆听用户的声音。互动讨论,GTD 看板,更新日志,帮助文档多合一,收集整理用户用户反馈,助你打造更好的产品。",
Expand All @@ -50,7 +51,6 @@
"MENTION_USER_ADDR": "https://groupher.com/users/",
"//--- contact configs ---//": "",
"EMAIL_SUPPORT": "[email protected]",
"// GRAPHQL_ENDPOINT": "http://localhost:4001/graphiql",
"BEIAN_ADDR": "http://beian.miit.gov.cn",
"BEIAN_TEXT": "蜀ICP备17043722号-4",
"/// GRAPHQL_ENDPOINT": "https://api.groupher.com/graphiql"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { FC, memo, Fragment, useState } from 'react'
import type { TCommunity } from '@/spec'
import { ICON } from '@/config'
import { HCN } from '@/constant/name'
import { assetSrc } from '@/helper'

import { changeToCommunity } from '@/signal'
import { buildLog } from '@/logger'
Expand Down Expand Up @@ -55,11 +56,11 @@ const SubscribedList: FC<TProps> = ({ community, communities }) => {
首页
</Item>
{communities.slice(0, 15).map((community) => (
<Fragment key={community.id}>
<Fragment key={community.slug}>
<Item>
{community.slug === activeCommunity.slug && <ActiveDot />}

<Logo src={community.logo} />
<Logo src={assetSrc(community.logo)} />
<Title
$active={community.slug === activeCommunity.slug}
onClick={() => changeToCommunity(community.slug)}
Expand Down
4 changes: 2 additions & 2 deletions src/containers/content/UserContent/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const user = gql`
`

const editableCommunities = gql`
query ($login: String, $filter: PagedFilter!) {
query ($login: String, $filter: PagiFilter!) {
editableCommunities(login: $login, filter: $filter) {
entries {
${F.community}
Expand All @@ -37,7 +37,7 @@ const editableCommunities = gql`
`

const pagedPublishedWorks = `
query($login: String!, $filter: PagedFilter!) {
query($login: String!, $filter: PagiFilter!) {
pagedPublishedWorks(login: $login, filter: $filter) {
entries {
id
Expand Down
3 changes: 2 additions & 1 deletion src/containers/digest/ArticleDigest/DesktopView/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { FC } from 'react'
import { observer } from 'mobx-react'

import type { TMetric } from '@/spec'
import { assetSrc } from '@/helper'

import { ANCHOR } from '@/constant/dom'
import { ROUTE } from '@/constant/route'
Expand Down Expand Up @@ -33,7 +34,7 @@ const Header: FC<TProps> = ({ metric }) => {
<Wrapper id={ANCHOR.GLOBAL_HEADER_ID}>
<InnerWrapper>
<Community>
<CommunityLogo src={community.logo} />
<CommunityLogo src={assetSrc(community.logo)} />
<CommunityTitle>{community.title}</CommunityTitle>
</Community>

Expand Down
5 changes: 3 additions & 2 deletions src/containers/digest/ArticleDigest/MobileView/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { FC } from 'react'
import { observer } from 'mobx-react'

import type { TCommunity, TMetric } from '@/spec'
import type { TMetric } from '@/spec'

import useViewingCommunity from '@/hooks/useViewingCommunity'
import { assetSrc } from '@/helper'

import { ANCHOR } from '@/constant/dom'
import { ROUTE } from '@/constant/route'
Expand Down Expand Up @@ -34,7 +35,7 @@ const Header: FC<TProps> = ({ metric }) => {
<Wrapper id={ANCHOR.GLOBAL_HEADER_ID}>
<InnerWrapper>
<Community>
<CommunityLogo src={community.logo} />
<CommunityLogo src={assetSrc(community.logo)} />
<CommunityTitle>{community.title}</CommunityTitle>
</Community>

Expand Down
2 changes: 1 addition & 1 deletion src/containers/editor/CommunityEditor/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const unsubscribeCommunity = gql`
}
`
const pagedCategories = gql`
query ($filter: PagedFilter!) {
query ($filter: PagiFilter!) {
pagedCategories(filter: $filter) {
entries {
id
Expand Down
13 changes: 9 additions & 4 deletions src/containers/thread/DashboardThread/BasicInfo/BaseInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,27 @@ type TProps = {
}

const BasicInfo: FC<TProps> = ({ testid = 'basic-info', settings, touched }) => {
const { saving, desc, title, introduction } = settings
const { saving, desc, title, introduction, logo } = settings

return (
<Wrapper>
<Title>favicon</Title>
<FaviconWrapper>
<OSSUploader>
<OSSUploader previewHeight={30} previewWidth={30}>
<Favicon />
</OSSUploader>
</FaviconWrapper>
<Desc>上传 favicon, 仅支持 ico 格式,最大 10 KB。可选。</Desc>
<Br bottom={30} />

<Title>LOGO</Title>
<LogoWrapper>
<OSSUploader>
<OSSUploader
previewUrl={logo}
previewHeight={70}
previewWidth={70}
onDelete={() => edit('', 'logo')}
onUploadDone={(v) => edit(v, 'logo')}
>
<Logo />
</OSSUploader>
</LogoWrapper>
Expand Down
5 changes: 4 additions & 1 deletion src/containers/thread/DashboardThread/logic/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,10 @@ const _handleError = () => {
const DataSolver = [
{
match: asyncRes('updateDashboardBaseInfo'),
action: () => _handleDone(),
action: ({ updateDashboardBaseInfo }) => {
store.updateViewingCommunity({ ...updateDashboardBaseInfo })
_handleDone()
},
},
{
match: asyncRes('updateDashboardMediaReports'),
Expand Down
10 changes: 6 additions & 4 deletions src/containers/thread/DashboardThread/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { P, F } from '@/schemas'
const { pagedPosts, pagedChangelogs } = P

const communityBaseInfo = gql`
query community($slug: String, $incViews: Boolean) {
query community($slug: String!, $incViews: Boolean) {
community(slug: $slug, incViews: $incViews) {
dashboard {
baseInfo {
Expand All @@ -31,7 +31,7 @@ const communityBaseInfo = gql`
`

const communitySocialLinks = gql`
query community($slug: String, $incViews: Boolean) {
query community($slug: String!, $incViews: Boolean) {
community(slug: $slug, incViews: $incViews) {
dashboard {
baseInfo {
Expand Down Expand Up @@ -71,6 +71,8 @@ const updateDashboardBaseInfo = gql`
techstack: $techstack
) {
title
logo
favicon
}
}
`
Expand Down Expand Up @@ -271,7 +273,7 @@ const updateDashboardFaqs = gql`
`

const updateModerators = gql`
query community($slug: String, $incViews: Boolean) {
query community($slug: String!, $incViews: Boolean) {
community(slug: $slug, incViews: $incViews) {
moderators {
role
Expand All @@ -288,7 +290,7 @@ const updateModerators = gql`
`

const communityOverview = gql`
query community($slug: String, $incViews: Boolean) {
query community($slug: String!, $incViews: Boolean) {
community(slug: $slug, incViews: $incViews) {
views
subscribersCount
Expand Down
5 changes: 5 additions & 0 deletions src/containers/thread/DashboardThread/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,11 @@ const DashboardThread = T.model('DashboardThread', {
// slf.mark({ demoAlertEnable: true })
},

updateViewingCommunity(args: TCommunity): void {
const root = getParent(self) as TRootStore
root.viewing.updateViewingCommunity(args)
},

_findTagIdx(): number {
const slf = self as TStore

Expand Down
2 changes: 1 addition & 1 deletion src/containers/tool/ArticleSticker/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { F } from '@/schemas'

// const pagedCommentsParticipants = gql`
// query($id: ID!, $thread: Thread, $filter: PagedFilter!) {
// query($id: ID!, $thread: Thread, $filter: PagiFilter!) {
// pagedCommentsParticipants(id: $id, thread: $thread, filter: $filter) {
// entries {
// ${F.author}
Expand Down
2 changes: 1 addition & 1 deletion src/containers/tool/Cashier/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const createBill = gql`
}
`
const pagedBillRecords = gql`
query ($filter: PagedFilter!) {
query ($filter: PagiFilter!) {
pagedBillRecords(filter: $filter) {
entries {
id
Expand Down
10 changes: 4 additions & 6 deletions src/containers/tool/ErrorBox/GraphqlDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,10 @@ const CustomDetails = ({ errors }) => (
<>
{!nilOrEmpty(errors) &&
errors.map((item) => (
<div key={uid.gen()}>
<TitleWrapper>
<Title>错误码: {item.code}</Title>
<Desc>{item.message}</Desc>
</TitleWrapper>
</div>
<TitleWrapper key={uid.gen()}>
<Title>错误: {item.code}</Title>
<Desc>{item.message}</Desc>
</TitleWrapper>
))}
</>
)
Expand Down
24 changes: 18 additions & 6 deletions src/containers/tool/ErrorBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ import { SpaceGrow } from '@/widgets/Common'

import Details from './Details'

import { Wrapper, WarningIcon, ResetButton, LearnMoreButton, MoreLink } from './styles'
import {
Wrapper,
IconWrapper,
WarningIcon,
ResetButton,
LearnMoreButton,
MoreLink,
ButtonGroup,
} from './styles'
import { useInit, onClose } from './logic'

/* eslint-disable-next-line */
Expand Down Expand Up @@ -47,7 +55,9 @@ const ErrorBoxContainer: FC<TProps> = ({ errorBox: store }) => {

return (
<Wrapper>
<WarningIcon />
<IconWrapper>
<WarningIcon />
</IconWrapper>
<Details
type={type}
timeoutError={timeoutError}
Expand All @@ -57,10 +67,12 @@ const ErrorBoxContainer: FC<TProps> = ({ errorBox: store }) => {
customError={customErrorData}
/>
<SpaceGrow />
<LearnMoreButton>
<MoreLink href="/">报告问题</MoreLink>
</LearnMoreButton>
<ResetButton onClick={() => onClose()}>关闭</ResetButton>
<ButtonGroup>
<LearnMoreButton>
<MoreLink href="/feedback">报告问题</MoreLink>
</LearnMoreButton>
<ResetButton onClick={() => onClose()}>关闭</ResetButton>
</ButtonGroup>
</Wrapper>
)
}
Expand Down
6 changes: 4 additions & 2 deletions src/containers/tool/ErrorBox/styles/details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ export const Wrapper = styled.div`
font-size: 13px;
`
export const TitleWrapper = styled.div`
${css.row('align-center')};
${css.row('align-start')};
`
export const Title = styled.div`
color: ${theme('baseColor.red')};
opacity: 0.8;
font-weight: bold;
`
export const Desc = styled.div`
color: ${theme('baseColor.red')};
margin-left: 10px;
width: 82%;
max-width: 82%;
`
2 changes: 0 additions & 2 deletions src/containers/tool/ErrorBox/styles/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import css, { theme, animate } from '@/css'

export const Wrapper = styled.div`
${css.row()};
padding: 15px 22px;
`
export const ErrorIcon = styled(Img)`
fill: ${theme('baseColor.red')};
Expand All @@ -23,5 +22,4 @@ export const Title = styled.div`
// color: ${theme('article.digest')};
export const Desc = styled.div`
color: ${theme('baseColor.red')};
opacity: 0.6;
`
20 changes: 15 additions & 5 deletions src/containers/tool/ErrorBox/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,30 @@ export const Wrapper = styled.div`
position: fixed;
left: calc(50% - 245px);
bottom: 30px;
${css.row('align-center')};
${css.row('align-start')};
border: 1px solid;
border-color: ${theme('baseColor.red')};
height: 40px;
height: auto;
width: 520px;
border-radius: 12px;
box-shadow: rgba(17, 17, 26, 0.1) 0px 1px 0px, rgba(17, 17, 26, 0.1) 0px 8px 24px,
rgba(17, 17, 26, 0.1) 0px 16px 48px;
background-color: #ffefee;
z-index: 10;
padding: 0 15px;
padding: 8px 15px;
animation: ${animate.jump} 0.3s linear;
`
export const IconWrapper = styled.div`
${css.row('align-both')};
`
export const WarningIcon = styled(WarningSVG)`
${css.size(12)};
fill: tomato;
fill: ${theme('baseColor.red')};
margin-right: 8px;
margin-bottom: 1px;
margin-top: 4px;
`
export const ResetButton = styled.div`
${css.row('align-both')};
Expand All @@ -46,13 +50,19 @@ export const ResetButton = styled.div`
cursor: pointer;
transition: all 0.2s;
`
export const ButtonGroup = styled.div`
${css.row('align-center', 'justify-end')};
width: 120px;
min-width: 120px;
`
export const LearnMoreButton = styled.div`
${css.row('align-both')};
width: 60px;
height: 18px;
border-radius: 6px;
font-size: 11px;
padding: 2px 6px;
background: tomato;
font-weight: 500;
margin-right: 8px;
`
export const MoreLink = styled(Link)`
Expand Down
2 changes: 1 addition & 1 deletion src/containers/unit/Comments/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const pagedPublishedComments = gql`
query pagedPublishedComments(
$login: String!
$thread: Thread,
$filter: PagedFilter!
$filter: PagiFilter!
) {
pagedPublishedComments(login: $login, thread: $thread, filter: $filter) {
entries {
Expand Down
Loading

0 comments on commit aeb0a91

Please sign in to comment.