-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bef2a07
commit 6857d55
Showing
35 changed files
with
291 additions
and
24 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
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,84 @@ | ||
import { v4 } from 'uuid'; | ||
import { Post, Session } from '../../common/types.js'; | ||
import { UserEntity } from '../../db/entities/UserIdentity.js'; | ||
import { savePost, saveVote } from './posts.js'; | ||
import { createSession, getSession, saveSession } from './sessions.js'; | ||
import { getNext, getMiddle } from '../../lexorank.js'; | ||
import { registerAnonymousUser } from './users.js'; | ||
import { DeepPartial } from 'typeorm'; | ||
|
||
export async function createDemoSession(author: UserEntity): Promise<Session> { | ||
const session = await createSession(author); | ||
session.name = 'My Retro Demo'; | ||
session.demo = true; | ||
session.options = { | ||
...session.options, | ||
allowActions: true, | ||
allowGiphy: true, | ||
allowMultipleVotes: true, | ||
allowReordering: true, | ||
allowSelfVoting: true, | ||
allowTimer: true, | ||
allowCancelVote: true, | ||
allowGrouping: true, | ||
maxDownVotes: 20, | ||
maxUpVotes: 20, | ||
readonlyOnTimerEnd: true, | ||
}; | ||
await saveSession(author.id, session); | ||
let rank = getMiddle(); | ||
|
||
const otherUser = (await registerAnonymousUser('John Doe^' + v4(), v4()))!; | ||
|
||
const otherUserId = otherUser!.user!.id; | ||
|
||
async function createPost( | ||
content: string, | ||
column: number, | ||
votes = 0, | ||
own = false | ||
) { | ||
rank = getNext(rank); | ||
const postData: DeepPartial<Post> = { | ||
content, | ||
column, | ||
giphy: null, | ||
action: null, | ||
rank, | ||
votes: [], | ||
group: null, | ||
id: v4(), | ||
}; | ||
const post = (await savePost( | ||
own ? author.id : otherUserId, | ||
session.id, | ||
postData | ||
))!; | ||
for (let i = 0; i < votes; i++) { | ||
saveVote(otherUserId, '', post.id, { | ||
id: v4(), | ||
type: 'like', | ||
user: otherUser.user.toJson(), | ||
}); | ||
} | ||
const updatedSession = await getSession(session.id); | ||
return updatedSession; | ||
} | ||
|
||
await Promise.all([ | ||
createPost("I'm enjoying our new retrospective board!", 0, 5), | ||
createPost('I love how we can vote on posts', 0), | ||
createPost('I wish I discovered this tool sooner 😅', 1, 2, true), | ||
createPost( | ||
'Have you tried different settings? Click on "Customise" to see what you can do.', | ||
2 | ||
), | ||
createPost('Try Giphy by clicking on the yellow smiley face!', 2, 1, true), | ||
createPost( | ||
'You can also share this URL with somebody else to collaborate on the same board.', | ||
2 | ||
), | ||
]); | ||
|
||
return session; | ||
} |
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,14 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class Demo1677668065305 implements MigrationInterface { | ||
name = 'Demo1677668065305' | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "sessions" ADD "demo" boolean NOT NULL DEFAULT false`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`ALTER TABLE "sessions" DROP COLUMN "demo"`); | ||
} | ||
|
||
} |
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,21 @@ | ||
import { LexoRank } from 'lexorank'; | ||
|
||
export function getMiddle(): string { | ||
return LexoRank.middle().toString(); | ||
} | ||
|
||
export function getNext(rank: string): string { | ||
return LexoRank.parse(rank).genNext().toString(); | ||
} | ||
|
||
export function getPrevious(rank: string): string { | ||
return LexoRank.parse(rank).genPrev().toString(); | ||
} | ||
|
||
export function getBetween(before: string, after: string): string { | ||
try { | ||
return LexoRank.parse(before).between(LexoRank.parse(after)).toString(); | ||
} catch { | ||
return before; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
"project_id" : "512896" | ||
"base_path" : "." | ||
"base_path" : "../" | ||
"base_url" : "https://api.crowdin.com" | ||
"preserve_hierarchy": true | ||
|
||
files: [ | ||
{ | ||
"source" : "/src/translations/locales/en-GB.json", | ||
"translation" : "/src/translations/locales/%locale%.json" | ||
"source" : "frontend/src/translations/locales/en-GB.json", | ||
"translation" : "frontend/src/translations/locales/%locale%.json" | ||
} | ||
] |
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
Oops, something went wrong.