TagSpaces is an offline, open source, document manager with tagging support
feat: make uuid of locations visible and editable
Ilian Sapundshiev5a81dad98534
diff --git a/app/components/FolderContainer.tsx b/app/components/FolderContainer.tsxindex 081f09cff..68c70bb6e 100644--- a/app/components/FolderContainer.tsx+++ b/app/components/FolderContainer.tsx@@ -268,7 +268,10 @@ const FolderContainer = (props: Props) => {const addSlash = PlatformIO.haveObjectStoreSupport() ? '//' : '/';let normalizedCurrentPath =addSlash +- normalizePath(props.currentDirectoryPath.split('\\').join('/'));+ normalizePath(+ props.currentDirectoryPath.split &&+ props.currentDirectoryPath.split('\\').join('/')+ );let normalizedCurrentLocationPath = '';if (props.currentLocationPath) {@@ -449,7 +452,7 @@ const FolderContainer = (props: Props) => {loadParentDirectoryContent} = props;const normalizedCurrentDirPath = normalizePath(- currentDirectoryPath.split('\\').join('/')+ currentDirectoryPath.split && currentDirectoryPath.split('\\').join('/'));let searchResultCounterText = searchResultCount + ' ' + i18n.t('entries');if (searchResultCount >= maxSearchResults) {diff --git a/app/components/dialogs/EditLocationDialog.tsx b/app/components/dialogs/EditLocationDialog.tsxindex 0e6db630b..db37ac774 100644--- a/app/components/dialogs/EditLocationDialog.tsx+++ b/app/components/dialogs/EditLocationDialog.tsx@@ -61,6 +61,7 @@ interface State {cloudErrorAccessKey: boolean;cloudErrorSecretAccessKey: boolean;uuid: string;+ newuuid: string;name: string;path: string;endpointURL: string;@@ -104,6 +105,7 @@ class EditLocationDialog extends React.Component<Props, State> {this.state = {...properties,uuid: props.location.uuid,+ newuuid: props.location.uuid,isDefault: props.location.isDefault,isReadOnly: props.location.isReadOnly,watchForChanges: props.location.watchForChanges,@@ -127,6 +129,7 @@ class EditLocationDialog extends React.Component<Props, State> {cloudErrorAccessKey: false,cloudErrorSecretAccessKey: false,uuid: '',+ newuuid: '',name: '',path: '',endpointURL: '',@@ -146,44 +149,6 @@ class EditLocationDialog extends React.Component<Props, State> {}}- /* componentWillReceiveProps = (nextProps: any) => {- if (nextProps.open === true && nextProps.location) {- const dir = nextProps.selectedDirectoryPath;- let properties;- if (nextProps.location.type === locationType.TYPE_CLOUD) {- properties = {- storeName: dir- ? extractDirectoryName(dir, PlatformIO.getDirSeparator())- : nextProps.location.name,- storePath: dir || nextProps.location.paths[0]- };- } else {- properties = {- // TODO maybe its better to separate name/path keys for different locationTypes ??- name: dir- ? extractDirectoryName(dir, PlatformIO.getDirSeparator())- : nextProps.location.name,- path: dir || nextProps.location.paths[0]- };- }- this.setState({- ...properties,- uuid: nextProps.location.uuid,- isDefault: nextProps.location.isDefault,- isReadOnly: nextProps.location.isReadOnly,- watchForChanges: nextProps.location.watchForChanges,- persistIndex: nextProps.location.persistIndex,- fullTextIndex: nextProps.location.fullTextIndex,- type: nextProps.location.type || locationType.TYPE_LOCAL,- accessKeyId: nextProps.location.accessKeyId,- secretAccessKey: nextProps.location.secretAccessKey,- bucketName: nextProps.location.bucketName,- endpointURL: nextProps.location.endpointURL,- region: nextProps.location.region- });- }- }; */-handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {const { target } = event;const value = target.type === 'checkbox' ? target.checked : target.value;@@ -284,6 +249,7 @@ class EditLocationDialog extends React.Component<Props, State> {if (this.state.type === locationType.TYPE_LOCAL) {this.props.editLocation({uuid: this.state.uuid,+ newuuid: this.state.newuuid,type: locationType.TYPE_LOCAL,name: this.state.name,paths: [this.state.path],@@ -296,6 +262,7 @@ class EditLocationDialog extends React.Component<Props, State> {} else if (this.state.type === locationType.TYPE_CLOUD) {this.props.editLocation({uuid: this.state.uuid,+ newuuid: this.state.newuuid,type: locationType.TYPE_CLOUD,name: this.state.storeName,paths: [this.state.storePath],diff --git a/app/components/dialogs/LocalForm.tsx b/app/components/dialogs/LocalForm.tsxindex 7c06c7db3..8407c63b4 100644--- a/app/components/dialogs/LocalForm.tsx+++ b/app/components/dialogs/LocalForm.tsx@@ -109,6 +109,18 @@ class LocalForm extends React.Component<Props> {<FormHelperText>{i18n.t('core:invalidPath')}</FormHelperText>)}</FormControl>+ <FormControl fullWidth={true}>+ <InputLabel htmlFor="newuuid">{i18n.t('core:uuid')}</InputLabel>+ <Input+ margin="dense"+ name="newuuid"+ fullWidth={true}+ data-tid="newuuid"+ placeholder="Advanced setting"+ onChange={handleInputChange}+ value={state.newuuid}+ />+ </FormControl></div>);}diff --git a/app/components/dialogs/ObjectStoreForm.tsx b/app/components/dialogs/ObjectStoreForm.tsxindex 003d09f5f..61b6bd70b 100644--- a/app/components/dialogs/ObjectStoreForm.tsx+++ b/app/components/dialogs/ObjectStoreForm.tsx@@ -305,6 +305,20 @@ class ObjectStoreForm extends React.Component<Props, State> {/></FormControl></Grid>+ <Grid item xs={12}>+ <FormControl fullWidth={true}>+ <InputLabel htmlFor="newuuid">{i18n.t('core:uuid')}</InputLabel>+ <Input+ margin="dense"+ name="newuuid"+ fullWidth={true}+ data-tid="newuuid"+ placeholder="Advanced setting"+ onChange={handleInputChange}+ value={state.newuuid}+ />+ </FormControl>+ </Grid></Grid>);}diff --git a/app/reducers/locations.ts b/app/reducers/locations.tsindex 357c98253..86f9c3ad2 100644--- a/app/reducers/locations.ts+++ b/app/reducers/locations.ts@@ -36,6 +36,7 @@ export const locationType = {export type Location = {uuid: string;+ newuuid?: string;name: string;type: string;accessKeyId?: string;@@ -89,7 +90,11 @@ export default (state: Array<Location> = initialState, action: any) => {if (indexForEditing >= 0) {return [...state.slice(0, indexForEditing),- { ...state[indexForEditing], ...action.location },+ {+ ...state[indexForEditing],+ ...action.location,+ uuid: action.location.newuuid+ },...state.slice(indexForEditing + 1)];}diff --git a/app/utils/paths.ts b/app/utils/paths.tsindex 565948924..1bd8baf8b 100644--- a/app/utils/paths.ts+++ b/app/utils/paths.ts@@ -160,6 +160,7 @@ export function cleanTrailingDirSeparator(dirPath: string): string {* @returns {string} -> root/subFolder*/export function normalizePath(path: string): string {+ if (!path) return '';return cleanTrailingDirSeparator(path.replace(/\/\//g, '/'));}