New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add new Admin Panel #6881
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
99cff1f
feat: add AdminPanel page
kewitz 27d3134
refact: accept space, layout and flexbox props on Flex component
kewitz f00d006
refact: adjust dashboard content layout
kewitz 6ca7f36
refact: adjust edit collective content header
kewitz f1db459
chore: update lang
kewitz 7977035
fix: selected menu link, self-hosted collective menu, error toast bug
kewitz aee3ec2
feat: add adminPanel feature flag
kewitz 0ad42d0
fix: missing user sections
kewitz 0eb9a03
fix: add contentOnly prop to missing sections
kewitz 10f672c
fix: selected MenuLink size
kewitz 8a97e84
fix: user settings header
kewitz 1fdcf6e
fix: cant edit flash state
kewitz f578dfd
fix: default section state
kewitz 106f2dd
chore: remove unused code and update lang
kewitz File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { values } from 'lodash'; | ||
import { useIntl } from 'react-intl'; | ||
import styled from 'styled-components'; | ||
|
||
import Container from '../Container'; | ||
import { Box } from '../Grid'; | ||
import HostDashboardExpenses from '../host-dashboard/HostDashboardExpenses'; | ||
import HostDashboardHostedCollectives from '../host-dashboard/HostDashboardHostedCollectives'; | ||
import PendingApplications from '../host-dashboard/PendingApplications'; | ||
import Loading from '../Loading'; | ||
import NotFound from '../NotFound'; | ||
|
||
import AccountSettings from './sections/AccountSettings'; | ||
import FinancialContributions from './sections/FinancialContributions'; | ||
import { HOST_DASHBOARD_SECTIONS, LEGACY_COLLECTIVE_SETTINGS_SECTIONS, SECTION_LABELS } from './constants'; | ||
|
||
const HOST_ADMIN_SECTIONS = { | ||
[HOST_DASHBOARD_SECTIONS.HOSTED_COLLECTIVES]: HostDashboardHostedCollectives, | ||
[HOST_DASHBOARD_SECTIONS.FINANCIAL_CONTRIBUTIONS]: FinancialContributions, | ||
[HOST_DASHBOARD_SECTIONS.EXPENSES]: HostDashboardExpenses, | ||
[HOST_DASHBOARD_SECTIONS.PENDING_APPLICATIONS]: PendingApplications, | ||
}; | ||
|
||
const Title = styled(Box)` | ||
font-size: 24px; | ||
font-weight: 700; | ||
line-height: 32px; | ||
`; | ||
|
||
const AdminPanelSection = ({ collective, isLoading, section }) => { | ||
const { formatMessage } = useIntl(); | ||
|
||
if (isLoading) { | ||
return ( | ||
<Container display="flex" justifyContent="center" alignItems="center"> | ||
<Loading /> | ||
</Container> | ||
); | ||
} | ||
|
||
// Host Dashboard | ||
const AdminSectionComponent = HOST_ADMIN_SECTIONS[section]; | ||
if (AdminSectionComponent) { | ||
return ( | ||
<Container width="100%"> | ||
<AdminSectionComponent hostSlug={collective.slug} /> | ||
</Container> | ||
); | ||
} | ||
|
||
// Form | ||
if (values(LEGACY_COLLECTIVE_SETTINGS_SECTIONS).includes(section)) { | ||
return ( | ||
<Container width="100%"> | ||
{SECTION_LABELS[section] && ( | ||
<Box mb={3}> | ||
<Title>{formatMessage(SECTION_LABELS[section])}</Title> | ||
</Box> | ||
)} | ||
<AccountSettings account={collective} /> | ||
</Container> | ||
); | ||
} | ||
|
||
return ( | ||
<Container display="flex" justifyContent="center" alignItems="center"> | ||
<NotFound /> | ||
</Container> | ||
); | ||
}; | ||
|
||
AdminPanelSection.propTypes = { | ||
isLoading: PropTypes.bool, | ||
section: PropTypes.string, | ||
/** The account. Can be null if isLoading is true */ | ||
collective: PropTypes.shape({ | ||
slug: PropTypes.string.isRequired, | ||
name: PropTypes.string, | ||
isHost: PropTypes.bool, | ||
}), | ||
}; | ||
|
||
export default AdminPanelSection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { FormattedMessage } from 'react-intl'; | ||
|
||
import hasFeature, { FEATURES } from '../../lib/allowed-features'; | ||
import { CollectiveType, isHost, isOneOfTypes, isType } from '../../lib/collective-sections'; | ||
|
||
import { HOST_SECTIONS } from '../host-dashboard/constants'; | ||
|
||
import { | ||
ABOUT_ORG_SECTIONS, | ||
ALL_SECTIONS, | ||
COLLECTIVE_SECTIONS, | ||
FISCAL_HOST_SECTIONS, | ||
ORG_BUDGET_SECTIONS, | ||
} from './constants'; | ||
import { MenuGroup, MenuLink, MenuSectionHeader, useSubmenu } from './MenuComponents'; | ||
|
||
const { USER, ORGANIZATION, COLLECTIVE, FUND, EVENT, PROJECT } = CollectiveType; | ||
|
||
const Menu = ({ collective }) => { | ||
const { menuContent, SubMenu } = useSubmenu(); | ||
|
||
if (menuContent) { | ||
return menuContent; | ||
} else { | ||
return ( | ||
<React.Fragment> | ||
<MenuGroup if={isHost(collective)} mb={24}> | ||
<MenuSectionHeader> | ||
<FormattedMessage id="HostDashboard" defaultMessage="Host Dashboard" /> | ||
</MenuSectionHeader> | ||
<MenuLink collective={collective} section={HOST_SECTIONS.EXPENSES} /> | ||
<MenuLink collective={collective} section={HOST_SECTIONS.FINANCIAL_CONTRIBUTIONS} /> | ||
<MenuLink collective={collective} section={HOST_SECTIONS.PENDING_APPLICATIONS} /> | ||
<MenuLink collective={collective} section={HOST_SECTIONS.HOSTED_COLLECTIVES} /> | ||
</MenuGroup> | ||
<MenuGroup if={isHost(collective) || isType(collective, ORGANIZATION)}> | ||
<MenuSectionHeader> | ||
<FormattedMessage id="Settings" defaultMessage="Settings" /> | ||
</MenuSectionHeader> | ||
<SubMenu | ||
label={<FormattedMessage id="AdminPanel.OrganizationSettings" defaultMessage="Organization Settings" />} | ||
if={isType(collective, ORGANIZATION) || isHost(collective)} | ||
> | ||
<MenuLink collective={collective} section={ABOUT_ORG_SECTIONS.INFO} /> | ||
<MenuLink collective={collective} section={ABOUT_ORG_SECTIONS.COLLECTIVE_PAGE} /> | ||
<MenuLink collective={collective} section={ABOUT_ORG_SECTIONS.CONNECTED_ACCOUNTS} /> | ||
<MenuLink collective={collective} section={ABOUT_ORG_SECTIONS.TEAM} /> | ||
<MenuLink collective={collective} section={ORG_BUDGET_SECTIONS.PAYMENT_METHODS} /> | ||
<MenuLink collective={collective} section={ORG_BUDGET_SECTIONS.PAYMENT_RECEIPTS} /> | ||
<MenuLink collective={collective} section={ORG_BUDGET_SECTIONS.TIERS} /> | ||
<MenuLink collective={collective} section={ORG_BUDGET_SECTIONS.GIFT_CARDS} /> | ||
<MenuLink | ||
collective={collective} | ||
section={ORG_BUDGET_SECTIONS.PENDING_ORDERS} | ||
if={isType(collective, COLLECTIVE)} | ||
/> | ||
<MenuLink collective={collective} section={ALL_SECTIONS.WEBHOOKS} /> | ||
<MenuLink collective={collective} section={ALL_SECTIONS.ADVANCED} /> | ||
</SubMenu> | ||
<SubMenu | ||
label={<FormattedMessage id="AdminPanel.FiscalHostSettings" defaultMessage="Fiscal Host Settings" />} | ||
if={isHost(collective) || (isType(collective, USER) && isHost(collective))} | ||
> | ||
<MenuLink collective={collective} section={FISCAL_HOST_SECTIONS.FISCAL_HOSTING} /> | ||
<MenuGroup if={isHost(collective)}> | ||
<MenuLink collective={collective} section={FISCAL_HOST_SECTIONS.INVOICES_RECEIPTS} /> | ||
<MenuLink collective={collective} section={FISCAL_HOST_SECTIONS.RECEIVING_MONEY} /> | ||
<MenuLink collective={collective} section={FISCAL_HOST_SECTIONS.SENDING_MONEY} /> | ||
<MenuLink | ||
collective={collective} | ||
section={FISCAL_HOST_SECTIONS.HOST_VIRTUAL_CARDS} | ||
if={hasFeature(collective, FEATURES.PRIVACY_VCC)} | ||
/> | ||
<MenuLink collective={collective} section={FISCAL_HOST_SECTIONS.HOST_TWO_FACTOR_AUTH} /> | ||
<MenuLink | ||
collective={collective} | ||
section={FISCAL_HOST_SECTIONS.POLICIES} | ||
if={isOneOfTypes(collective, [USER, ORGANIZATION])} | ||
/> | ||
<MenuLink | ||
collective={collective} | ||
section={FISCAL_HOST_SECTIONS.HOST_PLAN} | ||
if={isOneOfTypes(collective, [USER, ORGANIZATION])} | ||
/> | ||
<MenuLink | ||
collective={collective} | ||
section={FISCAL_HOST_SECTIONS.HOST_METRICS} | ||
if={isOneOfTypes(collective, [USER, ORGANIZATION])} | ||
/> | ||
</MenuGroup> | ||
</SubMenu> | ||
</MenuGroup> | ||
|
||
<MenuGroup if={!isHost(collective) && !isType(collective, ORGANIZATION)}> | ||
<MenuSectionHeader> | ||
{isType(collective, USER) ? ( | ||
<FormattedMessage id="AdminPanel.UserSettings" defaultMessage="User Settings" /> | ||
) : ( | ||
<FormattedMessage id="AdminPanel.CollectiveSettings" defaultMessage="Collective Settings" /> | ||
)} | ||
</MenuSectionHeader> | ||
<MenuLink collective={collective} section={COLLECTIVE_SECTIONS.INFO} /> | ||
<MenuLink collective={collective} section={COLLECTIVE_SECTIONS.COLLECTIVE_PAGE} /> | ||
<MenuLink | ||
collective={collective} | ||
section={COLLECTIVE_SECTIONS.COLLECTIVE_GOALS} | ||
if={isType(collective, COLLECTIVE)} | ||
/> | ||
<MenuLink | ||
collective={collective} | ||
section={COLLECTIVE_SECTIONS.CONNECTED_ACCOUNTS} | ||
if={isType(collective, COLLECTIVE)} | ||
/> | ||
<MenuLink | ||
collective={collective} | ||
section={COLLECTIVE_SECTIONS.POLICIES} | ||
if={isOneOfTypes(collective, [COLLECTIVE, FUND])} | ||
/> | ||
<MenuLink collective={collective} section={COLLECTIVE_SECTIONS.EXPORT} if={isType(collective, COLLECTIVE)} /> | ||
<MenuLink | ||
collective={collective} | ||
section={COLLECTIVE_SECTIONS.HOST} | ||
if={isOneOfTypes(collective, [COLLECTIVE, FUND])} | ||
/> | ||
<MenuLink | ||
collective={collective} | ||
section={COLLECTIVE_SECTIONS.TEAM} | ||
if={isOneOfTypes(collective, [COLLECTIVE, FUND, ORGANIZATION, EVENT, PROJECT])} | ||
/> | ||
<MenuLink | ||
collective={collective} | ||
section={COLLECTIVE_SECTIONS.PAYMENT_METHODS} | ||
if={isType(collective, USER)} | ||
/> | ||
<MenuLink | ||
collective={collective} | ||
section={COLLECTIVE_SECTIONS.PAYMENT_RECEIPTS} | ||
if={isType(collective, USER)} | ||
/> | ||
|
||
<MenuLink | ||
collective={collective} | ||
section={COLLECTIVE_SECTIONS.VIRTUAL_CARDS} | ||
if={ | ||
isOneOfTypes(collective, [COLLECTIVE, FUND]) && | ||
hasFeature(collective.host, FEATURES.PRIVACY_VCC) && | ||
collective.virtualCards?.totalCount > 0 | ||
} | ||
/> | ||
<MenuLink collective={collective} section={COLLECTIVE_SECTIONS.TICKETS} if={isType(collective, EVENT)} /> | ||
<MenuLink | ||
collective={collective} | ||
section={COLLECTIVE_SECTIONS.TIERS} | ||
if={isOneOfTypes(collective, [COLLECTIVE, FUND, EVENT, PROJECT])} | ||
/> | ||
<MenuLink | ||
collective={collective} | ||
section={COLLECTIVE_SECTIONS.WEBHOOKS} | ||
if={isOneOfTypes(collective, [COLLECTIVE, USER, EVENT])} | ||
/> | ||
<MenuLink | ||
collective={collective} | ||
section={COLLECTIVE_SECTIONS.TWO_FACTOR_AUTH} | ||
if={isType(collective, USER)} | ||
/> | ||
<MenuLink collective={collective} section={COLLECTIVE_SECTIONS.ADVANCED} /> | ||
</MenuGroup> | ||
</React.Fragment> | ||
); | ||
} | ||
}; | ||
|
||
Menu.propTypes = { | ||
collective: PropTypes.shape({ | ||
slug: PropTypes.string, | ||
name: PropTypes.string, | ||
type: PropTypes.string, | ||
isHost: PropTypes.bool, | ||
}), | ||
collectiveSlug: PropTypes.string, | ||
}; | ||
|
||
export default Menu; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally liked that we matched the original behavior of the
rebass/grid
library, and that we're keeping it simple. Why not use theContainer
, which supports all these?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we were matching the rebass behavior. I'm pretty much sure you can pass
alignItems="center" overflow="hidden"
props in rebass.I'll refactor this to use
Container
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It matches the rebass behavior from when we removed the dependency. This file was initially just a copy-paste of https://github.com/rebassjs/grid/blob/master/src/index.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it weird that a div Flex component accepts no CSS flex or div properties?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kewitz It does accept CSS flex properties already, since it inherits
Box
which implements styled-system'sflexbox
. Actually, the properties that you added there are already supported by the component.