Skip to content
Snippets Groups Projects
Commit af9b73cc authored by Thiago Presa's avatar Thiago Presa Committed by Fatih Acet
Browse files

Fix License App user count

parent dbfa39ca
No related branches found
No related tags found
No related merge requests found
Showing
with 57 additions and 14 deletions
Loading
Loading
@@ -27,7 +27,7 @@ export default {
},
},
computed: {
...mapState(['currentActiveUserCount', 'deleteQueue', 'downloadLicensePath']),
...mapState(['activeUserCount', 'guestUserCount', 'deleteQueue', 'downloadLicensePath']),
isRemoving() {
return this.deleteQueue.includes(this.license.id);
},
Loading
Loading
@@ -76,7 +76,8 @@ export default {
<license-card-body
:license="license"
:is-removing="isRemoving"
:current-active-user-count="currentActiveUserCount"
:active-user-count="activeUserCount"
:guest-user-count="guestUserCount"
/>
</div>
</template>
Loading
Loading
@@ -29,7 +29,11 @@ export default {
required: false,
default: false,
},
currentActiveUserCount: {
activeUserCount: {
type: Number,
required: true,
},
guestUserCount: {
type: Number,
required: true,
},
Loading
Loading
@@ -51,6 +55,11 @@ export default {
seatsInUseComponent() {
return this.license.plan === 'ultimate' ? 'info-cell' : 'cell';
},
seatsInUseForThisLicense() {
return this.license.plan === 'ultimate'
? this.activeUserCount - this.guestUserCount
: this.activeUserCount;
},
},
methods: {
licenseeValue(key) {
Loading
Loading
@@ -76,7 +85,7 @@ export default {
<component
:is="seatsInUseComponent"
:title="__('Seats currently in use')"
:value="currentActiveUserCount"
:value="seatsInUseForThisLicense"
:popover-content="info.currentActiveUserCount"
/>
<info-cell
Loading
Loading
Loading
Loading
@@ -7,7 +7,8 @@ export default function mountInstanceLicenseApp(mountElement) {
if (!mountElement) return undefined;
 
const {
currentActiveUserCount,
activeUserCount,
guestUserCount,
licensesPath,
deleteLicensePath,
newLicensePath,
Loading
Loading
@@ -23,7 +24,8 @@ export default function mountInstanceLicenseApp(mountElement) {
deleteLicensePath,
newLicensePath,
downloadLicensePath,
currentActiveUserCount: parseInt(currentActiveUserCount, 10),
activeUserCount: parseInt(activeUserCount, 10),
guestUserCount: parseInt(guestUserCount, 10),
});
 
this.fetchLicenses();
Loading
Loading
Loading
Loading
@@ -6,10 +6,14 @@ module LicenseHelper
 
delegate :new_admin_license_path, to: 'Gitlab::Routing.url_helpers'
 
def current_active_user_count
def active_user_count
User.active.count
end
 
def guest_user_count
active_user_count - User.active.excluding_guests.count
end
def max_historical_user_count
HistoricalData.max_historical_user_count
end
Loading
Loading
@@ -111,7 +115,8 @@ module LicenseHelper
end
 
def license_app_data
{ data: { current_active_user_count: current_active_user_count,
{ data: { active_user_count: active_user_count,
guest_user_count: guest_user_count,
licenses_path: api_licenses_url,
delete_license_path: api_license_url(id: ':id'),
new_license_path: new_admin_license_path, download_license_path: download_admin_license_path } }
Loading
Loading
---
title: Fix License App user count for ultimate
merge_request: 14055
author:
type: fixed
Loading
Loading
@@ -24,7 +24,13 @@ describe "Licenses app", :js do
expect(seats_in_license).to have_content 'Seats in license'
expect(seats_in_license).to have_content license.restrictions[:active_user_count]
expect(seats_in_use).to have_content 'Seats currently in use'
expect(seats_in_use).to have_content User.active.count
if license.exclude_guests_from_active_count?
expect(seats_in_use).to have_content User.active.excluding_guests.count
else
expect(seats_in_use).to have_content User.active.count
end
expect(historical_max).to have_content 'Max seats used'
expect(historical_max).to have_content license.historical_max
expect(overage).to have_content 'Users outside of license'
Loading
Loading
Loading
Loading
@@ -24,7 +24,7 @@ exports[`LicenseCardBody renders a license card body 1`] = `
<infocell-stub
popovercontent="Users with a Guest role or those who don't belong to any projects or groups don't count towards seats in use."
title="Seats currently in use"
value="10"
value="2"
/>
<infocell-stub
Loading
Loading
@@ -241,7 +241,7 @@ exports[`LicenseCardBody renders fallback licensee values 1`] = `
<infocell-stub
popovercontent="Users with a Guest role or those who don't belong to any projects or groups don't count towards seats in use."
title="Seats currently in use"
value="10"
value="2"
/>
<infocell-stub
Loading
Loading
Loading
Loading
@@ -35,7 +35,8 @@ exports[`LicenseCard renders license card with a delete button and license body
</div>
<licensecardbody-stub
currentactiveusercount="10"
activeusercount="10"
guestusercount="8"
license="[object Object]"
/>
</div>
Loading
Loading
Loading
Loading
@@ -18,7 +18,8 @@ describe('LicenseCardBody', () => {
},
},
isRemoving: false,
currentActiveUserCount: 10,
activeUserCount: 10,
guestUserCount: 8,
};
 
function createComponent(props = {}) {
Loading
Loading
Loading
Loading
@@ -13,7 +13,8 @@ describe('LicenseCard', () => {
isCurrentLicense: false,
};
const defaultState = {
currentActiveUserCount: 10,
activeUserCount: 10,
guestUserCount: 8,
deleteQueue: [],
downloadLicensePath: '/downloadLicensePath',
};
Loading
Loading
Loading
Loading
@@ -56,4 +56,16 @@ describe LicenseHelper do
expect(api_license_url(id: 1)).to eq('http://localhost/gitlab/api/v4/license/1')
end
end
describe '#active_user_count' do
it 'returns the number of active users' do
expect(active_user_count).to eq(User.active.count)
end
end
describe '#guest_user_count' do
it 'returns the number of active guest users' do
expect(guest_user_count).to eq(User.active.count - User.active.excluding_guests.count)
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment