diff --git a/public/app/features/all.ts b/public/app/features/all.ts index ad33af34cfe..7fe6eadbc36 100644 --- a/public/app/features/all.ts +++ b/public/app/features/all.ts @@ -4,7 +4,6 @@ import './plugins/all'; import './dashboard'; import './playlist/all'; import './panel/all'; -import './org/all'; import './admin'; import './alerting/NotificationsEditCtrl'; import './manage-dashboards'; diff --git a/public/app/features/org/SelectOrgCtrl.ts b/public/app/features/org/SelectOrgCtrl.ts deleted file mode 100644 index e167b9d823a..00000000000 --- a/public/app/features/org/SelectOrgCtrl.ts +++ /dev/null @@ -1,45 +0,0 @@ -import angular from 'angular'; -import config from 'app/core/config'; -import { getBackendSrv } from '@grafana/runtime'; -import { promiseToDigest } from 'app/core/utils/promiseToDigest'; - -export class SelectOrgCtrl { - /** @ngInject */ - constructor($scope: any, contextSrv: any) { - contextSrv.sidemenu = false; - - $scope.navModel = { - main: { - icon: 'grafana', - subTitle: 'Preferences', - text: 'Select active organization', - }, - }; - - $scope.init = () => { - $scope.getUserOrgs(); - }; - - $scope.getUserOrgs = () => { - promiseToDigest($scope)( - getBackendSrv() - .get('/api/user/orgs') - .then((orgs: any) => { - $scope.orgs = orgs; - }) - ); - }; - - $scope.setUsingOrg = (org: any) => { - getBackendSrv() - .post('/api/user/using/' + org.orgId) - .then(() => { - window.location.href = config.appSubUrl + '/'; - }); - }; - - $scope.init(); - } -} - -angular.module('grafana.controllers').controller('SelectOrgCtrl', SelectOrgCtrl); diff --git a/public/app/features/org/SelectOrgPage.tsx b/public/app/features/org/SelectOrgPage.tsx new file mode 100644 index 00000000000..77e8a25dbc4 --- /dev/null +++ b/public/app/features/org/SelectOrgPage.tsx @@ -0,0 +1,58 @@ +import React, { FC, useState } from 'react'; +import Page from 'app/core/components/Page/Page'; +import { getBackendSrv, config } from '@grafana/runtime'; +import { UserOrg } from 'app/types'; +import { useAsync } from 'react-use'; +import { Button, HorizontalGroup } from '@grafana/ui'; + +const navModel = { + main: { + icon: 'grafana', + subTitle: 'Preferences', + text: 'Select active organization', + }, + node: { + text: 'Select active organization', + }, +}; + +const getUserOrgs = async () => { + return await getBackendSrv().get('/api/user/orgs'); +}; +const setUserOrg = async (org: UserOrg) => { + return await getBackendSrv() + .post('/api/user/using/' + org.orgId) + .then(() => { + window.location.href = config.appSubUrl + '/'; + }); +}; + +export const SelectOrgPage: FC = () => { + const [orgs, setOrgs] = useState(); + + useAsync(async () => { + setOrgs(await getUserOrgs()); + }, []); + return ( + + +
+

+ You have been added to another Organization due to an open invitation! Please select which organization you + want to use right now (you can change this later at any time). +

+ + {orgs && + orgs.map(org => ( + + ))} + +
+
+
+ ); +}; + +export default SelectOrgPage; diff --git a/public/app/features/org/all.ts b/public/app/features/org/all.ts deleted file mode 100644 index ecdaf0b7d55..00000000000 --- a/public/app/features/org/all.ts +++ /dev/null @@ -1 +0,0 @@ -import './SelectOrgCtrl'; diff --git a/public/app/features/org/partials/select_org.html b/public/app/features/org/partials/select_org.html deleted file mode 100644 index c4c82054508..00000000000 --- a/public/app/features/org/partials/select_org.html +++ /dev/null @@ -1,27 +0,0 @@ - - -
- - -
- - -