refactor: 💡 remove dropdown for rdp type
This commit is contained in:
1 parent
f8c81a29c4
commit
36aed9588b
4 files changed
+63
-54
No files matched your search
@@ -3,21 +3,26 @@
|
||||
SPDX-License-Identifier: BUSL-1.1
|
||||
}}
|
||||
|
||||
<div class='proxy-url-container' data-test-proxy-url>
|
||||
<Hds::Dropdown @listPosition='bottom-left' as |dd|>
|
||||
<dd.ToggleButton
|
||||
@color='secondary'
|
||||
@text={{t (concat 'resources.session.proxy-url.' this.currentValue)}}
|
||||
/>
|
||||
{{#each this.dropdownOptions as |optionId|}}
|
||||
<dd.Interactive
|
||||
data-test={{concat optionId '-option'}}
|
||||
{{on 'click' (fn this.handleSelect optionId dd.close)}}
|
||||
>
|
||||
{{t (concat 'resources.session.proxy-url.' optionId)}}
|
||||
</dd.Interactive>
|
||||
{{/each}}
|
||||
</Hds::Dropdown>
|
||||
<div
|
||||
class='proxy-url-container{{if this.isRDPTarget " rdp-target"}}'
|
||||
data-test-proxy-url
|
||||
>
|
||||
{{#unless this.isRDPTarget}}
|
||||
<Hds::Dropdown @listPosition='bottom-left' as |dd|>
|
||||
<dd.ToggleButton
|
||||
@color='secondary'
|
||||
@text={{t (concat 'resources.session.proxy-url.' this.currentValue)}}
|
||||
/>
|
||||
{{#each this.dropdownOptions as |optionId|}}
|
||||
<dd.Interactive
|
||||
data-test={{concat optionId '-option'}}
|
||||
{{on 'click' (fn this.handleSelect optionId dd.close)}}
|
||||
>
|
||||
{{t (concat 'resources.session.proxy-url.' optionId)}}
|
||||
</dd.Interactive>
|
||||
{{/each}}
|
||||
</Hds::Dropdown>
|
||||
{{/unless}}
|
||||
|
||||
{{#let this.copySnippetData as |snippet|}}
|
||||
{{#if snippet}}
|
||||
|
||||
@@ -8,12 +8,13 @@ import { tracked } from '@glimmer/tracking';
|
||||
import { action } from '@ember/object';
|
||||
import { service } from '@ember/service';
|
||||
import {
|
||||
TYPE_TARGET_RDP,
|
||||
TYPE_TARGET_SSH,
|
||||
TYPE_TARGET_TCP,
|
||||
TYPE_TARGET_RDP,
|
||||
} from 'api/models/target';
|
||||
|
||||
const ADDRESS_PORT = 'address-port';
|
||||
const DROPDOWN_OPTIONS = [ADDRESS_PORT, TYPE_TARGET_SSH];
|
||||
|
||||
export default class SessionProxyUrlComponent extends Component {
|
||||
// =services
|
||||
@@ -24,6 +25,10 @@ export default class SessionProxyUrlComponent extends Component {
|
||||
|
||||
@tracked selectedValue = null;
|
||||
|
||||
get isRDPTarget() {
|
||||
return this.args.targetType === TYPE_TARGET_RDP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current value to be displayed in the dropdown.
|
||||
* If a value is selected, it returns that value.
|
||||
@@ -43,38 +48,23 @@ export default class SessionProxyUrlComponent extends Component {
|
||||
*/
|
||||
get copySnippetData() {
|
||||
const { proxyAddress, proxyPort } = this.args;
|
||||
switch (this.currentValue) {
|
||||
case ADDRESS_PORT:
|
||||
return {
|
||||
address: proxyAddress,
|
||||
port: proxyPort,
|
||||
};
|
||||
case TYPE_TARGET_SSH:
|
||||
return {
|
||||
address: `ssh ${proxyAddress} -p ${proxyPort}`,
|
||||
};
|
||||
case TYPE_TARGET_RDP:
|
||||
// TODO: This is a just a placeholder. Update this based on the design and product requirements.
|
||||
return {
|
||||
address: `rdp ${proxyAddress} -p ${proxyPort}`,
|
||||
};
|
||||
default:
|
||||
return null;
|
||||
if (this.currentValue === TYPE_TARGET_SSH) {
|
||||
return {
|
||||
address: `ssh ${proxyAddress} -p ${proxyPort}`,
|
||||
};
|
||||
}
|
||||
// For TCP and RDP, we return the address and port
|
||||
return {
|
||||
address: proxyAddress,
|
||||
port: proxyPort,
|
||||
};
|
||||
}
|
||||
|
||||
/** Returns the dropdown options based on the target type.
|
||||
/**
|
||||
* Only show AddressPort and SSH options. We do not show RDP here
|
||||
*/
|
||||
get dropdownOptions() {
|
||||
let options = [ADDRESS_PORT];
|
||||
|
||||
options.push(
|
||||
this.args.targetType === TYPE_TARGET_RDP
|
||||
? TYPE_TARGET_RDP
|
||||
: TYPE_TARGET_SSH,
|
||||
);
|
||||
|
||||
return options;
|
||||
return DROPDOWN_OPTIONS;
|
||||
}
|
||||
|
||||
// =actions
|
||||
|
||||
@@ -302,6 +302,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
.proxy-url-container.rdp-target {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
// Credentials Panel
|
||||
.credential-panel-header {
|
||||
display: flex;
|
||||
|
||||
Reference in new issue
Block a user