Skip to content

Commit

Permalink
task: Make Inactive users an enterprise feature (#6510) (#6519)
Browse files Browse the repository at this point in the history
Ivar pointed out to me that this was intended as an enterprise only
feature. So this PR makes it an enterprise only feature. Conditionally
render the link in the normal user table, and use premium feature
component if you happen to hit the route and not be running on the
enterprise plan.
  • Loading branch information
Christopher Kolstad authored Mar 12, 2024
1 parent bf0589c commit 4640da4
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 24 deletions.
62 changes: 41 additions & 21 deletions frontend/src/component/admin/users/UsersAdmin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,47 @@ import EditUser from './EditUser/EditUser';
import NotFound from 'component/common/NotFound/NotFound';
import { InactiveUsersList } from './InactiveUsersList/InactiveUsersList';
import { AccessMatrix } from './AccessMatrix/AccessMatrix';
import { PremiumFeature } from '../../common/PremiumFeature/PremiumFeature';
import { ConditionallyRender } from '../../common/ConditionallyRender/ConditionallyRender';
import useUiConfig from '../../../hooks/api/getters/useUiConfig/useUiConfig';

export const UsersAdmin = () => (
<div>
<PermissionGuard permissions={ADMIN}>
<Routes>
<Route
index
element={
<>
<InviteLinkBar />
<UsersList />
</>
}
/>
<Route path=':id/edit' element={<EditUser />} />
<Route path=':id/access' element={<AccessMatrix />} />
<Route path='inactive' element={<InactiveUsersList />} />
<Route path='*' element={<NotFound />} />
</Routes>
</PermissionGuard>
</div>
);
export const UsersAdmin = () => {
const { isEnterprise } = useUiConfig();
return (
<div>
<PermissionGuard permissions={ADMIN}>
<Routes>
<Route
index
element={
<>
<InviteLinkBar />
<UsersList />
</>
}
/>
<Route path=':id/edit' element={<EditUser />} />
<Route path=':id/access' element={<AccessMatrix />} />
<Route
path='inactive'
element={
<ConditionallyRender
condition={isEnterprise()}
show={<InactiveUsersList />}
elseShow={
<PremiumFeature
feature='inactive-users'
page
/>
}
/>
}
/>
<Route path='*' element={<NotFound />} />
</Routes>
</PermissionGuard>
</div>
);
};

export default UsersAdmin;
15 changes: 12 additions & 3 deletions frontend/src/component/admin/users/UsersList/UsersList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ import { useSearch } from 'hooks/useSearch';
import { Download } from '@mui/icons-material';
import { StyledUsersLinkDiv } from '../Users.styles';
import { useUiFlag } from 'hooks/useUiFlag';
import useUiConfig from '../../../../hooks/api/getters/useUiConfig/useUiConfig';

const UsersList = () => {
const navigate = useNavigate();
const { isEnterprise } = useUiConfig();
const { users, roles, refetch, loading } = useUsers();
const { setToastData, setToastApiError } = useToast();
const { removeUser, userLoading, userApiErrors } = useAdminUsersApi();
Expand Down Expand Up @@ -315,9 +317,16 @@ const UsersList = () => {
}
>
<UserLimitWarning />
<StyledUsersLinkDiv>
<Link to='/admin/users/inactive'>View inactive users</Link>
</StyledUsersLinkDiv>
<ConditionallyRender
condition={isEnterprise()}
show={
<StyledUsersLinkDiv>
<Link to='/admin/users/inactive'>
View inactive users
</Link>
</StyledUsersLinkDiv>
}
/>
<SearchHighlightProvider value={getSearchText(searchValue)}>
<VirtualizedTable
rows={rows}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ const PremiumFeatures = {
url: '', // FIXME: url
label: 'Dashboard',
},
'inactive-users': {
plan: FeaturePlan.ENTERPRISE,
url: '',
label: 'Automatic clean-up of inactive users',
},
};

type PremiumFeatureType = keyof typeof PremiumFeatures;
Expand Down

0 comments on commit 4640da4

Please sign in to comment.