This repository was archived by the owner on May 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add magic link component to create a magic link that can be sen…
…t to another user
- Loading branch information
1 parent
e718679
commit 8de7442
Showing
12 changed files
with
383 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import Component from "@glimmer/component"; | ||
import { tracked } from "@glimmer/tracking"; | ||
|
||
export default class MagicLinkBtn extends Component { | ||
@tracked isModalVisible = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<button | ||
type="button" | ||
data-test-magic-link-btn | ||
title="Create a magic link" | ||
class="btn btn-default" | ||
{{on "click" (toggle "isModalVisible" this)}} | ||
> | ||
<FaIcon @icon="magic" @prefix="fas" /> | ||
</button> | ||
|
||
{{#if this.isModalVisible}} | ||
<MagicLinkModal @isVisible={{this.isModalVisible}} @onClose={{toggle "isModalVisible" this}} /> | ||
{{/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,46 @@ | ||
import { action } from "@ember/object"; | ||
import { inject as service } from "@ember/service"; | ||
import Component from "@glimmer/component"; | ||
import { tracked } from "@glimmer/tracking"; | ||
|
||
export default class MagicLinkModal extends Component { | ||
@tracked task; | ||
@tracked duration; | ||
@tracked comment; | ||
@tracked review; | ||
@tracked notBillable; | ||
@tracked statusMsg; | ||
@tracked errorMsg; | ||
|
||
@service router; | ||
|
||
@action | ||
onSetTask(task) { | ||
this.task = task; | ||
} | ||
|
||
get magicLinkString() { | ||
const url = this.router.urlFor("index.reports", { | ||
queryParams: { | ||
task: this.task?.id, | ||
comment: this.comment, | ||
duration: this.duration, | ||
review: this.review, | ||
notBillable: this.notBillable, | ||
}, | ||
}); | ||
|
||
return `${window.location.origin}${url}`; | ||
} | ||
|
||
@action | ||
copyToClipboard() { | ||
try { | ||
navigator.clipboard.writeText(this.magicLinkString); | ||
this.statusMsg = | ||
"Magic link copied to clipboard. You can now send it to a friendly coworker!"; | ||
} catch { | ||
this.errorMsg = "Could not copy to clipboard"; | ||
} | ||
} | ||
} |
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,118 @@ | ||
<SyModal | ||
@size="auto" | ||
@visible={{@isVisible}} | ||
@onClose={{@onClose}} | ||
data-test-magic-link-modal | ||
as |modal| | ||
> | ||
<div | ||
class="magic-link-modal" | ||
data-test-magic-link-form | ||
> | ||
<modal.header> | ||
Create a magic link | ||
</modal.header> | ||
<modal.body> | ||
<div data-test-task-selector> | ||
<TaskSelection | ||
@disabled={{false}} | ||
@task={{this.task}} | ||
@on-set-task={{this.onSetTask}} | ||
as |t| | ||
> | ||
<div | ||
class="form-list-cell form-group" | ||
>{{t.customer}}</div> | ||
<div | ||
class="form-list-cell form-group" | ||
>{{t.project}}</div> | ||
<div | ||
class="form-list-cell form-group" | ||
>{{t.task}}</div> | ||
</TaskSelection> | ||
</div> | ||
|
||
<div class="margin-medium-bottom"> | ||
<Input | ||
@value={{this.comment}} | ||
class="ember-text-field form-control" | ||
placeholder="Comment" | ||
aria-label="Comment for the timed entry" | ||
data-test-magic-link-comment | ||
/> | ||
</div> | ||
|
||
<div class="margin-medium-bottom"> | ||
<div class="flex"> | ||
<SyDurationpickerDay | ||
@disabled={{false}} | ||
@value={{this.duration}} | ||
@onChange={{fn (mut this.duration)}} | ||
@title="Task duration" | ||
data-test-magic-link-duration | ||
class="flex-grow" | ||
/> | ||
<SyToggle | ||
class="margin-small-right form-control flex-shrink" | ||
data-test-magic-link-review | ||
@hint="Needs review" | ||
@onToggle={{toggle "review" this}} | ||
@value={{this.review}} | ||
> | ||
<span class="fa-layers fa-fw"> | ||
<FaIcon @icon="user" /> | ||
<FaIcon | ||
@icon="question" | ||
@prefix="fas" | ||
@transform="shrink-6 up-7 right-8" | ||
/> | ||
</span> | ||
</SyToggle> | ||
<SyToggle | ||
class="form-control flex-shrink" | ||
data-test-magic-link-not-billable | ||
@hint="Not billable" | ||
@onToggle={{toggle "notBillable" this}} | ||
@value={{this.notBillable}} | ||
> | ||
<span class="fa-layers fa-fw"> | ||
<FaIcon @icon="dollar-sign" @prefix="fas" /> | ||
<FaIcon @icon="slash" @prefix="fas" /> | ||
</span> | ||
</SyToggle> | ||
</div> | ||
</div> | ||
|
||
<div class="flex"> | ||
<Input | ||
@value={{this.magicLinkString}} | ||
disabled={{true}} | ||
class="flex-grow form-control" | ||
aria-label="magic link string" | ||
data-test-magic-link-string | ||
/> | ||
</div> | ||
{{#if this.statusMsg}} | ||
<div class="alert alert-success margin-medium-top"> | ||
{{this.statusMsg}} | ||
</div> | ||
{{/if}} | ||
{{#if this.errorMsg}} | ||
<div class="alert alert-warning margin-medium-top"> | ||
{{this.errorMsg}} | ||
</div> | ||
{{/if}} | ||
</modal.body> | ||
<modal.footer> | ||
<button | ||
class="btn btn-default margin-small-left" | ||
{{on "click" this.copyToClipboard}} | ||
disabled={{not this.magicLinkString}} | ||
type="button" | ||
data-test-create-magic-link-btn | ||
> | ||
Copy to clippy | ||
</button> | ||
</modal.footer> | ||
</div> | ||
</SyModal> |
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
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,7 @@ | ||
.ember-basic-dropdown-content { | ||
z-index: 1002; | ||
} | ||
|
||
.magic-link-modal { | ||
min-width: 500px; | ||
} |
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 |
---|---|---|
|
@@ -44,6 +44,7 @@ module.exports = function () { | |
"plus", | ||
"users", | ||
"question", | ||
"magic", | ||
], | ||
}; | ||
}; |
Oops, something went wrong.