Commit af9b73cc authored by Thiago Presa's avatar Thiago Presa Committed by Fatih Acet

Fix License App user count

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