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F,SAACQ,EAAA,EAAD,CAAMV,SAAUA,EAAhB,UACE,SAACU,EAAA,WAAD,WACE,iCACE,iBAAKpC,UAAU,kBAAf,iBACE,gBAAKA,UAAU,8BACf,SAAC,EAAAqC,WAAD,CAAY1B,KAAK,OAAON,KAAK,UAAUQ,UAAWqB,EAAlD,wBAIDT,EAAMa,QAxBQA,EAwBiBb,EAAMa,OAvBvCA,MAAAA,GAAA,UAAAA,EAAOC,YAAP,eAAaC,UAAW,iCAwBtBf,EAAMgB,SAAW,yBACjBhB,EAAMiB,QACL,SAACnD,EAAD,CACEC,KAAMiC,EAAMiB,MACZjD,SAAWkD,IArCPb,OAAAA,SACHC,EAAAA,EAAAA,iBAAgBa,OAAO,aAAeD,GAqCrC9C,CAAU8C,GAAOE,MAAK,IAAMjB,gBA9BnBU,IAAAA,EAAe","sources":["webpack://grafana/./public/app/features/admin/AdminOrgsTable.tsx","webpack://grafana/./public/app/features/admin/AdminListOrgsPage.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport { Button, ConfirmModal } from '@grafana/ui';\nimport { contextSrv } from 'app/core/core';\nimport { AccessControlAction, Organization } from 'app/types';\n\ninterface Props {\n orgs: Organization[];\n onDelete: (orgId: number) => void;\n}\n\nexport function AdminOrgsTable({ orgs, onDelete }: Props) {\n const canDeleteOrgs = contextSrv.hasPermission(AccessControlAction.OrgsDelete);\n\n const [deleteOrg, setDeleteOrg] = useState<Organization>();\n return (\n <table className=\"filter-table form-inline filter-table--hover\">\n <thead>\n <tr>\n <th>ID</th>\n <th>Name</th>\n <th style={{ width: '1%' }}></th>\n </tr>\n </thead>\n <tbody>\n {orgs.map((org) => (\n <tr key={`${org.id}-${org.name}`}>\n <td className=\"link-td\">\n <a href={`admin/orgs/edit/${org.id}`}>{org.id}</a>\n </td>\n <td className=\"link-td\">\n <a href={`admin/orgs/edit/${org.id}`}>{org.name}</a>\n </td>\n <td className=\"text-right\">\n <Button\n variant=\"destructive\"\n size=\"sm\"\n icon=\"times\"\n onClick={() => setDeleteOrg(org)}\n aria-label=\"Delete org\"\n disabled={!canDeleteOrgs}\n />\n </td>\n </tr>\n ))}\n </tbody>\n {deleteOrg && (\n <ConfirmModal\n isOpen\n icon=\"trash-alt\"\n title=\"Delete\"\n body={\n <div>\n Are you sure you want to delete '{deleteOrg.name}'?\n <br /> <small>All dashboards for this organization will be removed!</small>\n </div>\n }\n confirmText=\"Delete\"\n onDismiss={() => setDeleteOrg(undefined)}\n onConfirm={() => {\n onDelete(deleteOrg.id);\n setDeleteOrg(undefined);\n }}\n />\n )}\n </table>\n );\n}\n","import React, { useEffect } from 'react';\nimport { useSelector } from 'react-redux';\nimport useAsyncFn from 'react-use/lib/useAsyncFn';\n\nimport { getBackendSrv } from '@grafana/runtime';\nimport { LinkButton } from '@grafana/ui';\nimport Page from 'app/core/components/Page/Page';\nimport { getNavModel } from 'app/core/selectors/navModel';\nimport { contextSrv } from 'app/core/services/context_srv';\nimport { AccessControlAction } from 'app/types';\nimport { StoreState } from 'app/types/store';\n\nimport { AdminOrgsTable } from './AdminOrgsTable';\n\nconst deleteOrg = async (orgId: number) => {\n return await getBackendSrv().delete('/api/orgs/' + orgId);\n};\n\nconst getOrgs = async () => {\n return await getBackendSrv().get('/api/orgs');\n};\n\nconst getErrorMessage = (error: any) => {\n return error?.data?.message || 'An unexpected error happened.';\n};\n\nexport default function AdminListOrgsPages() {\n const navIndex = useSelector((state: StoreState) => state.navIndex);\n const navModel = getNavModel(navIndex, 'global-orgs');\n const [state, fetchOrgs] = useAsyncFn(async () => await getOrgs(), []);\n const canCreateOrg = contextSrv.hasPermission(AccessControlAction.OrgsCreate);\n\n useEffect(() => {\n fetchOrgs();\n }, [fetchOrgs]);\n\n return (\n <Page navModel={navModel}>\n <Page.Contents>\n <>\n <div className=\"page-action-bar\">\n <div className=\"page-action-bar__spacer\" />\n <LinkButton icon=\"plus\" href=\"org/new\" disabled={!canCreateOrg}>\n New org\n </LinkButton>\n </div>\n {state.error && getErrorMessage(state.error)}\n {state.loading && 'Fetching organizations'}\n {state.value && (\n <AdminOrgsTable\n orgs={state.value}\n onDelete={(orgId) => {\n deleteOrg(orgId).then(() => fetchOrgs());\n }}\n />\n )}\n </>\n </Page.Contents>\n </Page>\n );\n}\n"],"names":["AdminOrgsTable","orgs","onDelete","canDeleteOrgs","contextSrv","AccessControlAction","deleteOrg","setDeleteOrg","useState","className","style","width","map","org","href","id","name","Button","variant","size","icon","onClick","disabled","ConfirmModal","isOpen","title","body","confirmText","onDismiss","undefined","onConfirm","AdminListOrgsPages","navIndex","useSelector","state","navModel","getNavModel","fetchOrgs","useAsyncFn","async","getBackendSrv","get","getOrgs","canCreateOrg","useEffect","Page","LinkButton","error","data","message","loading","value","orgId","delete","then"],"sourceRoot":""}
|