Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] Migrate Severity to TypeScript
Change-Id: I5b738983f733da77100830b841419ba9d12fdf23 Resolves: #83955 Releases: master Reviewed-on: https://review.typo3.org/55780 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Mathias Schreiber <mathias.schreiber@typo3.com> Tested-by: Mathias Schreiber <mathias.schreiber@typo3.com> Reviewed-by: Andreas Wolf <andreas.wolf@typo3.org> Tested-by: Andreas Wolf <andreas.wolf@typo3.org>
- Loading branch information
1 parent
0a1f7db
commit f9152bc
Showing
13 changed files
with
103 additions
and
101 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
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
92 changes: 92 additions & 0 deletions
92
typo3/sysext/backend/Resources/Private/TypeScript/Severity.ts
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,92 @@ | ||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
enum SeverityEnum { | ||
notice = -2, | ||
info = -1, | ||
ok = 0, | ||
warning = 1, | ||
error = 2 | ||
} | ||
|
||
/** | ||
* Module: TYPO3/CMS/Backend/Severity | ||
* Severity for the TYPO3 backend | ||
*/ | ||
class Severity { | ||
public static notice: number = SeverityEnum.notice; | ||
public static info: number = SeverityEnum.info; | ||
public static ok: number = SeverityEnum.ok; | ||
public static warning: number = SeverityEnum.warning; | ||
public static error: number = SeverityEnum.error; | ||
|
||
/** | ||
* Gets the CSS class for the severity | ||
* | ||
* @param {SeverityEnum} severity | ||
* @returns {string} | ||
*/ | ||
public static getCssClass(severity: SeverityEnum): string { | ||
let severityClass: string; | ||
|
||
switch (severity) { | ||
case SeverityEnum.notice: | ||
severityClass = 'notice'; | ||
break; | ||
case SeverityEnum.ok: | ||
severityClass = 'success'; | ||
break; | ||
case SeverityEnum.warning: | ||
severityClass = 'warning'; | ||
break; | ||
case SeverityEnum.error: | ||
severityClass = 'danger'; | ||
break; | ||
case SeverityEnum.info: | ||
default: | ||
severityClass = 'info'; | ||
} | ||
|
||
return severityClass; | ||
} | ||
} | ||
|
||
let severityObject; | ||
try { | ||
// fetch from opening window | ||
if (window.opener && window.opener.TYPO3 && window.opener.TYPO3.Severity) { | ||
severityObject = window.opener.TYPO3.Severity; | ||
} | ||
|
||
// fetch from parent | ||
if (parent && parent.window.TYPO3 && parent.window.TYPO3.Severity) { | ||
severityObject = parent.window.TYPO3.Severity; | ||
} | ||
|
||
// fetch object from outer frame | ||
if (top && top.TYPO3 && top.TYPO3.Severity) { | ||
severityObject = top.TYPO3.Severity; | ||
} | ||
} catch (e) { | ||
// This only happens if the opener, parent or top is some other url (eg a local file) | ||
// which loaded the current window. Then the browser's cross domain policy jumps in | ||
// and raises an exception. | ||
// For this case we are safe and we can create our global object below. | ||
} | ||
|
||
if (!severityObject) { | ||
severityObject = Severity; | ||
} | ||
|
||
TYPO3.Storage = severityObject; | ||
export = severityObject; |
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
2 changes: 1 addition & 1 deletion
2
typo3/sysext/backend/Resources/Public/JavaScript/DragUploader.js
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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