Skip to content

Commit

Permalink
revert startUrl input formatting change (#4283)
Browse files Browse the repository at this point in the history
  • Loading branch information
Will-ShaoHua authored Apr 15, 2024
1 parent afd3842 commit 56b671b
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,12 @@ class WebviewBrowser(val project: Project) {

val profileName = lastLoginIdcInfo.profileName
val startUrl = lastLoginIdcInfo.startUrl
val directoryId = extractDirectoryIdFromStartUrl(startUrl)
val region = lastLoginIdcInfo.region

jcefBrowser.cefBrowser.executeJavaScript(
"window.ideClient.updateLastLoginIdcInfo({" +
"profileName: \"$profileName\"," +
"directoryId: \"$directoryId\"," +
"startUrl: \"$startUrl\"," +
"region: \"$region\"})",
jcefBrowser.cefBrowser.url,
0
Expand Down Expand Up @@ -258,11 +257,6 @@ class WebviewBrowser(val project: Project) {
else -> ""
}

private fun extractDirectoryIdFromStartUrl(startUrl: String): String {
val pattern = "https://(.*?).awsapps.com/start.*".toRegex()
return pattern.matchEntire(startUrl)?.groupValues?.get(1).orEmpty()
}

fun component(): JComponent? = jcefBrowser.component

private suspend fun <T> pollFor(func: () -> T): T? {
Expand Down
2 changes: 1 addition & 1 deletion plugins/core/webview/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface Region {

export interface IdcInfo {
profileName: string,
directoryId: string,
startUrl: string,
region: string,
}

Expand Down
27 changes: 8 additions & 19 deletions plugins/core/webview/src/q-ui/components/ssoLoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@
<div>
<div class="title no-bold">Start URL</div>
<div class="hint">URL for your organization, provided by an admin or help desk</div>
<div class="url-part">https://</div>
<input
class="url-input font-amazon url-part"
type="text"
id="startUrl"
name="startUrl"
v-model="directoryId"
v-model="startUrl"
@change="handleUrlInput"
tabindex="0"
spellcheck="false"
/>
<div class="url-part">.awsapps.com/start</div>
</div>
<br/>
<div>
Expand Down Expand Up @@ -93,14 +91,14 @@ export default defineComponent({
})
}
},
directoryId: {
startUrl: {
get() {
return this.$store.state.lastLoginIdcInfo.directoryId;
return this.$store.state.lastLoginIdcInfo.startUrl;
},
set(value: string) {
window.ideClient.updateLastLoginIdcInfo({
...this.$store.state.lastLoginIdcInfo,
directoryId: value
startUrl: value
})
}
},
Expand All @@ -117,24 +115,23 @@ export default defineComponent({
},
isInputValid: {
get() {
return this.directoryId != "" && this.selectedRegion != ""
return this.startUrl != "" && this.selectedRegion != ""
},
set() {}
}
},
methods: {
handleUrlInput() {
this.isInputValid = this.directoryId != "" && this.selectedRegion != "";
this.isInputValid = this.startUrl != "" && this.selectedRegion != "";
},
handleBackButtonClick() {
this.$emit('backToMenu')
},
async handleContinueClick() {
if (!this.isInputValid) return
const startUrl = "https://" + this.directoryId + ".awsapps.com/start"
window.ideApi.postMessage({
command: 'loginIdC',
url: startUrl,
url: this.startUrl,
region: this.selectedRegion,
profileName: this.ssoProfile
})
Expand Down Expand Up @@ -162,14 +159,10 @@ export default defineComponent({
border-radius: 4px;
}

.sso-profile, .region-select {
.url-input, .sso-profile, .region-select {
width: 100%;
}

.url-input {
width: 29%;
}

.sso-profile, .url-input {
padding-left: 10px;
box-sizing: border-box;
Expand All @@ -180,10 +173,6 @@ export default defineComponent({
margin-right: 3px;
}

.url-part {
display: inline-block;
}

.region-select {
padding-left: 6px;
}
Expand Down
6 changes: 3 additions & 3 deletions plugins/core/webview/src/q-ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const store = createStore<State>({
authorizationCode: undefined,
lastLoginIdcInfo: {
profileName: '',
directoryId: '',
startUrl: '',
region: '',
}
},
Expand All @@ -35,7 +35,7 @@ const store = createStore<State>({
setLastLoginIdcInfo(state: State, idcInfo: IdcInfo) {
console.log('state idc info is updated')
state.lastLoginIdcInfo.profileName = idcInfo.profileName
state.lastLoginIdcInfo.directoryId = idcInfo.directoryId
state.lastLoginIdcInfo.startUrl = idcInfo.startUrl
state.lastLoginIdcInfo.region = idcInfo.region
},
reset(state: State) {
Expand All @@ -44,7 +44,7 @@ const store = createStore<State>({
state.authorizationCode = undefined
state.lastLoginIdcInfo = {
profileName: '',
directoryId: '',
startUrl: '',
region: ''
}
}
Expand Down
6 changes: 3 additions & 3 deletions plugins/core/webview/src/q-ui/toolkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const store = createStore<State>({
authorizationCode: undefined,
lastLoginIdcInfo: {
profileName: '',
directoryId: '',
startUrl: '',
region: '',
}
},
Expand All @@ -36,7 +36,7 @@ const store = createStore<State>({
setLastLoginIdcInfo(state: State, idcInfo: IdcInfo) {
console.log('state idc info is updated')
state.lastLoginIdcInfo.profileName = idcInfo.profileName
state.lastLoginIdcInfo.directoryId = idcInfo.directoryId
state.lastLoginIdcInfo.startUrl = idcInfo.startUrl
state.lastLoginIdcInfo.region = idcInfo.region
},
reset(state: State) {
Expand All @@ -45,7 +45,7 @@ const store = createStore<State>({
state.authorizationCode = undefined
state.lastLoginIdcInfo = {
profileName: '',
directoryId: '',
startUrl: '',
region: ''
}
}
Expand Down
File renamed without changes.

0 comments on commit 56b671b

Please sign in to comment.