Skip to content

Commit

Permalink
Orgs: Add future deprecation notice (#24502)
Browse files Browse the repository at this point in the history
* Orgs: Fist draft of orgs deprecation infobox

* adds warning about potentially deprecating orgs (#24512)

* Updates

* Fixed ts issue

Co-authored-by: Carl Bergquist <carl@grafana.com>
  • Loading branch information
torkelo and bergquist committed May 14, 2020
1 parent 85ae144 commit 2f22781
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/grafana-ui/src/components/Badge/Badge.tsx
Expand Up @@ -9,7 +9,7 @@ import tinycolor from 'tinycolor2';
import { css } from 'emotion';
import { HorizontalGroup } from '..';

export type BadgeColor = 'blue' | 'red' | 'green' | 'orange';
export type BadgeColor = 'blue' | 'red' | 'green' | 'orange' | 'purple';

export interface BadgeProps {
text: string;
Expand Down
Expand Up @@ -9,6 +9,7 @@ interface FeatureInfoBox extends Omit<InfoBoxProps, 'branded' | 'title' | 'urlTi
title: string;
featureState?: FeatureState;
}

export const FeatureInfoBox = React.memo(
React.forwardRef<HTMLDivElement, FeatureInfoBox>(({ title, featureState, ...otherProps }, ref) => {
const theme = useTheme();
Expand Down
29 changes: 29 additions & 0 deletions pkg/services/sqlstore/sqlstore.go
Expand Up @@ -101,13 +101,42 @@ func (ss *SqlStore) Init() error {
ss.addUserQueryAndCommandHandlers()
ss.addAlertNotificationUidByIdHandler()

err = ss.logOrgsNotice()
if err != nil {
return err
}

if ss.skipEnsureDefaultOrgAndUser {
return nil
}

return ss.ensureMainOrgAndAdminUser()
}

func (ss *SqlStore) logOrgsNotice() error {
type targetCount struct {
Count int64
}

return ss.WithDbSession(context.Background(), func(session *DBSession) error {
resp := make([]*targetCount, 0)
if err := session.SQL("select count(id) as Count from org").Find(&resp); err != nil {
return err
}

if resp[0].Count > 1 {
ss.log.Warn(`[Deprecation notice]`)
ss.log.Warn(`Fewer than 1% of Grafana installations use organizations, and we feel that most of those`)
ss.log.Warn(`users would have a better experience using Teams instead. As such, we are considering de-emphasizing`)
ss.log.Warn(`and eventually deprecating Organizations in a future Grafana release. If you would like to provide`)
ss.log.Warn(`feedback or describe your need, please do so in the issue linked below`)
ss.log.Warn(`https://github.com/grafana/grafana/issues/24588`)
}

return nil
})
}

func (ss *SqlStore) ensureMainOrgAndAdminUser() error {
err := ss.InTransaction(context.Background(), func(ctx context.Context) error {
systemUserCountQuery := models.GetSystemUserCountStatsQuery{}
Expand Down
17 changes: 16 additions & 1 deletion public/app/features/admin/AdminListOrgsPage.tsx
Expand Up @@ -3,7 +3,7 @@ import { getNavModel } from 'app/core/selectors/navModel';
import Page from 'app/core/components/Page/Page';
import { useSelector } from 'react-redux';
import { StoreState } from 'app/types/store';
import { LinkButton } from '@grafana/ui';
import { LinkButton, InfoBox, VerticalGroup } from '@grafana/ui';
import { getBackendSrv } from '@grafana/runtime';
import { AdminOrgsTable } from './AdminOrgsTable';
import useAsyncFn from 'react-use/lib/useAsyncFn';
Expand All @@ -29,6 +29,21 @@ export const AdminListOrgsPages: FC = () => {
<Page.Contents>
<>
<div className="page-action-bar">
<InfoBox branded>
<VerticalGroup spacing="xs">
<p>
Fewer than 1% of Grafana installations use organizations, and we think that most of those would have a
better experience with Teams instead. As such, we are considering de-emphasizing and eventually
deprecating Organizations in a future Grafana release. If you would like to provide feedback or
describe your need, please do so{' '}
<a className="external-link" href="https://github.com/grafana/grafana/issues/24588">
here
</a>
.{' '}
</p>
</VerticalGroup>
</InfoBox>

<div className="page-action-bar__spacer"></div>
<LinkButton icon="plus" href="org/new">
New org
Expand Down

0 comments on commit 2f22781

Please sign in to comment.