Skip to content
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

fix: Allow switching organisations if current one is blocked #4606

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion frontend/web/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@ const App = class extends Component {
}
if (
AccountStore.getOrganisation() &&
AccountStore.getOrganisation().block_access_to_admin
AccountStore.getOrganisation().block_access_to_admin &&
pathname !== '/organisations'
) {
return <Blocked />
}
Expand Down
49 changes: 20 additions & 29 deletions frontend/web/components/Blocked.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import ConfigProvider from 'common/providers/ConfigProvider'
import Payment from './modals/Payment'
import BlockedOrgInfo from './BlockedOrgInfo'

const Blocked = class extends React.Component {
static contextTypes = {
Expand All @@ -19,41 +20,31 @@ const Blocked = class extends React.Component {
{!Utils.isSaas() ? (
<div className='col-md-6 mt-5' id='sign-up'>
<h1>Please get in touch</h1>
Your organisation has been disabled. Please get in touch so we can
discuss enabling your account.
{
<>
{' '}
<a
target='_blank'
href='mailto:[email protected]'
rel='noreferrer'
>
[email protected]
</a>
.
</>
}
<span className='h4'>
Your organisation has been disabled. Please contact Flagsmith
support at
{
<>
{' '}
<a
target='_blank'
href='mailto:[email protected]'
rel='noreferrer'
>
[email protected]
</a>
.
</>
}
</span>
<BlockedOrgInfo />
</div>
) : (
<div className='col-md-8 mt-5' id='sign-up'>
{
<>
<div>
<Button
theme='text'
onClick={() => {
AppActions.logout()
window.location.href = `/login`
}}
>
Return to Sign in/Sign up page
</Button>
</div>
<Payment
isDisableAccountText={
'Your organisation has been disabled. Please upgrade your plan or get in touch so we can discuss enabling your account.'
}
isDisableAccountText={`Your organisation has been disabled. Please upgrade your plan or contact us:`}
/>
</>
}
Expand Down
25 changes: 25 additions & 0 deletions frontend/web/components/BlockedOrgInfo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react'
import AccountStore from 'common/stores/account-store'
import AppActions from 'common/dispatcher/app-actions'

export default function BlockedOrgInfo() {
return (
<div className='text-nowrap'>
<div>Organisation name: {AccountStore.getOrganisation().name}</div>
<div>Organisation ID: {AccountStore.getOrganisation().id}</div>
<div>
<a href='/organisations'>Switch to a different organisation</a>
</div>
<div>
<a
href='/login'
onClick={() => {
AppActions.logout()
}}
>
Log out
</a>
</div>
</div>
)
}
33 changes: 19 additions & 14 deletions frontend/web/components/modals/Payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Utils from 'common/utils/utils'
import AccountProvider from 'common/providers/AccountProvider'
import classNames from 'classnames'
import Switch from 'components/Switch'
import BlockedOrgInfo from 'components/BlockedOrgInfo'

const PaymentButton = (props) => {
const activeSubscription = AccountStore.getOrganisationPlan(
Expand Down Expand Up @@ -104,21 +105,25 @@ const Payment = class extends Component {
''
return (
<div className='col-md-12'>
<Row space className='mb-2'>
<h5>Manage Payment Plan</h5>
<Row space className='mb-4'>
{this.props.isDisableAccountText && (
<Row>
<h7>
{this.props.isDisableAccountText}{' '}
<a
target='_blank'
href='mailto:[email protected]'
rel='noreferrer'
>
[email protected]
</a>
</h7>
</Row>
<div className='d-lg-flex flex-lg-row align-items-end justify-content-between w-100 gap-4'>
<div>
<h4>
{this.props.isDisableAccountText}{' '}
<a
target='_blank'
href='mailto:[email protected]'
rel='noreferrer'
>
[email protected]
</a>
</h4>
</div>
<div>
<BlockedOrgInfo />
</div>
</div>
)}
</Row>
<div className='d-flex mb-4 font-weight-medium justify-content-center align-items-center gap-2'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ const OrganisationSettingsPage = class extends Component {
)}
</div>
</Row>
<h5>Manage Payment Plan</h5>
<Payment viewOnly={false} />
</div>
</TabItem>
Expand Down
Loading