Skip to content

Commit d24d720

Browse files
committed
Fixed GH bug not showing file icons, preparing for 1.7 release
1 parent 9c69811 commit d24d720

6 files changed

Lines changed: 128 additions & 130 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66

7-
## [1.0.7] - 2018-01-DD
7+
## [1.0.7] - 2018-01-11
88

99
### Added
1010

11-
- Added Popup, where you can turn off/on vsi for specific hostings
1211
- Support for [gitlab.com](https://about.gitlab.com/)
1312
- Display icons in Repo Tree
1413
- Support for [bitbucket.org](https://bitbucket.org/)
@@ -20,13 +19,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
2019

2120
### Changed
2221

23-
- Updated `vscode-icons` to 7.19.1, added 25 new icons, read more at vscode-icons [changelog](https://marketplace.visualstudio.com/items/robertohuertasm.vscode-icons/changelog)
22+
- Updated `vscode-icons` to 7.19.0, added 25 new icons, read more at vscode-icons [changelog](https://marketplace.visualstudio.com/items/robertohuertasm.vscode-icons/changelog)
2423
- Changed structure of project to be more abstract for several web-based GIT hostings (Github, Gitlab, Bitbucket and Gist) and even for Pastebin
2524

2625
### Fixes
2726

28-
- Fixed git submodule icon not showing on GH pages
29-
- Temporally fixed symlink icon on GH
27+
- [Github] no icon for submodule
28+
- [Github] temporally fixed bug with `symlink` files
29+
- [Github] not showing file icons
3030

3131
## [1.0.6] - 2017-10-29
3232

build/manifest.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"default_icon": {
1515
"128": "icon128.png",
1616
"48": "icon48.png"
17-
},
18-
"default_popup": "popup.html"
17+
}
1918
},
2019
"background": {
2120
"scripts": [

packages/common/LocalStorage.ts

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,57 +4,57 @@
44
import { SupportedHostings } from './SupportedHostings';
55

66
export type LocalStorage = {
7-
/**
7+
/**
88
* Extension version
99
*/
10-
version: string;
11-
/**
10+
version: string;
11+
/**
1212
* List of showed/hidden icons for specific hosts
1313
*/
14-
showIcons: { [Hosting in SupportedHostings]: boolean };
14+
showIcons: { [Hosting in SupportedHostings]: boolean };
1515
};
1616

1717
export const initialStorage: LocalStorage = {
18-
version: chrome.runtime.getManifest().version,
19-
showIcons: {
20-
github: true,
21-
githubgist: false,
22-
gitlab: true,
23-
bitbucket: false,
24-
pastebin: false,
25-
sourceforge: false
26-
}
18+
version: chrome.runtime.getManifest().version,
19+
showIcons: {
20+
github: true,
21+
githubgist: false,
22+
gitlab: true,
23+
bitbucket: true,
24+
pastebin: false,
25+
sourceforge: false
26+
}
2727
};
2828

2929
export function getStorage(): Promise<LocalStorage> {
30-
return new Promise((resolve, reject) => {
31-
if (chrome.storage === undefined) {
32-
reject(new Error('Storage is not accessible from this part of extension'));
33-
}
34-
chrome.storage.local.get(storage => {
35-
const store = storage as LocalStorage;
36-
if (store.version === undefined) {
37-
// When version doesn't exists, it means that storage is empty and user is running
38-
// extension for first time, so use initial storage
39-
chrome.storage.local.set(initialStorage);
40-
resolve(initialStorage);
41-
}
42-
resolve(store);
43-
});
44-
});
30+
return new Promise((resolve, reject) => {
31+
if (chrome.storage === undefined) {
32+
reject(new Error('Storage is not accessible from this part of extension'));
33+
}
34+
chrome.storage.local.get(storage => {
35+
const store = storage as LocalStorage;
36+
if (store.version === undefined) {
37+
// When version doesn't exists, it means that storage is empty and user is running
38+
// extension for first time, so use initial storage
39+
chrome.storage.local.set(initialStorage);
40+
resolve(initialStorage);
41+
}
42+
resolve(store);
43+
});
44+
});
4545
}
4646

4747
export function setStorage(storage: LocalStorage) {
48-
if (chrome.storage === undefined) {
49-
throw new Error('Storage is not accessible from this part of extension');
50-
}
51-
chrome.storage.local.set(storage);
48+
if (chrome.storage === undefined) {
49+
throw new Error('Storage is not accessible from this part of extension');
50+
}
51+
chrome.storage.local.set(storage);
5252
}
5353

5454
export function resetStorage() {
55-
if (chrome.storage === undefined) {
56-
throw new Error('Storage is not accessible from this part of extension');
57-
}
58-
chrome.storage.local.set(initialStorage);
59-
return initialStorage;
55+
if (chrome.storage === undefined) {
56+
throw new Error('Storage is not accessible from this part of extension');
57+
}
58+
chrome.storage.local.set(initialStorage);
59+
return initialStorage;
6060
}

packages/content/Content.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import { initSourceForge } from './pages/SourceForge';
1515
const hostLocation = location.host;
1616

1717
(async function() {
18-
const storage = (await sendMessage({ type: 'STORAGE_GET' })) as LocalStorage;
19-
const hosts = Object.keys(storage.showIcons) as SupportedHostings[];
20-
for (const host of hosts) {
21-
const hostingData = getHostData(host);
22-
const isShowIconsTurnedOn = storage.showIcons[host];
23-
if (isShowIconsTurnedOn && hostLocation.includes(hostingData.host)) {
24-
showIconsForHosting(host);
25-
break; // we don't need to iterate over another hostings when already displayed icons
26-
}
27-
}
18+
const storage = (await sendMessage({ type: 'STORAGE_GET' })) as LocalStorage;
19+
const hosts = Object.keys(storage.showIcons) as SupportedHostings[];
20+
for (const host of hosts) {
21+
const hostingData = getHostData(host);
22+
const isShowIconsTurnedOn = storage.showIcons[host];
23+
if (isShowIconsTurnedOn && hostLocation.includes(hostingData.host)) {
24+
showIconsForHosting(host);
25+
break; // we don't need to iterate over another hostings when already displayed icons
26+
}
27+
}
2828
})();

packages/content/pages/GitHub.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ function showRepoTreeIcons() {
7373

7474
const iconSVGClassName = iconSVGEl.className.baseVal;
7575
let iconPath = '';
76-
if (iconSVGClassName.includes('octicon-file-text')) {
76+
if (iconSVGClassName.includes('octicon-file-text') || iconSVGClassName.endsWith('octicon-file')) {
7777
iconPath = getIconForFile(linkToEl.innerText.toLowerCase());
78-
} else if (iconSVGClassName.includes('octicon-file-directory')) {
78+
} else if (iconSVGClassName.endsWith('octicon-file-directory')) {
7979
iconPath = getIconForFolder(name.split('/').shift());
80-
} else if (iconSVGClassName.includes('octicon-file-submodule')) {
80+
} else if (iconSVGClassName.endsWith('octicon-file-submodule')) {
8181
iconPath = DEFAULT_ROOT;
82-
} else if (iconSVGClassName.includes('octicon-file-symlink-file')) {
82+
} else if (iconSVGClassName.endsWith('octicon-file-symlink-file')) {
8383
iconPath = DEFAULT_FILE;
8484
}
8585

packages/popup/Popup.tsx

Lines changed: 71 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -5,88 +5,87 @@ import { sendMessage } from '../common/Messenger';
55
import { getHostData } from '../common/HostData';
66

77
type State = {
8-
storage: LocalStorage;
9-
isSomethingChanged: boolean;
8+
storage: LocalStorage;
9+
isSomethingChanged: boolean;
1010
};
1111

1212
type Props = {
13-
storage: LocalStorage;
13+
storage: LocalStorage;
1414
};
1515

1616
class Popup extends React.Component<Props, State> {
17-
constructor(props: Props) {
18-
super(props);
19-
this.state = {
20-
storage: props.storage,
21-
isSomethingChanged: false
22-
};
23-
}
17+
constructor(props: Props) {
18+
super(props);
19+
this.state = {
20+
storage: props.storage,
21+
isSomethingChanged: false
22+
};
23+
}
2424

25-
handleToggleClick = (hosting: keyof LocalStorage['showIcons']) => {
26-
const prevStorage = this.state.storage;
27-
const newStorage: LocalStorage = {
28-
...prevStorage,
29-
showIcons: {
30-
...prevStorage.showIcons,
31-
[hosting]: !prevStorage.showIcons[hosting]
32-
}
33-
};
34-
sendMessage({ type: 'STORAGE_SET', storage: newStorage });
35-
this.setState({
36-
storage: newStorage,
37-
isSomethingChanged: true
38-
});
39-
};
25+
handleToggleClick = (hosting: keyof LocalStorage['showIcons']) => {
26+
const prevStorage = this.state.storage;
27+
const newStorage: LocalStorage = {
28+
...prevStorage,
29+
showIcons: {
30+
...prevStorage.showIcons,
31+
[hosting]: !prevStorage.showIcons[hosting]
32+
}
33+
};
34+
sendMessage({ type: 'STORAGE_SET', storage: newStorage });
35+
this.setState({
36+
storage: newStorage,
37+
isSomethingChanged: true
38+
});
39+
};
4040

41-
handleResetButton = async () => {
42-
const defaultState = (await sendMessage({ type: 'STORAGE_RESET' })) as LocalStorage;
43-
this.setState({
44-
storage: defaultState
45-
});
46-
};
41+
handleResetButton = async () => {
42+
const defaultState = (await sendMessage({ type: 'STORAGE_RESET' })) as LocalStorage;
43+
this.setState({
44+
storage: defaultState
45+
});
46+
};
4747

48-
render() {
49-
const hostings = Object.keys(this.props.storage.showIcons) as (keyof LocalStorage['showIcons'])[];
50-
const changedText = this.state.isSomethingChanged ? (
51-
<p style={{ color: 'orange' }}>
52-
<i>In order to see changes on pages, please reload them using refresh button</i>
53-
</p>
54-
) : null;
55-
return (
56-
<div id="settings">
57-
<h3>display icons for:</h3>
58-
<div>
59-
{hostings.map((hosting, index) => {
60-
const hostData = getHostData(hosting);
61-
return (
62-
<div
63-
key={index}
64-
className="form-group"
65-
style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}
66-
>
67-
<label className="form-checkbox">
68-
{hostData.fullName}
69-
<input
70-
type="checkbox"
71-
checked={this.state.storage.showIcons[hosting]}
72-
onChange={(_: any) => this.handleToggleClick(hosting)}
73-
/>
74-
<i className="form-icon" />
75-
</label>
76-
<img className="vsi-icon" src={chrome.runtime.getURL(`favicons/${hostData.favicon}`)} />
77-
</div>
78-
);
79-
})}
80-
{changedText}
81-
</div>
82-
{/* <button onClick={this.handleResetButton}>Reset</button> */}
83-
</div>
84-
);
85-
}
48+
render() {
49+
const hostings = Object.keys(this.props.storage.showIcons) as (keyof LocalStorage['showIcons'])[];
50+
const changedText = this.state.isSomethingChanged ? (
51+
<p style={{ color: 'orange' }}>
52+
<i>In order to see changes on pages, please reload them using refresh button</i>
53+
</p>
54+
) : null;
55+
return (
56+
<div id="settings">
57+
<h3>display icons for:</h3>
58+
<div>
59+
{hostings.map((hosting, index) => {
60+
const hostData = getHostData(hosting);
61+
return (
62+
<div
63+
key={index}
64+
className="form-group"
65+
style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}
66+
>
67+
<label className="form-checkbox">
68+
{hostData.fullName}
69+
<input
70+
type="checkbox"
71+
checked={this.state.storage.showIcons[hosting]}
72+
onChange={(_: any) => this.handleToggleClick(hosting)}
73+
/>
74+
<i className="form-icon" />
75+
</label>
76+
<img className="vsi-icon" src={chrome.runtime.getURL(`favicons/${hostData.favicon}`)} />
77+
</div>
78+
);
79+
})}
80+
{changedText}
81+
</div>
82+
{/* <button onClick={this.handleResetButton}>Reset</button> */}
83+
</div>
84+
);
85+
}
8686
}
8787

8888
(async function() {
89-
const storage = (await sendMessage({ type: 'STORAGE_GET' })) as LocalStorage;
90-
console.log(storage);
91-
ReactDOM.render(<Popup storage={storage} />, document.getElementById('app') as HTMLDivElement);
89+
const storage = (await sendMessage({ type: 'STORAGE_GET' })) as LocalStorage;
90+
ReactDOM.render(<Popup storage={storage} />, document.getElementById('app') as HTMLDivElement);
9291
})();

0 commit comments

Comments
 (0)