Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSN720 #1495

Merged

TSN720 #1495

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/components/dialogs/settings/SettingsAdvanced.tsx
Expand Up @@ -63,6 +63,9 @@ interface Props {
classes: any;
settings: any;
setDesktopMode: (desktopMode: boolean) => void;
setWarningOpeningFilesExternally: (
warningOpeningFilesExternally: boolean
) => void;
setSaveTagInLocation: (saveTagInLocation: boolean) => void;
showResetSettings: (showDialog: boolean) => void;
tileServers: Array<TS.MapTileServer>;
Expand Down Expand Up @@ -115,6 +118,18 @@ const SettingsAdvanced = (props: Props) => {
checked={!props.settings.desktopMode}
/>
</ListItem>
<ListItem className={classes.listItem}>
<ListItemText primary={i18n.t('warningOpeningFilesExternally')} />
<Switch
data-tid="warningOpeningFilesExternally"
onClick={() =>
props.setWarningOpeningFilesExternally(
!props.settings.warningOpeningFilesExternally
)
}
checked={props.settings.warningOpeningFilesExternally}
/>
</ListItem>
<ListItem className={classes.listItem}>
<ListItemText
primary={
Expand Down Expand Up @@ -216,6 +231,8 @@ function mapStateToProps(state) {
function mapActionCreatorsToProps(dispatch) {
return bindActionCreators(
{
setWarningOpeningFilesExternally:
SettingsActions.setWarningOpeningFilesExternally,
setDesktopMode: SettingsActions.setDesktopMode,
setSaveTagInLocation: SettingsActions.setSaveTagInLocation
},
Expand Down
1 change: 1 addition & 0 deletions app/locales/en/core.json
Expand Up @@ -614,5 +614,6 @@
"searchTypeSemiStrictTooltip": "Exact search in file path, description and text content (by enabled full-text search)",
"searchTypeStrict": "Strict",
"searchTypeStrictTooltip": "Same as semi-strict but case sensitive",
"warningOpeningFilesExternally": "Show warning on opening files externally",
"-": "-"
}
6 changes: 4 additions & 2 deletions app/reducers/app.ts
Expand Up @@ -1907,12 +1907,14 @@ export const actions = {
return;
}
if (fsEntry.isFile) {
PlatformIO.openFile(fsEntry.path);
const { warningOpeningFilesExternally } = getState().settings;
PlatformIO.openFile(fsEntry.path, warningOpeningFilesExternally);
} else {
PlatformIO.openDirectory(fsEntry.path);
}
} else {
PlatformIO.openFile(selectedFile);
const { warningOpeningFilesExternally } = getState().settings;
PlatformIO.openFile(selectedFile, warningOpeningFilesExternally);
}
},
openLink: (url: string) => (
Expand Down
1 change: 1 addition & 0 deletions app/reducers/settings-default.ts
Expand Up @@ -126,6 +126,7 @@ export default {
contentHash: '',
isUpdateInProgress: false,
isUpdateAvailable: false,
warningOpeningFilesExternally: true,
tagDelimiter: ' ',
maxSearchResult: 1000,
desktopMode,
Expand Down
15 changes: 15 additions & 0 deletions app/reducers/settings.ts
Expand Up @@ -32,6 +32,7 @@ export const types = {
SET_LANGUAGE: 'SETTINGS/SET_LANGUAGE',
TOGGLE_SHOWUNIXHIDDENENTRIES: 'SETTINGS/TOGGLE_SHOWUNIXHIDDENENTRIES',
SET_DESKTOPMODE: 'SETTINGS/SET_DESKTOPMODE',
WARNING_OPENING_FILES_EXTERNALLY: 'SETTINGS/WARNING_OPENING_FILES_EXTERNALLY',
SET_SAVE_TAGS_IN_LOCATION: 'SETTINGS/SET_SAVE_TAGS_IN_LOCATION',
SET_TAG_DELIMITER: 'SETTINGS/SET_TAG_DELIMITER',
SET_MAX_SEARCH_RESULT: 'SETTINGS/SET_MAX_SEARCH_RESULT',
Expand Down Expand Up @@ -124,6 +125,12 @@ export default (state: any = defaultSettings, action: any) => {
case types.SET_DESKTOPMODE: {
return { ...state, desktopMode: action.desktopMode };
}
case types.WARNING_OPENING_FILES_EXTERNALLY: {
return {
...state,
warningOpeningFilesExternally: action.warningOpeningFilesExternally
};
}
case types.SET_SAVE_TAGS_IN_LOCATION: {
return { ...state, saveTagInLocation: action.saveTagInLocation };
}
Expand Down Expand Up @@ -406,6 +413,12 @@ export const actions = {
type: types.SET_DESKTOPMODE,
desktopMode
}),
setWarningOpeningFilesExternally: (
warningOpeningFilesExternally: boolean
) => ({
type: types.WARNING_OPENING_FILES_EXTERNALLY,
warningOpeningFilesExternally
}),
setSaveTagInLocation: (saveTagInLocation: boolean) => ({
type: types.SET_SAVE_TAGS_IN_LOCATION,
saveTagInLocation
Expand Down Expand Up @@ -589,6 +602,8 @@ export const getDesktopMode = (state: any) => {
}
return window.ExtDisplayMode !== 'mobile';
};
export const getWarningOpeningFilesExternally = (state: any) =>
state.settings.warningOpeningFilesExternally;
export const getCheckForUpdateOnStartup = (state: any) =>
state.settings.checkForUpdates;
export const getLastPublishedVersion = (state: any) =>
Expand Down
7 changes: 6 additions & 1 deletion app/services/platform-io.ts
Expand Up @@ -23,6 +23,7 @@ import NativePlatformIO from './_PLATFORMIO_';
import ObjectStoreIO from './objectstore-io';
import AppConfig from '-/config';
import { TS } from '-/tagspaces.namespace';
import settings from '-/reducers/settings';

const nativeAPI: any = new NativePlatformIO();
let objectStoreAPI;
Expand Down Expand Up @@ -414,8 +415,12 @@ export default class PlatformIO {
static showInFileManager = (dirPath: string): void =>
nativeAPI.showInFileManager(dirPath);

static openFile = (filePath: string): void => {
static openFile = (
filePath: string,
warningOpeningFilesExternally: boolean
): void => {
if (
!warningOpeningFilesExternally ||
confirm(
'Do you really want to open "' +
filePath +
Expand Down