-
Notifications
You must be signed in to change notification settings - Fork 1
feat: #quickwin #162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat: #quickwin #162
Changes from 16 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
9824b0f
feat: First draft
HazAT 89d6e21
Store tagged messages
HazAT 0be61b3
revert gitkeep
HazAT 7f8fe25
Models
HazAT 8116f0a
Add migration
HazAT b991829
Posting message to channel
HazAT 812b801
Refactor TagsController to include reaction count for tagged messages
HazAT 5df650f
Add user avatars to Quickwins.vue and replace user IDs with user name…
HazAT f103f66
Added formatted message
HazAT 94528c1
Update MAX_AMOUNT constant value in Message entity
HazAT bb6a2a6
csfix
HazAT d7b7829
Add top note
HazAT 89d1adf
Add linking
HazAT 2d8fa44
Show modal
HazAT 978da4b
Add potato explosion
HazAT ef87408
Remove comment
HazAT b9f3687
Apply suggestions from code review
HazAT 4ef740d
fix endpoint
HazAT 3e23b69
Merge branch 'main' into feat/quick-win
cleptric ca686d9
Fix merge conflicts
cleptric 5b49cc7
Warp up
cleptric a5b476e
Rename Quickwins.vue to QuickWins.vue
cleptric aa97014
Fix QuickWins controller
cleptric 38d1dfe
Cleanup FormattedMessage.vue
cleptric 61e7d32
CS
cleptric File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,92 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
use Migrations\AbstractMigration; | ||
|
||
class TaggedMessages extends AbstractMigration | ||
{ | ||
/** | ||
* Up Method. | ||
* | ||
* More information on this method is available here: | ||
* https://book.cakephp.org/phinx/0/en/migrations.html#the-up-method | ||
* | ||
* @return void | ||
*/ | ||
public function up(): void | ||
{ | ||
$this->table('tagged_messages', ['id' => false, 'primary_key' => ['id']]) | ||
->addColumn('id', 'uuid', [ | ||
'default' => null, | ||
'limit' => null, | ||
'null' => false, | ||
]) | ||
->addColumn('message', 'string', [ | ||
'default' => null, | ||
'limit' => 4096, | ||
'null' => false, | ||
]) | ||
->addColumn('permalink', 'string', [ | ||
'default' => null, | ||
'limit' => 255, | ||
'null' => false, | ||
]) | ||
->addColumn('sender_user_id', 'uuid', [ | ||
'default' => null, | ||
'limit' => null, | ||
'null' => false, | ||
]) | ||
->addColumn('created', 'datetime', [ | ||
'default' => null, | ||
'limit' => null, | ||
'null' => true, | ||
]) | ||
->addIndex( | ||
[ | ||
'sender_user_id', | ||
] | ||
) | ||
->addIndex( | ||
[ | ||
'receiver_user_id', | ||
] | ||
) | ||
->addIndex( | ||
[ | ||
'permalink', | ||
] | ||
) | ||
->create(); | ||
|
||
$this->table('messages') | ||
->addColumn('permalink', 'string', [ | ||
'default' => null, | ||
'limit' => 255, | ||
'null' => false, | ||
]) | ||
->addIndex( | ||
[ | ||
'permalink', | ||
] | ||
) | ||
->update(); | ||
} | ||
cleptric marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* Down Method. | ||
* | ||
* More information on this method is available here: | ||
* https://book.cakephp.org/phinx/0/en/migrations.html#the-down-method | ||
* | ||
* @return void | ||
*/ | ||
public function down(): void | ||
{ | ||
$this->table('tagged_messages')->drop()->save(); | ||
|
||
$this->table('messages') | ||
->removeIndexByName('permalink') | ||
->removeColumn('permalink') | ||
->update(); | ||
} | ||
} |
This file contains hidden or 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 hidden or 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,19 @@ | ||
<template> | ||
<p class="text-sm font-normal py-2.5 text-gray-900 dark:text-white" v-html="formattedMessage"> | ||
|
||
</p> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
props: ['message'], | ||
computed: { | ||
formattedMessage() { | ||
return this.message | ||
.replace(/<(@[^>]+)>/g, (_match, p1) => `<span class="bg-blue-700 p-0.5 px-1 rounded-lg">${p1}</span>`) | ||
.replace(/ (\w+) <(http[^>]+)>/g, (_match, p1, p2) => ` <a class="underline" href="${p2}">${p1}</a> `) | ||
.replace(/:potato:/g, '🥔'); | ||
}, | ||
}, | ||
} | ||
</script> |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,141 @@ | ||
<template> | ||
<div class="bg-gray-700 mb-8 mx-20 border-t border-b text-white px-4 py-3" role="alert"> | ||
<p class="font-bold">How to?</p> | ||
<p class="text-sm">Write a message in Slack - if it contains <span class="bg-blue-700 p-0.5 px-1 rounded-lg">#quickwin</span> and a 🥔 emoji it will be captured here.</p> | ||
</div> | ||
<div | ||
v-if="taggedMessages.length" | ||
class="grid grid-cols-1 gap-y-12 sm:grid-cols-2 sm:gap-x-6 lg:grid-cols-4 xl:gap-x-8 mb-32" | ||
> | ||
|
||
<div | ||
v-for="(item, index) in taggedMessages" | ||
class="h-full flex flex-col" | ||
> | ||
<div | ||
:index="index" | ||
class="relative" | ||
> | ||
<div class="flex items-start gap-2.5"> | ||
<img class="w-8 h-8 rounded-full" :src="item.user.slack_picture" :alt="item.user.slack_name"> | ||
<div class="flex flex-col w-full max-w-[320px] leading-1.5 p-4 border-gray-200 bg-gray-100 rounded-e-xl rounded-es-xl dark:bg-gray-700"> | ||
<div class="flex items-center space-x-2 rtl:space-x-reverse"> | ||
<span class="text-sm font-semibold text-gray-900 dark:text-white">{{item.user.slack_name}}</span> | ||
<span class="text-sm font-normal text-gray-500 dark:text-gray-400">{{ new Date(item.created).toLocaleDateString('en-us', { year:"numeric", month:"short", day:"numeric"}) }}</span> | ||
</div> | ||
<FormattedMessage :message="item.message" /> | ||
<span v-if="item.reaction_count >= 2" class="relative text-sm font-normal text-gray-500 dark:text-gray-400"> | ||
<span v-for="(i, index2) in item.reaction_count" :key="i" :class="index2 === 0 ? '' : '-ml-2'">🥔</span> | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div | ||
v-else | ||
class="absolute inset-0 flex items-center justify-center" | ||
> | ||
<h1 class="text-2xl font-extrabold"> | ||
No #quickwins recorded yet | ||
</h1> | ||
</div> | ||
<div v-if="modalOpen === true" class="relative z-10"> | ||
<div class="fixed inset-0 bg-zinc-700 bg-opacity-75"></div> | ||
|
||
<div class="fixed inset-0 z-20 overflow-y-auto"> | ||
<div class="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0"> | ||
<div class="relative transform overflow-hidden rounded-lg bg-zinc-50 dark:bg-zinc-900 px-4 pt-5 pb-4 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-sm sm:p-6"> | ||
<div class="relative"> | ||
<div class="relative mt-4"> | ||
<div class="flex items-center space-x-2 rtl:space-x-reverse"> | ||
<span class="text-sm font-semibold text-gray-900 dark:text-white">{{modelData.user.slack_name}}</span> | ||
<span class="text-sm font-normal text-gray-500 dark:text-gray-400">{{ new Date(modelData.created).toLocaleDateString('en-us', { year:"numeric", month:"short", day:"numeric"}) }}</span> | ||
</div> | ||
<FormattedMessage :message="modelData.message" /> | ||
<button | ||
class="mt-2 cursor-pointer inline-flex w-full justify-center rounded-md border border-zinc-300 bg-zinc-100 px-4 py-2 text-base font-medium text-zinc-900 sm:mt-0 sm:text-sm" | ||
@click="closeModal" | ||
> | ||
Close | ||
</button> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { computed } from 'vue' | ||
import { useStore } from 'vuex' | ||
import FormattedMessage from '../components/FormattedMessage.vue' | ||
import JSConfetti from 'js-confetti' | ||
|
||
export default { | ||
name: 'Quickwins', | ||
components: { | ||
FormattedMessage, | ||
}, | ||
created() { | ||
let that = this; | ||
|
||
document.addEventListener('keyup', function (evt) { | ||
if (evt.keyCode === 27) { | ||
that.closeModal(); | ||
} | ||
}); | ||
if (this.modalOpen === true) { | ||
const jsConfetti = new JSConfetti() | ||
const startTime = Date.now(); | ||
let intervalId = setInterval(() => { | ||
jsConfetti.addConfetti({ | ||
emojis: ['🥔'], | ||
}); | ||
if (Date.now() - startTime > 3000) { | ||
clearInterval(intervalId); | ||
} | ||
}, 300) | ||
} | ||
|
||
}, | ||
data() { | ||
let modelData = null | ||
let modalOpen = false | ||
|
||
this.taggedMessages.forEach((message) => { | ||
if (message.id === this.$route.query?.id) { | ||
modelData = message | ||
modalOpen = true | ||
} | ||
}); | ||
|
||
return { | ||
modalOpen, | ||
modelData, | ||
} | ||
}, | ||
methods: { | ||
openModal() { | ||
this.modalOpen = true | ||
}, | ||
closeModal() { | ||
this.modalOpen = false | ||
this.$router.replace({'query': null}) | ||
}, | ||
}, | ||
|
||
setup() { | ||
const store = useStore() | ||
|
||
const taggedMessages = computed(() => store.getters.taggedMessages); | ||
return { | ||
taggedMessages, | ||
} | ||
}, | ||
} | ||
|
||
</script> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.