Skip to content

Commit 6cc0966

Browse files
authored
feat: add link to template pages from dashboards dropdown (#3215)
* feat: added a link to template page from dahsboard * fix: prettier * chore: clean up
1 parent df88eba commit 6cc0966

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

src/dashboards/components/dashboard_index/DashboardsIndex.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class DashboardIndex extends PureComponent<Props, State> {
8888
<AddResourceDropdown
8989
onSelectNew={createDashboard}
9090
onSelectImport={this.summonImportOverlay}
91-
onSelectTemplate={this.summonImportFromTemplateOverlay}
91+
onSelectTemplate={this.summonTemplatePage}
9292
resourceName="Dashboard"
9393
limitStatus={limitStatus}
9494
/>
@@ -155,14 +155,14 @@ class DashboardIndex extends PureComponent<Props, State> {
155155
history.push(`/orgs/${orgID}/dashboards-list/import`)
156156
}
157157

158-
private summonImportFromTemplateOverlay = (): void => {
158+
private summonTemplatePage = (): void => {
159159
const {
160160
history,
161161
match: {
162162
params: {orgID},
163163
},
164164
} = this.props
165-
history.push(`/orgs/${orgID}/dashboards-list/import/template`)
165+
history.push(`/orgs/${orgID}/settings/templates`)
166166
}
167167
}
168168

src/shared/components/AddResourceDropdown.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,20 @@ class AddResourceDropdown extends PureComponent<Props> {
8080
private get optionItems(): JSX.Element[] {
8181
const importOption = this.importOption
8282
const newOption = this.newOption
83+
const templateOption = this.templateOption
84+
const fromDashboard = this.props.resourceName === 'Dashboard'
85+
86+
const templateFromDashboard = (
87+
<Dropdown.Item
88+
id={templateOption}
89+
key={templateOption}
90+
onClick={this.handleSelect}
91+
value={templateOption}
92+
testID="add-resource-dropdown--template"
93+
>
94+
{templateOption}
95+
</Dropdown.Item>
96+
)
8397

8498
const items = [
8599
<Dropdown.Item
@@ -100,6 +114,7 @@ class AddResourceDropdown extends PureComponent<Props> {
100114
>
101115
{importOption}
102116
</Dropdown.Item>,
117+
...(fromDashboard ? [templateFromDashboard] : []),
103118
]
104119

105120
return items
@@ -114,7 +129,7 @@ class AddResourceDropdown extends PureComponent<Props> {
114129
}
115130

116131
private get templateOption(): string {
117-
return `From a Template`
132+
return `Add a Template`
118133
}
119134

120135
private handleLimit = (): void => {

0 commit comments

Comments
 (0)