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
3372dc94
Commit
3372dc94
authored
Jan 28, 2019
by
Johannes Schill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: Fix typings and add Page-component to FolderSettingsPage #14762
parent
d9a25ee5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
157 additions
and
138 deletions
+157
-138
public/app/features/folders/FolderSettingsPage.tsx
+45
-32
public/app/features/folders/__snapshots__/FolderSettingsPage.test.tsx.snap
+112
-106
No files found.
public/app/features/folders/FolderSettingsPage.tsx
View file @
3372dc94
import
React
,
{
PureComponent
}
from
'react'
;
import
{
hot
}
from
'react-hot-loader'
;
import
{
connect
}
from
'react-redux'
;
import
Page
Header
from
'app/core/components/PageHeader/PageHeader
'
;
import
Page
from
'app/core/components/Page/Page
'
;
import
appEvents
from
'app/core/app_events'
;
import
{
getNavModel
}
from
'app/core/selectors/navModel'
;
import
{
NavModel
,
StoreState
,
FolderState
}
from
'app/types'
;
...
...
@@ -18,23 +18,35 @@ export interface Props {
deleteFolder
:
typeof
deleteFolder
;
}
export
class
FolderSettingsPage
extends
PureComponent
<
Props
>
{
export
interface
State
{
isLoading
:
boolean
;
}
export
class
FolderSettingsPage
extends
PureComponent
<
Props
,
State
>
{
constructor
(
props
:
Props
)
{
super
(
props
);
this
.
state
=
{
isLoading
:
false
};
}
componentDidMount
()
{
this
.
props
.
getFolderByUid
(
this
.
props
.
folderUid
);
}
onTitleChange
=
evt
=>
{
onTitleChange
=
(
evt
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
this
.
props
.
setFolderTitle
(
evt
.
target
.
value
);
};
onSave
=
async
evt
=>
{
onSave
=
async
(
evt
:
React
.
FormEvent
<
HTMLFormElement
>
)
=>
{
evt
.
preventDefault
();
evt
.
stopPropagation
();
this
.
setState
({
isLoading
:
true
});
await
this
.
props
.
saveFolder
(
this
.
props
.
folder
);
this
.
setState
({
isLoading
:
false
});
};
onDelete
=
evt
=>
{
onDelete
=
(
evt
:
React
.
MouseEvent
<
HTMLButtonElement
>
)
=>
{
evt
.
stopPropagation
();
evt
.
preventDefault
();
...
...
@@ -53,34 +65,35 @@ export class FolderSettingsPage extends PureComponent<Props> {
const
{
navModel
,
folder
}
=
this
.
props
;
return
(
<
div
>
<
Page
Header
model=
{
navModel
}
/
>
<
div
className=
"page-container page-body"
>
<
h2
className=
"page-sub-heading"
>
Folder Settings
</
h2
>
<
Page
navModel=
{
navModel
}
>
<
Page
.
Contents
isLoading=
{
this
.
state
.
isLoading
}
>
<
div
className=
"page-container page-body"
>
<
h2
className=
"page-sub-heading"
>
Folder Settings
</
h2
>
<
div
className=
"section gf-form-group"
>
<
form
name=
"folderSettingsForm"
onSubmit=
{
this
.
onSave
}
>
<
div
className=
"gf-form"
>
<
label
className=
"gf-form-label width-7"
>
Name
</
label
>
<
input
type=
"text"
className=
"gf-form-input width-30"
value=
{
folder
.
title
}
onChange=
{
this
.
onTitleChange
}
/>
</
div
>
<
div
className=
"gf-form-button-row"
>
<
button
type=
"submit"
className=
"btn btn-success"
disabled=
{
!
folder
.
canSave
||
!
folder
.
hasChanged
}
>
<
i
className=
"fa fa-save"
/>
Save
</
button
>
<
button
className=
"btn btn-danger"
onClick=
{
this
.
onDelete
}
disabled=
{
!
folder
.
canSave
}
>
<
i
className=
"fa fa-trash"
/>
Delete
</
button
>
</
div
>
</
form
>
<
div
className=
"section gf-form-group"
>
<
form
name=
"folderSettingsForm"
onSubmit=
{
this
.
onSave
}
>
<
div
className=
"gf-form"
>
<
label
className=
"gf-form-label width-7"
>
Name
</
label
>
<
input
type=
"text"
className=
"gf-form-input width-30"
value=
{
folder
.
title
}
onChange=
{
this
.
onTitleChange
}
/>
</
div
>
<
div
className=
"gf-form-button-row"
>
<
button
type=
"submit"
className=
"btn btn-success"
disabled=
{
!
folder
.
canSave
||
!
folder
.
hasChanged
}
>
<
i
className=
"fa fa-save"
/>
Save
</
button
>
<
button
className=
"btn btn-danger"
onClick=
{
this
.
onDelete
}
disabled=
{
!
folder
.
canSave
}
>
<
i
className=
"fa fa-trash"
/>
Delete
</
button
>
</
div
>
</
form
>
</
div
>
</
div
>
</
div
>
</
div
>
</
Page
.
Contents
>
</
Page
>
);
}
}
...
...
public/app/features/folders/__snapshots__/FolderSettingsPage.test.tsx.snap
View file @
3372dc94
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Render should enable save button 1`] = `
<div>
<PageHeader
model={Object {}}
/>
<div
className="page-container page-body"
<Page
navModel={Object {}}
>
<PageContents
isLoading={false}
>
<h2
className="page-sub-heading"
>
Folder Settings
</h2>
<div
className="
section gf-form-group
"
className="
page-container page-body
"
>
<form
name="folderSettingsForm"
onSubmit={[Function]}
<h2
className="page-sub-heading"
>
<div
className="gf-form"
>
<label
className="gf-form-label width-7"
>
Name
</label>
<input
className="gf-form-input width-30"
onChange={[Function]}
type="text"
value="loading"
/>
</div>
<div
className="gf-form-button-row"
Folder Settings
</h2>
<div
className="section gf-form-group"
>
<form
name="folderSettingsForm"
onSubmit={[Function]}
>
<button
className="btn btn-success"
disabled={false}
type="submit"
<div
className="gf-form"
>
<i
className="fa fa-save"
<label
className="gf-form-label width-7"
>
Name
</label>
<input
className="gf-form-input width-30"
onChange={[Function]}
type="text"
value="loading"
/>
Save
</button>
<button
className="btn btn-danger"
disabled={false}
onClick={[Function]}
</div>
<div
className="gf-form-button-row"
>
<i
className="fa fa-trash"
/>
Delete
</button>
</div>
</form>
<button
className="btn btn-success"
disabled={false}
type="submit"
>
<i
className="fa fa-save"
/>
Save
</button>
<button
className="btn btn-danger"
disabled={false}
onClick={[Function]}
>
<i
className="fa fa-trash"
/>
Delete
</button>
</div>
</form>
</div>
</div>
</
div
>
</
div
>
</
PageContents
>
</
Page
>
`;
exports[`Render should render component 1`] = `
<div>
<PageHeader
model={Object {}}
/>
<div
className="page-container page-body"
<Page
navModel={Object {}}
>
<PageContents
isLoading={false}
>
<h2
className="page-sub-heading"
>
Folder Settings
</h2>
<div
className="
section gf-form-group
"
className="
page-container page-body
"
>
<form
name="folderSettingsForm"
onSubmit={[Function]}
<h2
className="page-sub-heading"
>
<div
className="gf-form"
>
<label
className="gf-form-label width-7"
>
Name
</label>
<input
className="gf-form-input width-30"
onChange={[Function]}
type="text"
value="loading"
/>
</div>
<div
className="gf-form-button-row"
Folder Settings
</h2>
<div
className="section gf-form-group"
>
<form
name="folderSettingsForm"
onSubmit={[Function]}
>
<button
className="btn btn-success"
disabled={true}
type="submit"
<div
className="gf-form"
>
<i
className="fa fa-save"
<label
className="gf-form-label width-7"
>
Name
</label>
<input
className="gf-form-input width-30"
onChange={[Function]}
type="text"
value="loading"
/>
Save
</button>
<button
className="btn btn-danger"
disabled={false}
onClick={[Function]}
</div>
<div
className="gf-form-button-row"
>
<i
className="fa fa-trash"
/>
Delete
</button>
</div>
</form>
<button
className="btn btn-success"
disabled={true}
type="submit"
>
<i
className="fa fa-save"
/>
Save
</button>
<button
className="btn btn-danger"
disabled={false}
onClick={[Function]}
>
<i
className="fa fa-trash"
/>
Delete
</button>
</div>
</form>
</div>
</div>
</
div
>
</
div
>
</
PageContents
>
</
Page
>
`;
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