Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
0733f7f0
Commit
0733f7f0
authored
Jun 04, 2020
by
Dhiraj Bodicherla
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add vue router to metrics dashboard
This MR adds vue router with base route for the metrics dashboard page
parent
df71d756
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
105 additions
and
12 deletions
+105
-12
app/assets/javascripts/monitoring/components/dashboard.vue
app/assets/javascripts/monitoring/components/dashboard.vue
+2
-1
app/assets/javascripts/monitoring/monitoring_app.js
app/assets/javascripts/monitoring/monitoring_app.js
+10
-8
app/assets/javascripts/monitoring/pages/dashboard_page.vue
app/assets/javascripts/monitoring/pages/dashboard_page.vue
+18
-0
app/assets/javascripts/monitoring/router/constants.js
app/assets/javascripts/monitoring/router/constants.js
+3
-0
app/assets/javascripts/monitoring/router/index.js
app/assets/javascripts/monitoring/router/index.js
+15
-0
app/assets/javascripts/monitoring/router/routes.js
app/assets/javascripts/monitoring/router/routes.js
+18
-0
app/assets/javascripts/pages/projects/environments/metrics/index.js
.../javascripts/pages/projects/environments/metrics/index.js
+2
-2
ee/app/assets/javascripts/pages/projects/clusters/show/cluster_health.js
...avascripts/pages/projects/clusters/show/cluster_health.js
+1
-1
spec/frontend/monitoring/pages/dashboard_page_spec.js
spec/frontend/monitoring/pages/dashboard_page_spec.js
+36
-0
No files found.
app/assets/javascripts/monitoring/components/dashboard.vue
View file @
0733f7f0
...
...
@@ -85,7 +85,8 @@ export default {
},
defaultBranch
:
{
type
:
String
,
required
:
true
,
required
:
false
,
default
:
''
,
},
emptyGettingStartedSvgPath
:
{
type
:
String
,
...
...
app/assets/javascripts/monitoring/monitoring_
bundle
.js
→
app/assets/javascripts/monitoring/monitoring_
app
.js
View file @
0733f7f0
import
Vue
from
'
vue
'
;
import
{
GlToast
}
from
'
@gitlab/ui
'
;
import
Dashboard
from
'
~/monitoring/components/dashboard.vue
'
;
import
{
parseBoolean
}
from
'
~/lib/utils/common_utils
'
;
import
{
getParameterValues
}
from
'
~/lib/utils/url_utility
'
;
import
{
createStore
}
from
'
./stores
'
;
import
createRouter
from
'
./router
'
;
Vue
.
use
(
GlToast
);
...
...
@@ -21,6 +21,7 @@ export default (props = {}) => {
logsPath
,
currentEnvironmentName
,
dashboardTimezone
,
metricsDashboardBasePath
,
...
dataProps
}
=
el
.
dataset
;
...
...
@@ -40,18 +41,19 @@ export default (props = {}) => {
dataProps
.
customMetricsAvailable
=
parseBoolean
(
dataProps
.
customMetricsAvailable
);
dataProps
.
prometheusAlertsAvailable
=
parseBoolean
(
dataProps
.
prometheusAlertsAvailable
);
const
router
=
createRouter
(
metricsDashboardBasePath
);
// eslint-disable-next-line no-new
new
Vue
({
el
,
store
,
render
(
createElement
)
{
return
createElement
(
Dashboard
,
{
props
:
{
...
dataProps
,
...
props
,
},
});
router
,
data
()
{
return
{
dashboardProps
:
{
...
dataProps
,
...
props
},
};
},
template
:
`<router-view :dashboardProps="dashboardProps"/>`
,
});
}
};
app/assets/javascripts/monitoring/pages/dashboard_page.vue
0 → 100644
View file @
0733f7f0
<
script
>
import
Dashboard
from
'
../components/dashboard.vue
'
;
export
default
{
components
:
{
Dashboard
,
},
props
:
{
dashboardProps
:
{
type
:
Object
,
required
:
true
,
},
},
};
</
script
>
<
template
>
<dashboard
v-bind=
"
{ ...dashboardProps }" />
</
template
>
app/assets/javascripts/monitoring/router/constants.js
0 → 100644
View file @
0733f7f0
export
const
BASE_DASHBOARD_PAGE
=
'
dashboard
'
;
export
default
{};
app/assets/javascripts/monitoring/router/index.js
0 → 100644
View file @
0733f7f0
import
Vue
from
'
vue
'
;
import
VueRouter
from
'
vue-router
'
;
import
routes
from
'
./routes
'
;
Vue
.
use
(
VueRouter
);
export
default
function
createRouter
(
base
)
{
const
router
=
new
VueRouter
({
base
,
mode
:
'
history
'
,
routes
,
});
return
router
;
}
app/assets/javascripts/monitoring/router/routes.js
0 → 100644
View file @
0733f7f0
import
DashboardPage
from
'
../pages/dashboard_page.vue
'
;
import
{
BASE_DASHBOARD_PAGE
}
from
'
./constants
'
;
/**
* Because the cluster health page uses the dashboard
* app instead the of the dashboard component, hitting
* `/` route is not possible. Hence using `*` until the
* health page is refactored.
* https://gitlab.com/gitlab-org/gitlab/-/issues/221096
*/
export
default
[
{
name
:
BASE_DASHBOARD_PAGE
,
path
:
'
*
'
,
component
:
DashboardPage
,
},
];
app/assets/javascripts/pages/projects/environments/metrics/index.js
View file @
0733f7f0
import
monitoring
Bundle
from
'
~/monitoring/monitoring_bundle
'
;
import
monitoring
App
from
'
~/monitoring/monitoring_app
'
;
document
.
addEventListener
(
'
DOMContentLoaded
'
,
monitoring
Bundle
);
document
.
addEventListener
(
'
DOMContentLoaded
'
,
monitoring
App
);
ee/app/assets/javascripts/pages/projects/clusters/show/cluster_health.js
View file @
0733f7f0
import
initCeBundle
from
'
~/monitoring/monitoring_
bundle
'
;
import
initCeBundle
from
'
~/monitoring/monitoring_
app
'
;
export
default
()
=>
{
const
el
=
document
.
getElementById
(
'
prometheus-graphs
'
);
...
...
spec/frontend/monitoring/pages/dashboard_page_spec.js
0 → 100644
View file @
0733f7f0
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
DashboardPage
from
'
~/monitoring/pages/dashboard_page.vue
'
;
import
Dashboard
from
'
~/monitoring/components/dashboard.vue
'
;
import
{
propsData
}
from
'
../mock_data
'
;
describe
(
'
monitoring/pages/dashboard_page
'
,
()
=>
{
let
wrapper
;
const
buildWrapper
=
(
props
=
{})
=>
{
wrapper
=
shallowMount
(
DashboardPage
,
{
propsData
:
{
...
props
,
},
});
};
const
findDashboardComponent
=
()
=>
wrapper
.
find
(
Dashboard
);
afterEach
(()
=>
{
if
(
wrapper
)
{
wrapper
.
destroy
();
wrapper
=
null
;
}
});
it
(
'
throws errors if dashboard props are not passed
'
,
()
=>
{
expect
(()
=>
buildWrapper
()).
toThrow
(
'
Missing required prop: "dashboardProps"
'
);
});
it
(
'
renders the dashboard page with dashboard component
'
,
()
=>
{
buildWrapper
({
dashboardProps
:
propsData
});
expect
(
findDashboardComponent
().
props
()).
toMatchObject
(
propsData
);
expect
(
findDashboardComponent
()).
toExist
();
});
});
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