-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
2,421 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
app/components/dynamic-scan/drawer/proxy-settings-view/index.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{{#if this.proxy.hasProxyUrl}} | ||
<AkStack | ||
local-class='bordered-box' | ||
data-test-proxySettingsView-container | ||
@direction='column' | ||
@spacing='1.5' | ||
> | ||
<AkStack @width='full' @justifyContent='space-between'> | ||
<AkStack @width='full' @direction='column' @spacing='0.5'> | ||
<AkTypography | ||
data-test-proxySettingsView-enableApiProxyLabel | ||
for='enable-api-proxy' | ||
@tag='label' | ||
@variant='h6' | ||
> | ||
{{t 'enable'}} | ||
{{t 'proxySettingsTitle'}} | ||
</AkTypography> | ||
|
||
<AkToggle | ||
local-class='api-proxy-toggle' | ||
@id='enable-api-proxy' | ||
@checked={{this.proxy.enabled}} | ||
@onChange={{perform this.toggleProxy}} | ||
@disabled={{this.toggleProxy.isRunning}} | ||
@size='small' | ||
data-test-proxySettingsView-enableApiProxyToggle | ||
/> | ||
</AkStack> | ||
|
||
<AkLink | ||
@route='authenticated.dashboard.project.settings' | ||
@model={{this.projectId}} | ||
@color='primary' | ||
@underline='always' | ||
title={{t 'proxyEdit'}} | ||
data-test-proxySettingsView-editSettings | ||
> | ||
{{t 'edit'}} | ||
</AkLink> | ||
</AkStack> | ||
|
||
<AkTypography | ||
@color='textSecondary' | ||
data-test-proxySettingsView-proxySettingRoute | ||
> | ||
{{t 'proxySettingsRouteVia'}} | ||
{{this.proxy.host}}:{{this.proxy.port}} | ||
</AkTypography> | ||
</AkStack> | ||
{{/if}} |
10 changes: 10 additions & 0 deletions
10
app/components/dynamic-scan/drawer/proxy-settings-view/index.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.bordered-box { | ||
border: 1px solid var(--dynamic-scan-drawer-proxy-settings-view-border-color); | ||
padding: 1.25em; | ||
box-sizing: border-box; | ||
} | ||
|
||
.api-proxy-toggle { | ||
margin-left: 0; | ||
margin-right: 0; | ||
} |
95 changes: 95 additions & 0 deletions
95
app/components/dynamic-scan/drawer/proxy-settings-view/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import Component from '@glimmer/component'; | ||
import ENV from 'irene/config/environment'; | ||
import triggerAnalytics from 'irene/utils/trigger-analytics'; | ||
import { inject as service } from '@ember/service'; | ||
import { task } from 'ember-concurrency'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import type IntlService from 'ember-intl/services/intl'; | ||
import type Store from '@ember-data/store'; | ||
import type { AsyncBelongsTo } from '@ember-data/model'; | ||
|
||
import type ProxySettingModel from 'irene/models/proxy-setting'; | ||
import type ProfileModel from 'irene/models/profile'; | ||
import type ProjectModel from 'irene/models/project'; | ||
|
||
export interface DynamicScanDrawerProxySettingsViewSignature { | ||
Args: { | ||
profile: AsyncBelongsTo<ProfileModel>; | ||
project: AsyncBelongsTo<ProjectModel>; | ||
}; | ||
} | ||
|
||
export default class DynamicScanDrawerProxySettingsViewComponent extends Component<DynamicScanDrawerProxySettingsViewSignature> { | ||
@service declare intl: IntlService; | ||
@service('notifications') declare notify: NotificationService; | ||
@service declare store: Store; | ||
|
||
@tracked proxy?: ProxySettingModel; | ||
|
||
constructor( | ||
owner: unknown, | ||
args: DynamicScanDrawerProxySettingsViewSignature['Args'] | ||
) { | ||
super(owner, args); | ||
|
||
this.fetchProxySetting.perform(); | ||
} | ||
|
||
get projectId() { | ||
return this.args.project.get('id'); | ||
} | ||
|
||
fetchProxySetting = task(async () => { | ||
const profileId = this.args.profile.get('id'); | ||
|
||
if (profileId) { | ||
this.proxy = await this.store.findRecord('proxy-setting', profileId); | ||
} | ||
}); | ||
|
||
/* Proxy enable or disable */ | ||
toggleProxy = task(async (event) => { | ||
try { | ||
const enabled = event.target.checked; | ||
|
||
this.proxy?.set('enabled', enabled); | ||
|
||
await this.proxy?.save(); | ||
|
||
const statusText = enabled ? this.intl.t('on') : this.intl.t('off'); | ||
|
||
this.notify.info( | ||
`${this.intl.t('proxyTurned')} ${statusText.toUpperCase()}` | ||
); | ||
|
||
if (enabled) { | ||
triggerAnalytics( | ||
'feature', | ||
ENV.csb['enableProxy'] as CsbAnalyticsFeatureData | ||
); | ||
} else { | ||
triggerAnalytics( | ||
'feature', | ||
ENV.csb['disableProxy'] as CsbAnalyticsFeatureData | ||
); | ||
} | ||
} catch (error) { | ||
const err = error as AdapterError; | ||
let errMsg = this.intl.t('plaseTryAgain'); | ||
|
||
if (err.errors && err.errors.length) { | ||
errMsg = err.errors[0]?.detail || errMsg; | ||
} else if (err.message) { | ||
errMsg = err.message; | ||
} | ||
|
||
this.notify.error(errMsg); | ||
} | ||
}); | ||
} | ||
|
||
declare module '@glint/environment-ember-loose/registry' { | ||
export default interface Registry { | ||
'DynamicScan::Drawer::ProxySettingsView': typeof DynamicScanDrawerProxySettingsViewComponent; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.extend-time-btn { | ||
border-radius: 50%; | ||
background-color: var( | ||
--dynamic-scan-action-expiry-extend-btn-background | ||
) !important; | ||
padding: 0 !important; | ||
|
||
:global(.ak-icon) { | ||
color: var(--dynamic-scan-action-expiry-extend-btn-icon-color) !important; | ||
} | ||
} | ||
|
||
.dynamic-scan-expiry-container { | ||
background-color: var( | ||
--dynamic-scan-action-expiry-container-background-color | ||
); | ||
padding: 0.3em 1em; | ||
border-radius: 200px; | ||
} | ||
|
||
.info-btn { | ||
border-radius: 50%; | ||
margin-right: 0.5em; | ||
} |
Oops, something went wrong.