-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[My Site Migration] Identity Linking step2,3 page (#967)
* resolve merge commits * feat: add get started page * remove: unused auth url * fix: css for get started on identity page * feat: add identity page behind feature flag * feat: setp1 page in identity linking * remove: unused redirect-auth util * Remove .DS_Store files from repository * feat: add varaible css * feat: add varaible css * feat: add step2 on identity linking page * feat: add step2 and step3 page * feat: add reload step * feat: add varaible css
- Loading branch information
Showing
9 changed files
with
221 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div class='identity-box-heading' data-test-reload-heading>Status Pending</div> | ||
<div class='identity-box-desc' data-test-reload-desc>Reload to complete and | ||
verify the link between Profile Service and RealDevSquad Service.</div> | ||
<button | ||
class='identity-box-button' type="button" {{on 'click' this.handleReload}} | ||
>Reload</button> |
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,9 @@ | ||
import Component from '@glimmer/component'; | ||
import { action } from '@ember/object'; | ||
|
||
export default class ReloadComponent extends Component { | ||
@action async handleReload(e) { | ||
e.preventDefault(); | ||
window.location.reload(); | ||
} | ||
} |
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,21 @@ | ||
<div class='identity-box-heading' data-test-step2-heading>Step 2: Profile | ||
Service URL</div> | ||
<div class='identity-box-desc' data-test-step2-desc>Set the chaincode on your | ||
profile service, deploy it and enter your profile service URL.</div> | ||
<label class="identity-box-input-label"> | ||
<Input | ||
@value={{this.profileURL}} | ||
class='identity-box-input' | ||
placeholder='E.g.: https://my-profile-service.com' | ||
data-test-step2-input | ||
/> | ||
</label> | ||
{{#if this.profileURL}} | ||
<button | ||
class='identity-next-button' | ||
data-test-step2-next-button | ||
type='button' | ||
{{on 'click' this.handleNext}} | ||
> | ||
{{#if this.savingURL}}<div class='loader'></div>{{else}}Next{{/if}}</button> | ||
{{/if}} |
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,73 @@ | ||
import Component from '@glimmer/component'; | ||
import { action } from '@ember/object'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { inject as service } from '@ember/service'; | ||
import { toastNotificationTimeoutOptions } from '../../constants/toast-notification'; | ||
import { APPS } from '../../constants/urls'; | ||
|
||
const BASE_URL = APPS.API_BACKEND; | ||
|
||
export default class Step2Component extends Component { | ||
@tracked profileURL = this.args.profileURL || ''; | ||
@tracked savingURL = false; | ||
@service toast; | ||
|
||
@action async handleNext() { | ||
const isValidUrl = (str) => { | ||
try { | ||
const newUrl = new URL(str); | ||
return newUrl.protocol === 'https:'; | ||
} catch (err) { | ||
return false; | ||
} | ||
}; | ||
if (this.profileURL) { | ||
if (isValidUrl(this.profileURL)) { | ||
if (this.savingURL === false) { | ||
if (this.profileURL === this.args.profileURL) { | ||
this.args.setState('step3'); | ||
return; | ||
} | ||
this.savingURL = true; | ||
try { | ||
const response = await fetch(`${BASE_URL}/users/profileURL`, { | ||
method: 'PATCH', | ||
body: JSON.stringify({ profileURL: this.profileURL }), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
credentials: 'include', | ||
}); | ||
if (response.ok) { | ||
this.toast.info( | ||
'Updated profile URL!!', | ||
'', | ||
toastNotificationTimeoutOptions, | ||
); | ||
this.args.setState('step3'); | ||
} else { | ||
this.toast.error( | ||
'Something went wrong. Please check console errors.', | ||
'', | ||
toastNotificationTimeoutOptions, | ||
); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
this.toast.error( | ||
'Something went wrong. Please check console errors.', | ||
'', | ||
toastNotificationTimeoutOptions, | ||
); | ||
} finally { | ||
this.savingURL = false; | ||
} | ||
} | ||
} else { | ||
alert( | ||
'Invalid URL! Make sure you entered the correct https profile URL.', | ||
); | ||
} | ||
} | ||
} | ||
} |
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,13 @@ | ||
<div class='identity-box-heading' data-test-step3-heading>Step 3: Link Profile | ||
Service</div> | ||
<div class='identity-box-desc' data-test-step3-desc>Ensure that you have | ||
deployed your profile service URL and after that link with the RealDevSquad | ||
service.</div> | ||
<button | ||
class='identity-box-button' | ||
data-test-step3-button | ||
type='button' | ||
{{on 'click' this.handleLink}} | ||
>{{#if this.linking}} <div class='loader'></div>{{else}} | ||
Link | ||
{{/if}}</button> |
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,57 @@ | ||
import Component from '@glimmer/component'; | ||
import { action } from '@ember/object'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { inject as service } from '@ember/service'; | ||
import { toastNotificationTimeoutOptions } from '../../constants/toast-notification'; | ||
import { APPS } from '../../constants/urls'; | ||
|
||
const BASE_URL = APPS.API_BACKEND; | ||
|
||
export default class Step3Component extends Component { | ||
@tracked linking = false; | ||
@service toast; | ||
|
||
@action async handleLink(e) { | ||
e.preventDefault(); | ||
if ( | ||
this.linking === false && | ||
confirm( | ||
'Make sure to set the chaincode and re-deploy your profile service before linking.', | ||
) | ||
) { | ||
this.linking = true; | ||
try { | ||
const response = await fetch(`${BASE_URL}/users/verify`, { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
credentials: 'include', | ||
}); | ||
|
||
if (response.ok) { | ||
this.toast.info( | ||
'Your linking request has been queued successfully', | ||
'', | ||
toastNotificationTimeoutOptions, | ||
); | ||
this.args.setState('reload'); | ||
} else { | ||
this.toast.error( | ||
'Something went wrong. Please check console errors.', | ||
'', | ||
toastNotificationTimeoutOptions, | ||
); | ||
} | ||
} catch (error) { | ||
this.toast.error( | ||
'Something went wrong. Please check console errors.', | ||
'', | ||
toastNotificationTimeoutOptions, | ||
); | ||
} finally { | ||
this.linking = false; | ||
} | ||
} | ||
} | ||
} |
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