-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into enhancement/context_menus/sidebar
- Loading branch information
Showing
121 changed files
with
5,303 additions
and
536 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Extract and upload i18n strings | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
workflow_dispatch: | ||
|
||
jobs: | ||
extract-and-upload-i18n-strings: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up environment | ||
uses: ./.github/actions/setup | ||
- name: Configure i18n client | ||
run: | | ||
pip install wlc | ||
- name: Generate i18n strings | ||
run: yarn generate:i18n | ||
- name: Upload i18n strings | ||
run: | | ||
if [[ ! -f packages/desktop-client/locale/en.json ]]; then | ||
echo "File packages/desktop-client/locale/en.json not found. Ensure the file was generated correctly." | ||
exit 1 | ||
fi | ||
wlc \ | ||
--url https://hosted.weblate.org/api/ \ | ||
--key "${{ secrets.WEBLATE_API_KEY_CI_STRINGS }}" \ | ||
upload \ | ||
--author-name "Actual Budget" \ | ||
--author-email "[email protected]" \ | ||
--method add \ | ||
--input packages/desktop-client/locale/en.json \ | ||
actualbudget/actual/en | ||
echo "Translations uploaded" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,6 @@ public/kcab | |
public/data | ||
public/data-file-index.txt | ||
public/*.wasm | ||
|
||
# translations | ||
locale/ |
Binary file modified
BIN
+370 Bytes
(100%)
...tion-available-funds-overspent-budgeted-and-for-next-month-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+210 Bytes
(100%)
...tion-available-funds-overspent-budgeted-and-for-next-month-2-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+424 Bytes
(100%)
...tion-available-funds-overspent-budgeted-and-for-next-month-3-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+345 Bytes
(100%)
...est.js-snapshots/Budget-transfer-funds-to-another-category-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+194 Bytes
(100%)
...est.js-snapshots/Budget-transfer-funds-to-another-category-2-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+435 Bytes
(100%)
...est.js-snapshots/Budget-transfer-funds-to-another-category-3-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+150 Bytes
(100%)
...ettings.test.js-snapshots/Settings-checks-the-page-visuals-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+162 Bytes
(100%)
...ettings.test.js-snapshots/Settings-checks-the-page-visuals-3-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, { createContext, useContext, type ReactNode } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
|
||
import { type State } from 'loot-core/client/state-types'; | ||
|
||
import { useServerURL } from '../components/ServerContext'; | ||
|
||
import { type Permissions } from './types'; | ||
|
||
type AuthContextType = { | ||
hasPermission: (permission?: Permissions) => boolean; | ||
}; | ||
|
||
const AuthContext = createContext<AuthContextType | undefined>(undefined); | ||
|
||
type AuthProviderProps = { | ||
children?: ReactNode; | ||
}; | ||
|
||
export const AuthProvider = ({ children }: AuthProviderProps) => { | ||
const userData = useSelector((state: State) => state.user.data); | ||
const serverUrl = useServerURL(); | ||
|
||
const hasPermission = (permission?: Permissions) => { | ||
if (!permission) { | ||
return true; | ||
} | ||
|
||
return ( | ||
!serverUrl || | ||
userData?.permission?.toUpperCase() === permission?.toUpperCase() | ||
); | ||
}; | ||
|
||
return ( | ||
<AuthContext.Provider value={{ hasPermission }}> | ||
{children} | ||
</AuthContext.Provider> | ||
); | ||
}; | ||
|
||
export const useAuth = () => { | ||
const context = useContext(AuthContext); | ||
if (context === undefined) { | ||
throw new Error('useAuth must be used within an AuthProvider'); | ||
} | ||
return context; | ||
}; |
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,65 @@ | ||
import { useEffect, useState, type ReactElement } from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
|
||
import { type RemoteFile, type SyncedLocalFile } from 'loot-core/types/file'; | ||
|
||
import { View } from '../components/common/View'; | ||
import { useMetadataPref } from '../hooks/useMetadataPref'; | ||
|
||
import { useAuth } from './AuthProvider'; | ||
import { type Permissions } from './types'; | ||
|
||
type ProtectedRouteProps = { | ||
permission: Permissions; | ||
element: ReactElement; | ||
validateOwner?: boolean; | ||
}; | ||
|
||
export const ProtectedRoute = ({ | ||
element, | ||
permission, | ||
validateOwner, | ||
}: ProtectedRouteProps) => { | ||
const { hasPermission } = useAuth(); | ||
const [permissionGranted, setPermissionGranted] = useState(false); | ||
const [cloudFileId] = useMetadataPref('cloudFileId'); | ||
const allFiles = useSelector(state => state.budgets.allFiles || []); | ||
const remoteFiles = allFiles.filter( | ||
(f): f is SyncedLocalFile | RemoteFile => | ||
f.state === 'remote' || f.state === 'synced' || f.state === 'detached', | ||
); | ||
const currentFile = remoteFiles.find(f => f.cloudFileId === cloudFileId); | ||
const userData = useSelector(state => state.user.data); | ||
|
||
useEffect(() => { | ||
const hasRequiredPermission = hasPermission(permission); | ||
setPermissionGranted(hasRequiredPermission); | ||
|
||
if (!hasRequiredPermission && validateOwner) { | ||
if (currentFile) { | ||
setPermissionGranted( | ||
currentFile.usersWithAccess.some(u => u.userId === userData?.userId), | ||
); | ||
} | ||
} | ||
}, [ | ||
cloudFileId, | ||
permission, | ||
validateOwner, | ||
hasPermission, | ||
currentFile, | ||
userData, | ||
]); | ||
|
||
return permissionGranted ? ( | ||
element | ||
) : ( | ||
<View | ||
style={{ | ||
margin: '50px', | ||
}} | ||
> | ||
<h3>You don't have permission to view this page</h3> | ||
</View> | ||
); | ||
}; |
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,3 @@ | ||
export enum Permissions { | ||
ADMINISTRATOR = 'ADMIN', | ||
} |
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
Oops, something went wrong.