diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2023-02-11 13:54:27 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2023-02-11 13:54:27 +0900 |
| commit | 73a1372940050d2c8a240e2a22c080ee2175e013 (patch) | |
| tree | dede6cde4dd441dd1b402c7b9721fb91ccd876a3 /packages/frontend/src/os.ts | |
| parent | enhance(client): ヘッダー(MkPageHeader)関連 (#9869) (diff) | |
| download | sharkey-73a1372940050d2c8a240e2a22c080ee2175e013.tar.gz sharkey-73a1372940050d2c8a240e2a22c080ee2175e013.tar.bz2 sharkey-73a1372940050d2c8a240e2a22c080ee2175e013.zip | |
enhance(client): 迷惑になる可能性のある投稿を行う前に警告を表示
Resolve #9862
Diffstat (limited to 'packages/frontend/src/os.ts')
| -rw-r--r-- | packages/frontend/src/os.ts | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/packages/frontend/src/os.ts b/packages/frontend/src/os.ts index 4997030669..639f4eaf17 100644 --- a/packages/frontend/src/os.ts +++ b/packages/frontend/src/os.ts @@ -186,6 +186,38 @@ export function confirm(props: { }); } +// TODO: const T extends ... にしたい +// https://zenn.dev/general_link/articles/813e47b7a0eef7#const-type-parameters +export function actions<T extends { + value: string; + text: string; + primary?: boolean, +}[]>(props: { + type: 'error' | 'info' | 'success' | 'warning' | 'waiting' | 'question'; + title?: string | null; + text?: string | null; + actions: T; +}): Promise<{ canceled: true; result: undefined; } | { + canceled: false; result: T[number]['value']; +}> { + return new Promise((resolve, reject) => { + popup(MkDialog, { + ...props, + actions: props.actions.map(a => ({ + text: a.text, + primary: a.primary, + callback: () => { + resolve({ canceled: false, result: a.value }); + }, + })), + }, { + done: result => { + resolve(result ? result : { canceled: true }); + }, + }, 'closed'); + }); +} + export function inputText(props: { type?: 'text' | 'email' | 'password' | 'url'; title?: string | null; |