Skip to content

Commit

Permalink
Adapting the extension to the new Settings GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
PKief committed Sep 9, 2018
1 parent 6c1ddf4 commit 818f888
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 27 deletions.
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 24 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,21 @@
"material-icon-theme.activeIconPack": {
"type": "string",
"default": "angular",
"description": "%configuration.activeIconPack%"
"description": "%configuration.activeIconPack%",
"enumDescriptions": [
"%configuration.activeIconPack.angular%",
"%configuration.activeIconPack.angular_ngrx%",
"%configuration.activeIconPack.react%",
"%configuration.activeIconPack.react_redux%",
"%configuration.activeIconPack.none%"
],
"enum": [
"angular",
"angular_ngrx",
"react",
"react_redux",
"none"
]
},
"material-icon-theme.files.associations": {
"type": "object",
Expand All @@ -115,6 +129,11 @@
"type": "string",
"default": "specific",
"description": "%configuration.folders.theme%",
"enumDescriptions": [
"%configuration.folders.theme.specific%",
"%configuration.folders.theme.classic%",
"%configuration.folders.theme.none%"
],
"enum": [
"specific",
"classic",
Expand Down Expand Up @@ -164,14 +183,14 @@
},
"devDependencies": {
"@types/mocha": "^5.2.5",
"@types/node": "^10.7.1",
"@types/puppeteer": "^1.6.0",
"@types/node": "^10.9.4",
"@types/puppeteer": "^1.6.3",
"mocha": "^5.2.0",
"puppeteer": "^1.7.0",
"puppeteer": "^1.8.0",
"rimraf": "^2.6.2",
"ts-node": "^7.0.1",
"tslint": "^5.11.0",
"typescript": "^3.0.1",
"typescript": "^3.0.3",
"vscode": "^1.1.21"
}
}
10 changes: 9 additions & 1 deletion package.nls.de.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@
"configuration.showWelcomeMessage": "Willkommensnachricht nach der ersten Installation anzeigen.",
"configuration.showUpdateMessage": "Nachricht bei Aktualisierungen anzeigen.",
"configuration.showReloadMessage": "Nachricht zum Neustarten anzeigen.",
"configuration.activeIconPack": "Icon Paket auswählen, die bestimme Icons aktivieren.",
"configuration.activeIconPack": "Icon-Pack auswählen, die bestimme Icons aktivieren.",
"configuration.activeIconPack.angular": "Icons für Angular",
"configuration.activeIconPack.angular_ngrx": "Icons für Angular und Ngrx",
"configuration.activeIconPack.react": "Icons für React",
"configuration.activeIconPack.react_redux": "Icons für React und Redux",
"configuration.activeIconPack.none": "Kein Icon-Pack aktiviert.",
"configuration.folders.theme": "Art der Ordner Icons auswählen.",
"configuration.folders.theme.specific": "Spezifische Ordner Icons auswählen.",
"configuration.folders.theme.classic": "Klassische Ordner Icons auswählen.",
"configuration.folders.theme.none": "Keine Ordner Icons.",
"configuration.folders.color": "Farbe der Ordner Icons verändern.",
"configuration.hidesExplorerArrows": "Pfeile vor den Ordnern deaktivieren.",
"configuration.opacity": "Deckkraft der Icons anpassen."
Expand Down
8 changes: 8 additions & 0 deletions package.nls.es.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@
"configuration.showUpdateMessage": "Mostrar mensaje al actualizar.",
"configuration.showReloadMessage": "Mostrar mensaje de reinicio.",
"configuration.activeIconPack": "Seleccione un paquete de iconos que permita iconos específicos.",
"configuration.activeIconPack.angular": "Iconos de Angular.",
"configuration.activeIconPack.angular_ngrx": "Iconos de Angular y ngrx.",
"configuration.activeIconPack.react": "Iconos de React.",
"configuration.activeIconPack.react_redux": "Iconos de React y Redux.",
"configuration.activeIconPack.none": "No hay ningún paquete de iconos activo.",
"configuration.folders.theme": "Seleccione el tipo de iconos de carpeta.",
"configuration.folders.theme.specific": "Seleccione iconos de carpeta específicos.",
"configuration.folders.theme.classic": "Seleccione iconos de carpetas clásicas.",
"configuration.folders.theme.none": "Sin iconos de carpeta.",
"configuration.folders.color": "Cambia el color de las carpetas.",
"configuration.hidesExplorerArrows": "Deshabilitar flechas delante de carpetas.",
"configuration.opacity": "Cambia la opacidad de los iconos."
Expand Down
8 changes: 8 additions & 0 deletions package.nls.fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@
"configuration.showUpdateMessage": "Afficher le message de mise à jour.",
"configuration.showReloadMessage": "Afficher le message de redémarrage.",
"configuration.activeIconPack": "Sélectionner un pack d'icônes qui active des icônes spécifiques.",
"configuration.activeIconPack.angular": "Icônes pour Angular.",
"configuration.activeIconPack.angular_ngrx": "Icônes pour Angular et ngrx.",
"configuration.activeIconPack.react": "Icônes pour React.",
"configuration.activeIconPack.react_redux": "Icônes pour React et Redux.",
"configuration.activeIconPack.none": "Aucun pack d'icônes n'est actif.",
"configuration.folders.theme": "Sélectionner le type d'icônes de dossier.",
"configuration.folders.theme.specific": "Sélectionner des icônes de dossiers spécifiques.",
"configuration.folders.theme.classic": "Sélectionner les icônes des dossiers classiques.",
"configuration.folders.theme.none": "Pas d'icônes de dossier.",
"configuration.folders.color": "Changer la couleur des icônes du dossier.",
"configuration.hidesExplorerArrows": "Désactiver les flèches devant les dossiers.",
"configuration.opacity": "Ajuster l'opacité des icônes."
Expand Down
8 changes: 8 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@
"configuration.showUpdateMessage": "Show the update message after each update.",
"configuration.showReloadMessage": "Show restart notification.",
"configuration.activeIconPack": "Select an icon pack that enables specific icons.",
"configuration.activeIconPack.angular": "Icons for Angular.",
"configuration.activeIconPack.angular_ngrx": "Icons for Angular and ngrx.",
"configuration.activeIconPack.react": "Icons for React.",
"configuration.activeIconPack.react_redux": "Icons for React and Redux.",
"configuration.activeIconPack.none": "No icon pack enabled.",
"configuration.folders.theme": "Set the type for the folder icons.",
"configuration.folders.theme.specific": "Select specific folder icons.",
"configuration.folders.theme.classic": "Select classic folder icons.",
"configuration.folders.theme.none": "No folder icons.",
"configuration.folders.color": "Change the color of the folder icons.",
"configuration.hidesExplorerArrows": "Hide explorer arrows before folder.",
"configuration.opacity": "Change the opacity of the icons."
Expand Down
8 changes: 8 additions & 0 deletions package.nls.pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@
"configuration.showUpdateMessage": "Mostrar mensagem de atualização após cada atualização.",
"configuration.showReloadMessage": "Mostrar mensagem da reinicialização.",
"configuration.activeIconPack": "Selecione um pacote de ícones que habilitam ícones específicos.",
"configuration.activeIconPack.angular": "Ícones para Angular.",
"configuration.activeIconPack.angular_ngrx": "Ícones para Angular e ngrx.",
"configuration.activeIconPack.react": "Ícones para React.",
"configuration.activeIconPack.react_redux": "Ícones para React e ngrx.",
"configuration.activeIconPack.none": "Nenhum pacote de ícones ativado.",
"configuration.folders.theme": "Definir o tipo dos ícones das pastas.",
"configuration.folders.theme.specific": "Selecione ícones de pastas específicas.",
"configuration.folders.theme.classic": "Selecione ícones de pastas clássicas.",
"configuration.folders.theme.none": "Nenhum ícone de pasta.",
"configuration.folders.color": "Alterar a cor dos ícones das pastas.",
"configuration.hidesExplorerArrows": "Ocultar as setas ao lado das pastas no explorador de arquivos.",
"configuration.opacity": "Alterar a opacidade dos ícones."
Expand Down
8 changes: 8 additions & 0 deletions package.nls.pt-PT.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@
"configuration.showUpdateMessage": "Exibir mensagem de actualização após cada actualização.",
"configuration.showReloadMessage": "Exibir mensagem da reinicialização.",
"configuration.activeIconPack": "Selecciona um pacote de ícones que habilitam ícones específicos.",
"configuration.activeIconPack.angular": "Ícones para Angular.",
"configuration.activeIconPack.angular_ngrx": "Ícones para Angular e ngrx.",
"configuration.activeIconPack.react": "Ícones para React.",
"configuration.activeIconPack.react_redux": "Ícones para React e ngrx.",
"configuration.activeIconPack.none": "Nenhum pacote de ícones ativado.",
"configuration.folders.theme": "Definir o formato dos ícones dos directórios.",
"configuration.folders.theme.specific": "Selecciona ícones de pastas específicas.",
"configuration.folders.theme.classic": "Selecciona ícones de pastas clássicas.",
"configuration.folders.theme.none": "Nenhum ícone de pasta.",
"configuration.folders.color": "Alterar a cor dos ícones dos directórios.",
"configuration.hidesExplorerArrows": "Esconder as setas ao lado dos directórios no explorador de ficheiros.",
"configuration.opacity": "Alterar a opacidade dos ícones."
Expand Down
8 changes: 8 additions & 0 deletions package.nls.ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@
"configuration.showUpdateMessage": "Показывать сообщение об обновлении после каждого обновления.",
"configuration.showReloadMessage": "Показывать сообщение перезагрузки.",
"configuration.activeIconPack": "Выберите набор значков, которые включают определенные значки.",
"configuration.activeIconPack.angular": "Иконки для Angular.",
"configuration.activeIconPack.angular_ngrx": "Иконки для Angular и ngrx.",
"configuration.activeIconPack.react": "Иконки для React.",
"configuration.activeIconPack.react_redux": "Иконки для React и Redux.",
"configuration.activeIconPack.none": "Папка с иконками не включена.",
"configuration.folders.theme": "Установить тип иконок для папок.",
"configuration.folders.theme.specific": "Выберите конкретные значки папок.",
"configuration.folders.theme.classic": "Выберите классические значки папок.",
"configuration.folders.theme.none": "Нет значков папок.",
"configuration.folders.color": "Изменение цвета иконок папок.",
"configuration.hidesExplorerArrows": "Скрыть стрелки проводника перед папкой.",
"configuration.opacity": "Измените прозрачность значков."
Expand Down
10 changes: 9 additions & 1 deletion package.nls.zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@
"configuration.showUpdateMessage": "更新后显示升级信息。",
"configuration.showReloadMessage": "显示重启消息。",
"configuration.activeIconPack": "选择一个图标包。",
"configuration.folders.theme": "设置文件夹图标类型。\n接受的值为 \"specific\", \"classic\"\"none\"",
"configuration.activeIconPack.angular": "Angular的图标。",
"configuration.activeIconPack.angular_ngrx": "Angular和ngrx的图标。",
"configuration.activeIconPack.react": "React的图标。",
"configuration.activeIconPack.react_redux": "React和Redux的图标。",
"configuration.activeIconPack.none": "没有启用图标包。",
"configuration.folders.theme": "设置文件夹图标的类型。",
"configuration.folders.theme.specific": "选择特定文件夹图标。",
"configuration.folders.theme.classic": "选择经典文件夹图标。",
"configuration.folders.theme.none": "没有文件夹图标。",
"configuration.folders.color": "更改文件夹图标的颜色。",
"configuration.hidesExplorerArrows": "隐藏该文件夹旁边的箭头。",
"configuration.opacity": "更改图标的透明度。"
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/changeDetection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ const compareConfigs = (configs: string[]): Promise<{ updatedConfigs: IconJsonOp
// no further actions (e.g. reload) required
if (/show(Welcome|Update|Reload)Message/g.test(configName)) return result;

const configValue = getThemeConfig(configName).globalValue;
const configValue = getThemeConfig(configName).globalValue || getThemeConfig(configName).defaultValue;
const currentState = getObjectPropertyValue(json.options, configName);

if (configValue !== undefined && JSON.stringify(configValue) !== JSON.stringify(currentState)) {
if (JSON.stringify(configValue) !== JSON.stringify(currentState)) {
setObjectPropertyValue(json.options, configName, configValue);
setObjectPropertyValue(result.updatedConfigs, configName, configValue);
}
Expand Down
6 changes: 1 addition & 5 deletions src/icons/generator/iconOpacity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import * as path from 'path';
* @param fileNames Only change the opacity of certain file names.
*/
export const setIconOpacity = (opacity: number, fileNames?: string[]) => {
if (!validateOpacityValue(opacity)) {
return console.error('Invalid opacity value! Opacity must be a decimal number between 0 and 1!');
}

return new Promise((resolve, reject) => {
let iconsPath = path.join(__dirname, '..', '..', '..');
const parentFolder = iconsPath.split(path.sep).pop();
Expand Down Expand Up @@ -57,7 +53,7 @@ export const setIconOpacity = (opacity: number, fileNames?: string[]) => {
* @param opacity Opacity value
*/
export const validateOpacityValue = (opacity: number) => {
return opacity <= 1 && opacity >= 0;
return opacity !== null && opacity <= 1 && opacity >= 0;
};

/**
Expand Down
8 changes: 7 additions & 1 deletion src/icons/generator/jsonGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { fileIcons } from '../fileIcons';
import { folderIcons } from '../folderIcons';
import { languageIcons } from '../languageIcons';
import { iconJsonName } from './constants';
import { generateFolderIcons, getFileIconDefinitions, getFolderIconDefinitions, getLanguageIconDefinitions, setIconOpacity } from './index';
import { generateFolderIcons, getFileIconDefinitions, getFolderIconDefinitions, getLanguageIconDefinitions, setIconOpacity, validateOpacityValue } from './index';

/**
* Generate the complete icon configuration object that can be written as JSON file.
Expand All @@ -32,11 +32,17 @@ export const createIconFile = async (updatedConfigs?: IconJsonOptions, updatedJS
const iconJSONPath = path.join(__dirname, '../../../', 'src', iconJsonName);
const json = generateIconConfigurationObject(options);

// make sure that the opacity value must be entered correctly to trigger a reload.
if (updatedConfigs && updatedConfigs.opacity && !validateOpacityValue(updatedConfigs.opacity)) {
return Promise.reject('Material Icons: Invalid opacity value!');
}

try {
await fs.writeFile(iconJSONPath, JSON.stringify(json, undefined, 2), async (err) => {
if (err) {
throw Error(err.message);
}

// if updatedConfigs do not exist (because of initial setup)
// or new config value was detected by the change detection
if (!updatedConfigs || (updatedConfigs.folders || {}).color) {
Expand Down

0 comments on commit 818f888

Please sign in to comment.