Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
--wip-- [skip ci]
Browse files Browse the repository at this point in the history
Yibaebi committed Sep 27, 2024

Verified

This commit was signed with the committer’s verified signature.
joshcooper Josh Cooper
1 parent 913f250 commit 00b8e8d
Showing 39 changed files with 2,421 additions and 157 deletions.
Original file line number Diff line number Diff line change
@@ -4,20 +4,35 @@
@project={{@file.project}}
as |dpContext|
>
<AkModal
<AkDrawer
data-test-cy='dynamicScanModal'
@showHeader={{true}}
@headerTitle={{t 'modalCard.dynamicScan.title'}}
@open={{true}}
@onClose={{@onClose}}
@disableClose={{or
this.startDynamicScan.isRunning
this.scheduleDynamicScan.isRunning
}}
@anchor='right'
as |dr|
>
<:default>
<div local-class='dynamic-scan-modal-body' class='p-1'>
<AkStack @direction='column' {{style width='600px' height='100%'}}>
<AkAppbar
@position='sticky'
@justifyContent='space-between'
class='px-3'
as |ab|
>
<AkTypography @color='inherit' @variant='h5' @fontWeight='medium'>
{{t 'modalCard.dynamicScan.title'}}
</AkTypography>

<AkIconButton
{{on 'click' dr.closeHandler}}
class={{ab.classes.defaultIconBtn}}
>
<AkIcon @iconName='close' />
</AkIconButton>
</AkAppbar>

<div class='p-3 mb-6'>
<AkStack
local-class='dynamic-scan-modal-alert'
local-class='dynamic-scan-drawer-alert'
class='p-2'
@alignItems='center'
@spacing='2'
@@ -92,7 +107,7 @@
{{/unless}}

<div class='mt-4'>
<ProxySettingsView
<DynamicScan::Drawer::ProxySettingsView
@profile={{@file.profile}}
@project={{@file.project}}
/>
@@ -187,12 +202,14 @@
{{/if}}
</div>
</div>
</:default>

<:footer>
<AkDivider />

<AkStack class='px-3 py-2' @justifyContent='flex-end' @spacing='1.5'>
<AkStack
@width='full'
@justifyContent='flex-end'
@spacing='1.5'
local-class='dynamic-scan-modal-cta'
class='px-3 py-2'
>
<AkButton
data-test-dynamicScanModal-cancelBtn
@variant='outlined'
@@ -212,6 +229,6 @@
{{t 'modalCard.dynamicScan.start'}}
</AkButton>
</AkStack>
</:footer>
</AkModal>
</AkStack>
</AkDrawer>
</ProjectPreferencesOld::Provider>
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
.dynamic-scan-modal-body {
width: 650px;
}

.dynamic-scan-modal-alert {
.dynamic-scan-drawer-alert {
background-color: var(--dynamic-scan-modal-alert-background-color);
color: var(--dynamic-scan-modal-alert-text-color);
border: 1px solid var(--dynamic-scan-modal-alert-border-color);
@@ -27,3 +23,12 @@
}
}
}

.dynamic-scan-modal-cta {
z-index: 10;
position: absolute;
bottom: 0;
border-top: 1px solid var(--file-details-dynamic-scan-drawer-border-color);
background-color: var(--file-details-dynamic-scan-drawer-background-main);
box-shadow: var(--file-details-dynamic-scan-drawer-cta-box-shadow);
}
Original file line number Diff line number Diff line change
@@ -9,15 +9,15 @@ import Store from '@ember-data/store';
import { tracked } from '@glimmer/tracking';
import FileModel from 'irene/models/file';

export interface DynamicScanModalSignature {
export interface DynamicScanDrawerSignature {
Args: {
onClose: () => void;
pollDynamicStatus: () => void;
file: FileModel;
};
}

export default class DynamicScanModalComponent extends Component<DynamicScanModalSignature> {
export default class DynamicScanDrawerComponent extends Component<DynamicScanDrawerSignature> {
@service declare intl: IntlService;
@service declare ajax: any;
@service declare store: Store;
@@ -169,6 +169,6 @@ export default class DynamicScanModalComponent extends Component<DynamicScanModa

declare module '@glint/environment-ember-loose/registry' {
export default interface Registry {
'DynamicScan::Modal': typeof DynamicScanModalComponent;
'DynamicScan::Drawer': typeof DynamicScanDrawerComponent;
}
}
51 changes: 51 additions & 0 deletions app/components/dynamic-scan/drawer/proxy-settings-view/index.hbs
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 app/components/dynamic-scan/drawer/proxy-settings-view/index.scss
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 app/components/dynamic-scan/drawer/proxy-settings-view/index.ts
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;
}
}
39 changes: 34 additions & 5 deletions app/components/dynamic-scan/expiry/index.hbs
Original file line number Diff line number Diff line change
@@ -1,26 +1,51 @@
<div>
<AkStack @justifyContent='center' @alignItems='center' @spacing='1'>
<AkTypography @tag='span' @variant='h5' @fontWeight='regular'>
<AkStack
data-test-fileDetails-dynamicScan-expiry
local-class='dynamic-scan-expiry-container'
@justifyContent='center'
@alignItems='center'
@spacing='1'
>
<AkTooltip
data-test-fileDetails-dynamicScan-expiry-tooltip
@color='dark'
@placement='top'
@arrow={{true}}
@title={{t 'dynamicScanTitleTooltip'}}
>
<AkIconButton @size='small' local-class='info-btn'>
<AkIcon @iconName='info' @color='primary' />
</AkIconButton>
</AkTooltip>

<AkTypography
data-test-fileDetails-dynamicScan-expiry-time
@tag='span'
@variant='h5'
@fontWeight='regular'
>
{{this.timeRemaining.minutes}}:{{this.timeRemaining.seconds}}
</AkTypography>

{{#if this.extendtime.isRunning}}
<AkLoader @size={{16}} />
{{else}}
<AkTooltip
data-test-fileDetails-dynamicScan-expiry-extendBtn-tooltip
@disabled={{this.canExtend}}
@color='dark'
@placement='top'
@arrow={{true}}
@title={{t 'dynamicScanExtentionLimit'}}
>
<AkIconButton
data-test-fileDetails-dynamicScan-expiry-extendBtn
@size='small'
disabled={{not this.canExtend}}
@variant='outlined'
{{on 'click' this.handleExtendTimeClick}}
local-class='extend-time-btn'
>
<AkIcon @iconName='add' />
<AkIcon @size='small' @iconName='add' />
</AkIconButton>
</AkTooltip>
{{/if}}
@@ -32,7 +57,11 @@
as |akm|
>
{{#each this.extendTimeOptions as |time|}}
<akm.listItem @onClick={{perform this.extendtime time}} as |li|>
<akm.listItem
data-test-fileDetails-dynamicScan-expiry-extendTime-menu-item
@onClick={{perform this.extendtime time}}
as |li|
>
<li.text @primaryText='{{time}} mins' />
</akm.listItem>
{{/each}}
24 changes: 24 additions & 0 deletions app/components/dynamic-scan/expiry/index.scss
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;
}
Loading

0 comments on commit 00b8e8d

Please sign in to comment.