Skip to content

Commit

Permalink
fix: Allow switching organisations if current one is blocked (#4606)
Browse files Browse the repository at this point in the history
  • Loading branch information
rolodato authored Sep 10, 2024
1 parent 64c53da commit 6ef774b
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 44 deletions.
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:support@flagsmith.com'
rel='noreferrer'
>
support@flagsmith.com
</a>
.
</>
}
<span className='h4'>
Your organisation has been disabled. Please contact Flagsmith
support at
{
<>
{' '}
<a
target='_blank'
href='mailto:support@flagsmith.com'
rel='noreferrer'
>
support@flagsmith.com
</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:support@flagsmith.com'
rel='noreferrer'
>
support@flagsmith.com
</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:support@flagsmith.com'
rel='noreferrer'
>
support@flagsmith.com
</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
1 change: 1 addition & 0 deletions frontend/web/components/pages/OrganisationSettingsPage.js
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

0 comments on commit 6ef774b

Please sign in to comment.