Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
a188ceac
Commit
a188ceac
authored
Oct 02, 2018
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
invitees
parent
3c8820ab
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
588 additions
and
25 deletions
+588
-25
public/app/core/components/OrgActionBar/OrgActionBar.test.tsx
+0
-1
public/app/features/users/InviteesTable.test.tsx
+32
-0
public/app/features/users/InviteesTable.tsx
+8
-3
public/app/features/users/UsersActionBar.test.tsx
+51
-0
public/app/features/users/UsersListPage.test.tsx
+5
-1
public/app/features/users/__mocks__/userMocks.ts
+25
-0
public/app/features/users/__snapshots__/InviteesTable.test.tsx.snap
+318
-0
public/app/features/users/__snapshots__/UsersActionBar.test.tsx.snap
+141
-0
public/app/features/users/__snapshots__/UsersListPage.test.tsx.snap
+2
-10
public/app/features/users/__snapshots__/UsersTable.test.tsx.snap
+6
-10
No files found.
public/app/core/components/OrgActionBar/OrgActionBar.test.tsx
View file @
a188ceac
...
...
@@ -5,7 +5,6 @@ import OrgActionBar, { Props } from './OrgActionBar';
const
setup
=
(
propOverrides
?:
object
)
=>
{
const
props
:
Props
=
{
searchQuery
:
''
,
showLayoutMode
:
true
,
setSearchQuery
:
jest
.
fn
(),
linkButton
:
{
href
:
'some/url'
,
title
:
'test'
},
};
...
...
public/app/features/users/InviteesTable.test.tsx
0 → 100644
View file @
a188ceac
import
React
from
'react'
;
import
{
shallow
}
from
'enzyme'
;
import
InviteesTable
,
{
Props
}
from
'./InviteesTable'
;
import
{
Invitee
}
from
'app/types'
;
import
{
getMockInvitees
}
from
'./__mocks__/userMocks'
;
const
setup
=
(
propOverrides
?:
object
)
=>
{
const
props
:
Props
=
{
invitees
:
[]
as
Invitee
[],
revokeInvite
:
jest
.
fn
(),
};
Object
.
assign
(
props
,
propOverrides
);
return
shallow
(<
InviteesTable
{
...
props
}
/>);
};
describe
(
'Render'
,
()
=>
{
it
(
'should render component'
,
()
=>
{
const
wrapper
=
setup
();
expect
(
wrapper
).
toMatchSnapshot
();
});
it
(
'should render invitees'
,
()
=>
{
const
wrapper
=
setup
({
invitees
:
getMockInvitees
(
5
),
});
expect
(
wrapper
).
toMatchSnapshot
();
});
});
public/app/features/users/InviteesTable.tsx
View file @
a188ceac
...
...
@@ -7,10 +7,10 @@ export interface Props {
}
export
default
class
InviteesTable
extends
PureComponent
<
Props
>
{
private
copyRef
=
createRef
<
HTMLTextAreaElement
>
();
private
copy
Url
Ref
=
createRef
<
HTMLTextAreaElement
>
();
copyToClipboard
=
()
=>
{
const
node
=
this
.
copyRef
.
current
;
const
node
=
this
.
copy
Url
Ref
.
current
;
if
(
node
)
{
node
.
select
();
...
...
@@ -39,7 +39,12 @@ export default class InviteesTable extends PureComponent<Props> {
<
td
>
{
invitee
.
name
}
</
td
>
<
td
className=
"text-right"
>
<
button
className=
"btn btn-inverse btn-mini"
onClick=
{
this
.
copyToClipboard
}
>
<
textarea
readOnly=
{
true
}
value=
{
invitee
.
url
}
style=
{
{
display
:
'none'
}
}
ref=
{
this
.
copyRef
}
/>
<
textarea
readOnly=
{
true
}
value=
{
invitee
.
url
}
style=
{
{
position
:
'absolute'
,
right
:
-
1000
}
}
ref=
{
this
.
copyUrlRef
}
/>
<
i
className=
"fa fa-clipboard"
/>
Copy Invite
</
button
>
...
...
public/app/features/users/UsersActionBar.test.tsx
0 → 100644
View file @
a188ceac
import
React
from
'react'
;
import
{
shallow
}
from
'enzyme'
;
import
{
UsersActionBar
,
Props
}
from
'./UsersActionBar'
;
const
setup
=
(
propOverrides
?:
object
)
=>
{
const
props
:
Props
=
{
searchQuery
:
''
,
setUsersSearchQuery
:
jest
.
fn
(),
showInvites
:
false
,
pendingInvitesCount
:
0
,
canInvite
:
false
,
externalUserMngLinkUrl
:
''
,
externalUserMngLinkName
:
''
,
};
Object
.
assign
(
props
,
propOverrides
);
return
shallow
(<
UsersActionBar
{
...
props
}
/>);
};
describe
(
'Render'
,
()
=>
{
it
(
'should render component'
,
()
=>
{
const
wrapper
=
setup
();
expect
(
wrapper
).
toMatchSnapshot
();
});
it
(
'should render pending invites button'
,
()
=>
{
const
wrapper
=
setup
({
pendingInvitesCount
:
5
,
});
expect
(
wrapper
).
toMatchSnapshot
();
});
it
(
'should show invite button'
,
()
=>
{
const
wrapper
=
setup
({
canInvite
:
true
,
});
expect
(
wrapper
).
toMatchSnapshot
();
});
it
(
'should show external user management button'
,
()
=>
{
const
wrapper
=
setup
({
externalUserMngLinkUrl
:
'some/url'
,
});
expect
(
wrapper
).
toMatchSnapshot
();
});
});
public/app/features/users/UsersListPage.test.tsx
View file @
a188ceac
import
React
from
'react'
;
import
{
shallow
}
from
'enzyme'
;
import
{
UsersListPage
,
Props
}
from
'./UsersListPage'
;
import
{
NavModel
,
User
}
from
'app/types'
;
import
{
Invitee
,
NavModel
,
User
}
from
'app/types'
;
import
{
getMockUser
}
from
'./__mocks__/userMocks'
;
import
appEvents
from
'../../core/app_events'
;
...
...
@@ -13,7 +13,11 @@ const setup = (propOverrides?: object) => {
const
props
:
Props
=
{
navModel
:
{}
as
NavModel
,
users
:
[]
as
User
[],
invitees
:
[]
as
Invitee
[],
searchQuery
:
''
,
externalUserMngInfo
:
''
,
revokeInvite
:
jest
.
fn
(),
loadInvitees
:
jest
.
fn
(),
loadUsers
:
jest
.
fn
(),
updateUser
:
jest
.
fn
(),
removeUser
:
jest
.
fn
(),
...
...
public/app/features/users/__mocks__/userMocks.ts
View file @
a188ceac
...
...
@@ -29,3 +29,28 @@ export const getMockUser = () => {
userId
:
2
,
};
};
export
const
getMockInvitees
=
(
amount
:
number
)
=>
{
const
invitees
=
[];
for
(
let
i
=
0
;
i
<=
amount
;
i
++
)
{
invitees
.
push
({
code
:
`asdfasdfsadf-
${
i
}
`
,
createdOn
:
'2018-10-02'
,
email
:
`invitee-
${
i
}
@test.com`
,
emailSent
:
true
,
emailSentOn
:
'2018-10-02'
,
id
:
i
,
invitedByEmail
:
'admin@grafana.com'
,
invitedByLogin
:
'admin'
,
invitedByName
:
'admin'
,
name
:
`invitee-
${
i
}
`
,
orgId
:
1
,
role
:
'viewer'
,
status
:
'not accepted'
,
url
:
`localhost/invite/$
${
i
}
`
,
});
}
return
invitees
;
};
public/app/features/users/__snapshots__/InviteesTable.test.tsx.snap
0 → 100644
View file @
a188ceac
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Render should render component 1`] = `
<table
className="filter-table form-inline"
>
<thead>
<tr>
<th>
Email
</th>
<th>
Name
</th>
<th />
<th
style={
Object {
"width": "34px",
}
}
/>
</tr>
</thead>
<tbody />
</table>
`;
exports[`Render should render invitees 1`] = `
<table
className="filter-table form-inline"
>
<thead>
<tr>
<th>
Email
</th>
<th>
Name
</th>
<th />
<th
style={
Object {
"width": "34px",
}
}
/>
</tr>
</thead>
<tbody>
<tr
key="0-0"
>
<td>
invitee-0@test.com
</td>
<td>
invitee-0
</td>
<td
className="text-right"
>
<button
className="btn btn-inverse btn-mini"
onClick={[Function]}
>
<textarea
readOnly={true}
style={
Object {
"position": "absolute",
"right": -1000,
}
}
value="localhost/invite/$0"
/>
<i
className="fa fa-clipboard"
/>
Copy Invite
</button>
</td>
<td>
<button
className="btn btn-danger btn-mini"
onClick={[Function]}
>
<i
className="fa fa-remove"
/>
</button>
</td>
</tr>
<tr
key="1-1"
>
<td>
invitee-1@test.com
</td>
<td>
invitee-1
</td>
<td
className="text-right"
>
<button
className="btn btn-inverse btn-mini"
onClick={[Function]}
>
<textarea
readOnly={true}
style={
Object {
"position": "absolute",
"right": -1000,
}
}
value="localhost/invite/$1"
/>
<i
className="fa fa-clipboard"
/>
Copy Invite
</button>
</td>
<td>
<button
className="btn btn-danger btn-mini"
onClick={[Function]}
>
<i
className="fa fa-remove"
/>
</button>
</td>
</tr>
<tr
key="2-2"
>
<td>
invitee-2@test.com
</td>
<td>
invitee-2
</td>
<td
className="text-right"
>
<button
className="btn btn-inverse btn-mini"
onClick={[Function]}
>
<textarea
readOnly={true}
style={
Object {
"position": "absolute",
"right": -1000,
}
}
value="localhost/invite/$2"
/>
<i
className="fa fa-clipboard"
/>
Copy Invite
</button>
</td>
<td>
<button
className="btn btn-danger btn-mini"
onClick={[Function]}
>
<i
className="fa fa-remove"
/>
</button>
</td>
</tr>
<tr
key="3-3"
>
<td>
invitee-3@test.com
</td>
<td>
invitee-3
</td>
<td
className="text-right"
>
<button
className="btn btn-inverse btn-mini"
onClick={[Function]}
>
<textarea
readOnly={true}
style={
Object {
"position": "absolute",
"right": -1000,
}
}
value="localhost/invite/$3"
/>
<i
className="fa fa-clipboard"
/>
Copy Invite
</button>
</td>
<td>
<button
className="btn btn-danger btn-mini"
onClick={[Function]}
>
<i
className="fa fa-remove"
/>
</button>
</td>
</tr>
<tr
key="4-4"
>
<td>
invitee-4@test.com
</td>
<td>
invitee-4
</td>
<td
className="text-right"
>
<button
className="btn btn-inverse btn-mini"
onClick={[Function]}
>
<textarea
readOnly={true}
style={
Object {
"position": "absolute",
"right": -1000,
}
}
value="localhost/invite/$4"
/>
<i
className="fa fa-clipboard"
/>
Copy Invite
</button>
</td>
<td>
<button
className="btn btn-danger btn-mini"
onClick={[Function]}
>
<i
className="fa fa-remove"
/>
</button>
</td>
</tr>
<tr
key="5-5"
>
<td>
invitee-5@test.com
</td>
<td>
invitee-5
</td>
<td
className="text-right"
>
<button
className="btn btn-inverse btn-mini"
onClick={[Function]}
>
<textarea
readOnly={true}
style={
Object {
"position": "absolute",
"right": -1000,
}
}
value="localhost/invite/$5"
/>
<i
className="fa fa-clipboard"
/>
Copy Invite
</button>
</td>
<td>
<button
className="btn btn-danger btn-mini"
onClick={[Function]}
>
<i
className="fa fa-remove"
/>
</button>
</td>
</tr>
</tbody>
</table>
`;
public/app/features/users/__snapshots__/UsersActionBar.test.tsx.snap
0 → 100644
View file @
a188ceac
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Render should render component 1`] = `
<div
className="page-action-bar"
>
<div
className="gf-form gf-form--grow"
>
<label
className="gf-form--has-input-icon"
>
<input
className="gf-form-input width-20"
onChange={[Function]}
placeholder="Filter by name or type"
type="text"
value=""
/>
<i
className="gf-form-input-icon fa fa-search"
/>
</label>
<div
className="page-action-bar__spacer"
/>
</div>
</div>
`;
exports[`Render should render pending invites button 1`] = `
<div
className="page-action-bar"
>
<div
className="gf-form gf-form--grow"
>
<label
className="gf-form--has-input-icon"
>
<input
className="gf-form-input width-20"
onChange={[Function]}
placeholder="Filter by name or type"
type="text"
value=""
/>
<i
className="gf-form-input-icon fa fa-search"
/>
</label>
<div
className="page-action-bar__spacer"
/>
<button
className="btn btn-inverse"
onClick={false}
>
Pending Invites (
5
)
</button>
</div>
</div>
`;
exports[`Render should show external user management button 1`] = `
<div
className="page-action-bar"
>
<div
className="gf-form gf-form--grow"
>
<label
className="gf-form--has-input-icon"
>
<input
className="gf-form-input width-20"
onChange={[Function]}
placeholder="Filter by name or type"
type="text"
value=""
/>
<i
className="gf-form-input-icon fa fa-search"
/>
</label>
<div
className="page-action-bar__spacer"
/>
<a
className="btn btn-success"
href="some/url"
target="_blank"
>
<i
className="fa fa-external-link-square"
/>
</a>
</div>
</div>
`;
exports[`Render should show invite button 1`] = `
<div
className="page-action-bar"
>
<div
className="gf-form gf-form--grow"
>
<label
className="gf-form--has-input-icon"
>
<input
className="gf-form-input width-20"
onChange={[Function]}
placeholder="Filter by name or type"
type="text"
value=""
/>
<i
className="gf-form-input-icon fa fa-search"
/>
</label>
<div
className="page-action-bar__spacer"
/>
<a
className="btn btn-success"
href="org/users/invite"
>
<i
className="fa fa-plus"
/>
<span>
Invite
</span>
</a>
</div>
</div>
`;
public/app/features/users/__snapshots__/UsersListPage.test.tsx.snap
View file @
a188ceac
...
...
@@ -8,16 +8,8 @@ exports[`Render should render component 1`] = `
<div
className="page-container page-body"
>
<OrgActionBar
linkButton={
Object {
"href": "/org/users/add",
"title": "Add user",
}
}
searchQuery=""
setSearchQuery={[MockFunction]}
showLayoutMode={false}
<Connect(UsersActionBar)
showInvites={[Function]}
/>
<UsersTable
onRemoveUser={[Function]}
...
...
public/app/features/users/__snapshots__/UsersTable.test.tsx.snap
View file @
a188ceac
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Render should render component 1`] = `
<div>
<table
<table
className="filter-table form-inline"
>
>
<thead>
<tr>
<th />
...
...
@@ -30,15 +29,13 @@ exports[`Render should render component 1`] = `
</tr>
</thead>
<tbody />
</table>
</div>
</table>
`;
exports[`Render should render users table 1`] = `
<div>
<table
<table
className="filter-table form-inline"
>
>
<thead>
<tr>
<th />
...
...
@@ -443,6 +440,5 @@ exports[`Render should render users table 1`] = `
</td>
</tr>
</tbody>
</table>
</div>
</table>
`;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment