Commit 0c774e86 authored by Matthias van de Meent's avatar Matthias van de Meent Committed by Mayra Cabrera

Remove Cohorts limit by dropping false dependency on Usage Ping

parent ad555aa8
<script>
import { GlEmptyState, GlSprintf, GlLink } from '@gitlab/ui';
export default {
components: {
GlEmptyState,
GlSprintf,
GlLink,
},
inject: {
svgPath: {
default: '',
},
docsLink: {
default: '',
},
primaryButtonPath: {
default: '',
},
},
};
</script>
<template>
<gl-empty-state
class="js-empty-state"
:title="__('Activate user activity analysis')"
:svg-path="svgPath"
:primary-button-text="__('Turn on usage ping')"
:primary-button-link="primaryButtonPath"
>
<template #description>
<gl-sprintf
:message="
__(
'Turn on %{strongStart}usage ping%{strongEnd} to activate analysis of user activity, known as %{docLinkStart}Cohorts%{docLinkEnd}.',
)
"
>
<template #docLink="{ content }">
<gl-link :href="docsLink" target="_blank">{{ content }}</gl-link>
</template>
<template #strong="{ content }"
><strong>{{ content }}</strong></template
>
</gl-sprintf>
</template>
</gl-empty-state>
</template>
import Vue from 'vue';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import AdminUsersApp from './components/app.vue';
import UsagePingDisabled from './components/usage_ping_disabled.vue';
export const initAdminUsersApp = (el = document.querySelector('#js-admin-users-app')) => {
if (!el) {
......@@ -21,23 +20,3 @@ export const initAdminUsersApp = (el = document.querySelector('#js-admin-users-a
}),
});
};
export const initCohortsEmptyState = (el = document.querySelector('#js-cohorts-empty-state')) => {
if (!el) {
return false;
}
const { emptyStateSvgPath, enableUsagePingLink, docsLink } = el.dataset;
return new Vue({
el,
provide: {
svgPath: emptyStateSvgPath,
primaryButtonPath: enableUsagePingLink,
docsLink,
},
render(h) {
return h(UsagePingDisabled);
},
});
};
import Vue from 'vue';
import { initAdminUsersApp, initCohortsEmptyState } from '~/admin/users';
import { initAdminUsersApp } from '~/admin/users';
import initTabs from '~/admin/users/tabs';
import initConfirmModal from '~/confirm_modal';
import csrf from '~/lib/utils/csrf';
......@@ -62,6 +62,5 @@ document.addEventListener('DOMContentLoaded', () => {
});
initConfirmModal();
initCohortsEmptyState();
initTabs();
});
......@@ -318,14 +318,12 @@ class Admin::UsersController < Admin::ApplicationController
end
def load_cohorts
if Gitlab::CurrentSettings.usage_ping_enabled
cohorts_results = Rails.cache.fetch('cohorts', expires_in: 1.day) do
CohortsService.new.execute
end
CohortsSerializer.new.represent(cohorts_results)
end
end
def track_cohorts_visit
if request.format.html? && request.headers['DNT'] != '1'
......
- if @cohorts
= render 'cohorts_table'
- else
#js-cohorts-empty-state{ data: { empty_state_svg_path: image_path('illustrations/convdev/convdev_no_index.svg'), enable_usage_ping_link: metrics_and_profiling_admin_application_settings_path(anchor: 'js-usage-settings'), docs_link: help_page_path('user/admin_area/analytics/user_cohorts') } }
= render 'cohorts_table'
......@@ -6,8 +6,7 @@ info: To determine the technical writer assigned to the Stage/Group associated w
# Cohorts **(FREE)**
As a benefit of having the [usage ping active](settings/usage_statistics.md),
you can analyze your users' GitLab activities over time.
You can analyze your users' GitLab activities over time.
To see user cohorts, go to **Admin Area > Overview > Users**.
......
......@@ -11,6 +11,7 @@ RSpec.describe 'admin/users/index' do
allow(view).to receive(:container_class).and_return('ignored')
create(:user) # to have at least one usser
assign(:users, User.all.page(1))
assign(:cohorts, { months_included: 0, cohorts: [] })
render
end
......
......@@ -1796,9 +1796,6 @@ msgstr ""
msgid "Activate Service Desk"
msgstr ""
msgid "Activate user activity analysis"
msgstr ""
msgid "Active"
msgstr ""
......@@ -33336,9 +33333,6 @@ msgstr ""
msgid "Turn on"
msgstr ""
msgid "Turn on %{strongStart}usage ping%{strongEnd} to activate analysis of user activity, known as %{docLinkStart}Cohorts%{docLinkEnd}."
msgstr ""
msgid "Turn on usage ping"
msgstr ""
......
......@@ -44,9 +44,8 @@ RSpec.describe "Admin::Users" do
end
describe 'Cohorts tab content' do
context 'with usage ping enabled' do
it 'shows users count per month' do
stub_application_setting(usage_ping_enabled: true)
stub_application_setting(usage_ping_enabled: false)
create_list(:user, 2)
......@@ -55,16 +54,4 @@ RSpec.describe "Admin::Users" do
expect(page).to have_content("#{Time.now.strftime('%b %Y')} 3 0")
end
end
context 'with usage ping disabled' do
it 'shows empty state', :js do
stub_application_setting(usage_ping_enabled: false)
visit admin_users_path(tab: 'cohorts')
expect(page).to have_selector(".js-empty-state")
expect(page).to have_content("Activate user activity analysis")
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