diff options
author | Mats Larsen <me@supergrecko.com> | 2021-10-30 14:41:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-30 15:41:38 +0200 |
commit | 2d0cb9f8f0d0b2c2f7f16c1b674ac31426fceff5 (patch) | |
tree | 52b202ed6eb6c130be868a5b17bdb8f710b7a19e | |
parent | c9542a2c1a1d9ac5797f4f42837685346fa9ecba (diff) | |
download | compiler-explorer-gh-1215.tar.gz compiler-explorer-gh-1215.zip |
Ensure Alert.enterSomething's yes callback's type includes the answer (#3052)gh-1215
-rw-r--r-- | static/alert.interfaces.ts | 5 | ||||
-rw-r--r-- | static/alert.ts | 4 | ||||
-rw-r--r-- | static/multifile-service.ts | 2 |
3 files changed, 8 insertions, 3 deletions
diff --git a/static/alert.interfaces.ts b/static/alert.interfaces.ts index 5531f7b3e..f64164c3b 100644 --- a/static/alert.interfaces.ts +++ b/static/alert.interfaces.ts @@ -39,6 +39,11 @@ export interface AlertAskOptions { onClose?: () => void; } +export type AlertEnterTextOptions = { + /** The enter text action returns a value which is captured here */ + yes?: (answer: string) => void; +} & Partial<Pick<AlertAskOptions, 'no' | 'yesHtml' | 'yesClass' | 'noHtml' | 'noClass' | 'onClose'>>; + export interface AlertNotifyOptions { /** * Which group this notification is from. Sets data-group attribute value diff --git a/static/alert.ts b/static/alert.ts index 1d06e1d47..0099c0e60 100644 --- a/static/alert.ts +++ b/static/alert.ts @@ -24,7 +24,7 @@ import $ from 'jquery'; -import { AlertAskOptions, AlertNotifyOptions } from "./alert.interfaces"; +import { AlertAskOptions, AlertEnterTextOptions, AlertNotifyOptions } from './alert.interfaces'; export class Alert { yesHandler: (answer?: string | string[] | number) => void | null = null; @@ -137,7 +137,7 @@ export class Alert { /** * Asks the user a two choice question, where the title, content and buttons are customizable */ - enterSomething(title: string, question: string, defaultValue: string, askOptions: AlertAskOptions) { + enterSomething(title: string, question: string, defaultValue: string, askOptions: AlertEnterTextOptions) { const modal = $('#enter-something'); this.yesHandler = askOptions?.yes ?? (() => undefined); this.noHandler = askOptions?.no ?? (() => undefined); diff --git a/static/multifile-service.ts b/static/multifile-service.ts index 4812e44b0..6d491332c 100644 --- a/static/multifile-service.ts +++ b/static/multifile-service.ts @@ -475,7 +475,7 @@ export class MultifileService { return new Promise((resolve) => { this.alertSystem.enterSomething('Rename file', 'Please enter new filename', suggestedFilename, { - yes: (value) => { + yes: (value: string) => { if (value !== '' && value[0] !== '/') { if (!this.fileExists(value, file)) { file.filename = value; |