Skip to content

Commit 2b62e11

Browse files
remove some cases for codacy cloud to avoid duplication + fix theme style for secondary button + add dependencies message
1 parent e3dd78f commit 2b62e11

5 files changed

Lines changed: 52 additions & 24 deletions

File tree

package.json

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@
4444
},
4545
"views": {
4646
"codacy-main": [
47-
{
48-
"type": "webview",
49-
"id": "codacy.setupView",
50-
"name": "Setup",
51-
"when": "codacy:hasProject"
52-
},
5347
{
5448
"id": "codacy:status",
5549
"name": "Status",
@@ -61,7 +55,7 @@
6155
"id": "codacy:cloud-status",
6256
"name": "Codacy Cloud",
6357
"icon": "$(library)",
64-
"when": "codacy:hasProject && Codacy:PullRequestStateContext == NoPullRequest",
58+
"when": "codacy:hasProject && Codacy:PullRequestStateContext == NoPullRequest && Codacy:CodacyCloudStateContext != NeedsAuthentication && Codacy:CodacyCloudStateContext != NeedsToAddOrganization && Codacy:CodacyCloudStateContext != NeedsToAddRepository",
6559
"initialSize": 1,
6660
"collapsed": false
6761
},
@@ -86,6 +80,14 @@
8680
"icon": "$(bug)",
8781
"initialSize": 3
8882
},
83+
{
84+
"type": "webview",
85+
"id": "codacy.setupView",
86+
"name": "Setup",
87+
"when": "codacy:hasProject",
88+
"collapsed": false,
89+
"initialSize": 4
90+
},
8991
{
9092
"id": "codacy:support",
9193
"name": "Help and Feedback",
@@ -105,11 +107,6 @@
105107
"contents": "Codacy Cloud is initializing...",
106108
"when": "Codacy:CodacyCloudStateContext == Initializing"
107109
},
108-
{
109-
"view": "codacy:cloud-status",
110-
"contents": "You are not connected to Codacy. Connect to Codacy to customize your rules and scan every PR before it gets merged.\n[Connect to Codacy](command:codacy.codacyAuth)\n\nGet access to all features: coverage, DAST, SCA scanning, and more. [Learn more about Codacy](https://www.codacy.com/)",
111-
"when": "Codacy:CodacyCloudStateContext == NeedsAuthentication"
112-
},
113110
{
114111
"view": "codacy:cloud-status",
115112
"contents": "This project isn't a Git repository. To connect it to Codacy, initialize a Git repository first.",
@@ -130,11 +127,6 @@
130127
"contents": "An admin must approve your request to join the organization on Codacy.",
131128
"when": "Codacy:CodacyCloudStateContext == HasPendingJoinOrganization"
132129
},
133-
{
134-
"view": "codacy:cloud-status",
135-
"contents": "This organization is not part of Codacy.\n[Add organization](command:codacy.codacyAuth)",
136-
"when": "Codacy:CodacyCloudStateContext == NeedsToAddOrganization"
137-
},
138130
{
139131
"view": "codacy:cloud-status",
140132
"contents": "Ensure full protection by adding PR-level scans to this repo so that no security vulnerabilities are added.\n[Add repository to Codacy](command:codacy.addRepository)\nAdds this Git repository to Codacy with your organization default scanning rules.",

src/views/SetupView.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ export class SetupViewProvider implements vscode.WebviewViewProvider {
418418
<button id="install-cli-button">Install Codacy CLI</button>
419419
<p id="add-organization-section" style="display: none;">To customize the analysis, <button class="link-btn" id="add-organization-button">Add this organization to Codacy</button></p>
420420
<p id="add-repository-section" style="display: none;">To customize the analysis, <button class="link-btn" id="add-repository-button">Add this repository to Codacy</button></p>
421+
<p id="dependencies-description">Installs required dependencies: Node, Python, Java</p>
421422
</div>
422423
</div>
423424
</li>
@@ -447,7 +448,7 @@ export class SetupViewProvider implements vscode.WebviewViewProvider {
447448
448449
<div class="setup-item upgrade-box" id="upgrade-box">
449450
<p>Strengthen security and quality across all your repositories.</p>
450-
<a href="https://www.codacy.com/pricing" target="_blank" rel="noopener noreferrer">
451+
<a href="https://www.codacy.com/pricing" id="upgrade-button" target="_blank" rel="noopener noreferrer">
451452
<button class="secondary">Upgrade to PRO</button>
452453
</a>
453454
</div>

src/views/scripts/setupScript.js

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
return
6868
}
6969
linkNode.textContent = `${params.provider}/${params.organization}`
70-
linkNode.href = `https://app.codacy.com/${encodeURIComponent(params.provider)}/${encodeURIComponent(params.organization)}`
70+
linkNode.href = `https://app.codacy.com/organizations/${encodeURIComponent(params.provider)}/${encodeURIComponent(params.organization)}`
7171
break
7272
case 'repository':
7373
if (!params.provider || !params.organization || !params.repository) {
@@ -177,6 +177,7 @@
177177
*/
178178
function handleLoginStateChange(loggedIn, isOrgInCodacy, isRepoInCodacy, userInfo, organizationInfo, repositoryInfo) {
179179
const upgradeBox = document.getElementById('upgrade-box')
180+
const upgradeButton = document.getElementById('upgrade-button')
180181
/** @type {HTMLImageElement | null} */
181182
const cloudIcon = /** @type {HTMLImageElement | null} */ (document.getElementById('cloud-icon'))
182183
const cloudDescription = document.getElementById('cloud-description')
@@ -193,32 +194,50 @@
193194
const userName = escapeHtml(userInfo?.name)
194195
const organizationProvider = escapeHtml(organizationInfo?.provider)
195196

196-
if (upgradeBox) {
197-
upgradeBox.style.display = 'none'
198-
}
199197
if (
200198
cloudIcon &&
201199
iconUris &&
202200
cloudDescription &&
203201
connectToCodacyButton &&
204202
addOrgButton &&
205203
addRepoButton &&
206-
noOrgDescription
204+
noOrgDescription &&
205+
upgradeBox &&
206+
upgradeButton
207207
) {
208208
connectToCodacyButton.style.display = 'none'
209209
cloudIcon.src = iconUris.finished
210210
if (isOrgInCodacy && isRepoInCodacy) {
211211
addOrgButton.style.display = 'none'
212212
addRepoButton.style.display = 'none'
213213
noOrgDescription.style.display = 'none'
214+
if (organizationInfo.billing === 'premium') {
215+
upgradeBox.style.display = 'none'
216+
} else {
217+
upgradeBox.style.display = 'block'
218+
upgradeButton.setAttribute(
219+
'href',
220+
`https://app.codacy.com/organizations/${encodeURIComponent(organizationProvider)}/${encodeURIComponent(organizationName)}/settings/billing`
221+
)
222+
}
214223
setCloudDescription(cloudDescription, {
215224
type: 'repository',
216225
params: { organization: organizationName, provider: organizationProvider, repository: repositoryName },
217226
})
218227
} else if (isOrgInCodacy) {
219228
addRepoButton.style.display = 'inline-block'
229+
addOrgButton.style.display = 'none'
220230
noOrgDescription.style.display = 'none'
221231
cloudIcon.src = iconUris.warning
232+
if (organizationInfo.billing === 'premium') {
233+
upgradeBox.style.display = 'none'
234+
} else {
235+
upgradeBox.style.display = 'block'
236+
upgradeButton.setAttribute(
237+
'href',
238+
`https://app.codacy.com/organizations/${encodeURIComponent(organizationProvider)}/${encodeURIComponent(organizationName)}/settings/billing`
239+
)
240+
}
222241
setCloudDescription(cloudDescription, {
223242
type: 'organization',
224243
params: { organization: organizationName, provider: organizationProvider },
@@ -228,6 +247,8 @@
228247
noOrgDescription.style.display = 'inline-block'
229248
addRepoButton.style.display = 'none'
230249
cloudIcon.src = iconUris.warning
250+
upgradeBox.style.display = 'block'
251+
upgradeButton.setAttribute('href', 'https://www.codacy.com/pricing')
231252
setCloudDescription(cloudDescription, { type: 'user', params: { user: userName } })
232253
}
233254
}
@@ -237,11 +258,13 @@
237258
addRepoButton &&
238259
noOrgDescription &&
239260
upgradeBox &&
261+
upgradeButton &&
240262
cloudIcon &&
241263
cloudDescription &&
242264
connectToCodacyButton
243265
) {
244266
upgradeBox.style.display = 'block'
267+
upgradeButton.setAttribute('href', 'https://www.codacy.com/pricing')
245268
cloudIcon.src = iconUris.unfinished
246269
cloudDescription.textContent = 'Customize local analysis and keep your PRs up to standards in the IDE.'
247270
addOrgButton.style.display = 'none'
@@ -406,6 +429,7 @@
406429
const addRepositorySection = document.getElementById('add-repository-section')
407430
const installCliButton = document.getElementById('install-cli-button')
408431
const cliHeaderActions = document.getElementById('cli-header-actions')
432+
const dependenciesDescription = document.getElementById('dependencies-description')
409433
/** @type {IconUris | undefined} */
410434
// @ts-expect-error - iconUris is injected by the extension
411435
const iconUris = window.iconUris
@@ -422,6 +446,9 @@
422446
if (installCliButton) {
423447
installCliButton.style.display = 'none'
424448
}
449+
if (dependenciesDescription) {
450+
dependenciesDescription.style.display = 'none'
451+
}
425452
cliDescription.textContent = 'Codacy CLI installed'
426453
cliIcon.src = iconUris.finished
427454
if (addOrganizationSection && addRepositorySection) {
@@ -445,6 +472,9 @@
445472
if (installCliButton) {
446473
installCliButton.style.display = 'inline-block'
447474
}
475+
if (dependenciesDescription) {
476+
dependenciesDescription.style.display = 'inline-block'
477+
}
448478
cliDescription.textContent = 'Get instant feedback as you type by analyzing your code locally.'
449479
cliIcon.src = iconUris.unfinished
450480
}

src/views/styles/main.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ body {
5656
margin-top: 8px;
5757
}
5858

59+
#dependencies-description {
60+
margin-top: 8px;
61+
color: var(--vscode-disabledForeground);
62+
}
63+
5964
.setup-item-header {
6065
display: flex;
6166
align-items: center;

src/views/styles/vscode.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ button:focus {
6363
}
6464

6565
button.secondary {
66-
color: var(--vscode-button-foreground);
66+
color: var(--vscode-button-secondaryForeground);
6767
background: var(--vscode-button-secondaryBackground);
6868
}
6969

0 commit comments

Comments
 (0)