Skip to content

Commit cfa8db8

Browse files
authored
improve get domains list and hide share directory when unavailable (#189)
1 parent a746d12 commit cfa8db8

File tree

6 files changed

+34
-10
lines changed

6 files changed

+34
-10
lines changed

create-desktop-file.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ THIS_BASE_PATH=$(dirname "${THIS_PATH}")
66
cd "$THIS_BASE_PATH"
77
FULL_PATH=$(pwd)
88
cd "${WORKING_DIR}"
9-
cat <<EOS > "kodo-browser.desktop"
9+
DESKTOP_FILE_NAME="kodo-browser.desktop"
10+
cat <<EOS > "${DESKTOP_FILE_NAME}"
1011
[Desktop Entry]
1112
Name=Kodo Browser
1213
Comment=Kodo Browser for Linux
@@ -17,4 +18,4 @@ MimeType=x-scheme-handler/kodobrowser
1718
Icon=${FULL_PATH}/resources/app/renderer/static/brand/qiniu.png
1819
Categories=Utility;Development;
1920
EOS
20-
chmod +x "Kodo Browser.desktop"
21+
chmod +x "${DESKTOP_FILE_NAME}"

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "kodo-browser",
3-
"version": "2.3.0",
3+
"version": "2.3.1",
44
"license": "Apache-2.0",
55
"author": {
66
"name": "Rong Zhou",
@@ -111,7 +111,7 @@
111111
"form-data": "^4.0.0",
112112
"js-base64": "^3.4.5",
113113
"js-md5": "^0.7.3",
114-
"kodo-s3-adapter-sdk": "0.6.0",
114+
"kodo-s3-adapter-sdk": "0.6.1",
115115
"lockfile": "^1.0.4",
116116
"lodash": "^4.17.21",
117117
"mime": "^2.3.1",

src/renderer/modules/auth/functions.ts

+13-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import lodash from "lodash";
33
import * as LocalLogger from "@renderer/modules/local-logger";
44
import * as QiniuClient from "@renderer/modules/qiniu-client";
55

6-
import {AkItem, EndpointType, ShareSession} from "./types";
6+
import {AkItem, AkSpecialType, EndpointType, ShareSession} from "./types";
77
import {authPersistence} from "./persistence";
88

99
let currentUser: AkItem | null = null;
@@ -32,6 +32,7 @@ export async function signIn(akItem: AkItem, remember: boolean) {
3232
QiniuClient.clearAllCache();
3333
throw err;
3434
}
35+
akItem.specialType = getAkSpecialType(akItem.accessKey);
3536
currentUser = akItem;
3637
if (remember) {
3738
await authPersistence.save(akItem);
@@ -78,6 +79,7 @@ export async function signInWithShareLink({
7879
endpointType: EndpointType.ShareSession,
7980
accessKey: verifyShareResult.federated_ak,
8081
accessSecret: verifyShareResult.federated_sk,
82+
specialType: getAkSpecialType(verifyShareResult.federated_ak),
8183
};
8284
shareSession = {
8385
sessionToken: verifyShareResult.session_token,
@@ -108,6 +110,7 @@ export async function signInWithShareSession({
108110
currentUser = {
109111
...akItem,
110112
endpointType: EndpointType.ShareSession,
113+
specialType: getAkSpecialType(akItem.accessKey),
111114
};
112115
shareSession = session;
113116
// do not remember always;
@@ -124,6 +127,15 @@ export function getCurrentUser(): AkItem | null {
124127
return currentUser;
125128
}
126129

130+
export function getAkSpecialType(accessKey: string = ""): AkSpecialType | undefined {
131+
if (accessKey.length === 44 && accessKey.startsWith("IAM-")) {
132+
return AkSpecialType.IAM;
133+
} else if (accessKey.startsWith("STS-")) {
134+
return AkSpecialType.STS;
135+
}
136+
return;
137+
}
138+
127139
export function getShareSession(): ShareSession | null {
128140
return shareSession;
129141
}

src/renderer/modules/auth/types.ts

+6
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@ export enum EndpointType {
44
ShareSession = "shareSession",
55
}
66

7+
export enum AkSpecialType {
8+
IAM = "IAM",
9+
STS = "STS",
10+
}
11+
712
export interface AkItem {
813
endpointType: EndpointType,
914
accessKey: string,
1015
accessSecret: string,
16+
specialType?: AkSpecialType,
1117
description?: string,
1218
}
1319

src/renderer/pages/browse/files/file-table/columns/file-operations.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ const FileOperations: React.FC<RowCellDataProps & FileOperationsCellCallbackProp
3131
const canRestore = isFile && ["Archive", "DeepArchive"].includes(file.storageClass);
3232

3333
const shouldShowShareDirButton = useMemo(() => {
34-
if (isFile || !currentUser) {
34+
if (
35+
isFile ||
36+
!currentUser ||
37+
currentUser.specialType ||
38+
bucketGrantedPermission
39+
) {
3540
return false;
3641
}
3742

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -7364,10 +7364,10 @@ klona@^2.0.4, klona@^2.0.5:
73647364
resolved "https://registry.yarnpkg.com/klona/-/klona-2.0.5.tgz#d166574d90076395d9963aa7a928fabb8d76afbc"
73657365
integrity sha512-pJiBpiXMbt7dkzXe8Ghj/u4FfXOOa98fPW+bihOJ4SjnoijweJrNThJfd3ifXpXhREjpoF2mZVH1GfS9LV3kHQ==
73667366

7367-
7368-
version "0.6.0"
7369-
resolved "https://registry.yarnpkg.com/kodo-s3-adapter-sdk/-/kodo-s3-adapter-sdk-0.6.0.tgz#d1e5f2687683748ec3bf33602d6ad9b1bc2f396b"
7370-
integrity sha512-aq4LBU7GCErC3YZCmIcMhLgfjlYzMwF5WJ80qUT/UqAsk0/mhgrG3oj2yGmVooid6UhBuTe3to7XjddyUkdj3A==
7367+
7368+
version "0.6.1"
7369+
resolved "https://registry.yarnpkg.com/kodo-s3-adapter-sdk/-/kodo-s3-adapter-sdk-0.6.1.tgz#319da35d9c3a8f5e1e3987b9a89835ac1b43953f"
7370+
integrity sha512-RWxb1I0EjPdZZC3Q7FBHBKjc3ctzm/Hy2hw3yk6mKRs+rIPyzbjuTyG1j9RrhewY8ZeG3Avlozrlg6YG36ySqg==
73717371
dependencies:
73727372
agentkeepalive "^4.2.1"
73737373
async-lock "^1.2.4"

0 commit comments

Comments
 (0)