Skip to content

Commit 1e670d6

Browse files
committed
feat: add authentication service and form
1 parent 4bf403b commit 1e670d6

32 files changed

+1247
-238
lines changed

apps/vscode-sonar-extension/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
All notable changes to the "creedengo-for-sonar" extension will be documented in this file.
44

5-
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
5+
Check [Keep a Changelog](https://keepachangelog.com/) for recommendations on how to structure this file.
66

77
## [Unreleased]
88

apps/vue-app/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"exports": {
1414
"./script": "./dist/view.js",
15-
"./stylesheet": "./dist/view.css"
15+
"./stylesheet": "./dist/view.css"
1616
},
1717
"scripts": {
1818
"preinstall": "npx only-allow pnpm",
@@ -34,13 +34,14 @@
3434
"dependencies": {
3535
"@creedengo/sonar-services": "workspace:*",
3636
"@creedengo/vue-ui": "workspace: *",
37-
"vue": "^3.5.18"
37+
"vue": "^3.5.18",
38+
"vue-router": "^4.5.1"
3839
},
3940
"devDependencies": {
4041
"@creedengo/core-services": "workspace: *",
41-
"@creedengo/sonar-services": "workspace: *",
4242
"@creedengo/eslint-config": "workspace: *",
4343
"@creedengo/playwright-config": "workspace:*",
44+
"@creedengo/sonar-services": "workspace: *",
4445
"@creedengo/vitest-config": "workspace:*",
4546
"@storybook/addon-a11y": "^9.1.2",
4647
"@storybook/addon-coverage": "^2.0.0",
@@ -60,7 +61,6 @@
6061
"jsdom": "^26.1.0",
6162
"msw": "^2.10.2",
6263
"msw-storybook-addon": "^2.0.5",
63-
"@playwright/test": "^1.54.2",
6464
"sonarqube-scanner": "^4.3.0",
6565
"storybook": "^9.1.2",
6666
"vite-plugin-vue-devtools": "^8.0.0",

apps/vue-app/src/App.vue

Lines changed: 40 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import SettingsPage from './components/pages/SettingsPage.vue';
44
import DashboardPage from './components/pages/DashboardPage.vue';
55
import NotFoundPage from './components/pages/NotFoundPage.vue';
66
7+
import { isSonarPlugin, isWebExtension, isWebsite } from './context';
8+
import ConnectionPage from './components/pages/ConnectionPage.vue';
9+
710
const routes = {
811
'/': DashboardPage,
912
'/settings': SettingsPage
@@ -33,15 +36,43 @@ const props = defineProps({
3336
</script>
3437

3538
<template>
36-
<component
37-
:is="currentView"
38-
:project="props.project"
39-
:branch="props.branch"
40-
/>
41-
<aside>
42-
<a href="#/">Dashboard</a> |
43-
<a href="#/settings">Settings</a>
44-
</aside>
39+
<div v-if="isSonarPlugin">
40+
<h2>Creedengo Sonar Dashboard</h2>
41+
<DashboardPage
42+
:project="props.project"
43+
:branch="props.branch"
44+
/>
45+
</div>
46+
<div v-if="isWebExtension">
47+
<header>
48+
<h1>Creedengo Extension Dashboard</h1>
49+
</header>
50+
<main>
51+
<component
52+
:is="currentView"
53+
:project="props.project"
54+
:branch="props.branch"
55+
/>
56+
</main>
57+
<nav aria-labelledby="menu-web-extension">
58+
<strong id="menu-web-extension">Menu</strong>
59+
<a href="#/">Dashboard</a> |
60+
<a href="#/settings">Settings</a>
61+
</nav>
62+
</div>
63+
<div v-if="isWebsite">
64+
<header>
65+
<h1>Creedengo Website Dashboard</h1>
66+
</header>
67+
<main>
68+
<ConnectionPage></ConnectionPage>
69+
</main>
70+
<nav aria-labelledby="menu-website">
71+
<strong id="menu-website">Menu</strong>
72+
<a href="#/">Dashboard</a> |
73+
<a href="#/settings">Settings</a>
74+
</nav>
75+
</div>
4576
</template>
4677

4778
<style scoped>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import sonar from '@creedengo/sonar-services'
22

3-
export const handlers = [...sonar.handlers]
3+
export const handlers = [...sonar.mockHandlers]

apps/vue-app/src/components/Widgets/Score/ScoreWidget.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
projectKey: { control: { type: 'text' }, default: 'my-project' },
1313
branch: { control: { type: 'text' }, default: 'main' },
1414
},
15-
parameters: { msw: { handlers: sonar.handlers } },
15+
parameters: { msw: { handlers: sonar.mockHandlers } },
1616
}
1717

1818
export const MockedSuccess = {};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<script setup>
2+
import { TokenConnectionForm } from '@creedengo/vue-ui'
3+
import core from '@creedengo/core-services';
4+
5+
const [, authenticator] = core.api.services.authenticators;
6+
const onSuccess = () => this.$router.push('/projects')
7+
</script>
8+
9+
<template>
10+
<h2>Sonar Connection</h2>
11+
<TokenConnectionForm
12+
:authenticator="authenticator"
13+
:callback="onSuccess"
14+
/>
15+
</template>

apps/vue-app/src/components/pages/DashboardPage.stories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
projectKey: { control: { type: 'text' }, default: 'my-project' },
1313
branch: { control: { type: 'text' }, default: 'main' },
1414
},
15-
parameters: { msw: { handlers: sonar.handlers } },
15+
parameters: { msw: { handlers: sonar.mockHandlers } },
1616
}
1717

1818
export const MockedSuccess = {};

apps/vue-app/src/components/pages/DashboardPage.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
import { onMounted, reactive } from 'vue';
33
44
import { AbcdeScore } from '@creedengo/vue-ui'
5-
import SonarAPI from '@creedengo/sonar-services'
65
import core from '@creedengo/core-services';
76
8-
const { api, calculateProjectScore } = core;
7+
const { calculateProjectScore } = core;
98
10-
api.init(SonarAPI)
119
const props = defineProps({
1210
project: {
1311
type: String,
@@ -39,10 +37,10 @@ onMounted(async () => {
3937
<main>
4038
<div class="wrapper">
4139
<span v-if="!state.score">
42-
<i class="fa fa-spinner fa-spin" /> Loading score...
40+
<em>Loading score...</em>
4341
</span>
4442
<span v-else-if="state.error">
45-
<i class="fa fa-exclamation-triangle" /> Score not available - {{ state.error }}
43+
<em>Score not available - {{ state.error }}</em>
4644
</span>
4745
<span v-else>
4846
<AbcdeScore :value="state.score" />

apps/vue-app/src/context.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// THIS LOGIC MIGHT MOVE LATER TO PARENT APPS
2+
export const isSonarPlugin = Boolean(globalThis.SonarRequest)
3+
export const isWebExtension = (globalThis.chrome || globalThis?.browser?.action?.setTitle)
4+
export const isWebsite = !isSonarPlugin && !isWebExtension

apps/vue-app/src/main.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@ import './assets/main.css'
22

33
import { createApp } from 'vue'
44
import App from './App.vue'
5+
//import router from './router'
6+
7+
import core from '@creedengo/core-services'
8+
import SonarApi from '@creedengo/sonar-services'
9+
10+
core.api.init(SonarApi)
511

612
// MOCK
713
if (globalThis?.process.env.NODE_ENV === 'development') {
814
const { worker } = await import('./api/mocks/browser')
915
await worker.start()
1016
}
1117

12-
createApp(App).mount('#app')
18+
createApp(App)
19+
//.use(router)
20+
.mount('#app')

0 commit comments

Comments
 (0)