Skip to content

Commit

Permalink
PullRequest: 466 fix/dev-4.3.1-2840
Browse files Browse the repository at this point in the history
Merge branch 'fix/dev-4.3.1-2840 of [email protected]:oceanbase/oceanbase-developer-center.git into dev-4.3.1

https://code.alipay.com/oceanbase/oceanbase-developer-center/pull_requests/466


Signed-off-by: 晓康 <[email protected]>


* Fixes oceanbase/odc#2804
* Fixes oceanbase/odc#2840
  • Loading branch information
yezaoshu committed Jul 9, 2024
1 parent 7e95489 commit 4ed588e
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 56 deletions.
2 changes: 1 addition & 1 deletion src/component/Toolbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function TButton({

if (tip) {
return (
<Tooltip placement={'topLeft'} title={tip} overlayInnerStyle={tipStyle}>
<Tooltip placement={'topLeft'} title={tip} overlayInnerStyle={tipStyle} color="white">
<Badge dot={true} color="blue" style={{ top: 12, right: 6 }}>
{content}
</Badge>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ const ObjectList = ({
</div>
{i.key === DbObjectType.database
? selectDbBtn(object)
: permissionBtn(object)}
: permissionBtn(object, i.key)}
</div>
);
}
Expand All @@ -232,14 +232,16 @@ const ObjectList = ({
);
};

const applyTablePermission = (e, object) => {
const applyTablePermission = (e, object, type) => {
e.stopPropagation();
const dbObj = type === DbObjectType.table ? object : object?.dbObject;
const params = {
projectId: object?.database?.project?.id,
databaseId: object?.database?.id,
tableName: object?.name,
tableId: object?.id,
projectId: dbObj?.database?.project?.id,
databaseId: dbObj?.database?.id,
tableName: dbObj?.name,
tableId: dbObj?.id,
};
// debugger
modalStore.changeApplyTablePermissionModal(true, {
...params,
});
Expand All @@ -253,28 +255,42 @@ const ObjectList = ({
);
};

const permissionBtn = (object) => {
const permissionBtn = (object, type: DbObjectType) => {
if (activeDatabase?.id !== object.id) return;
if (hasPermission(object)) return;
const isTableColumn =
object?.dbObject?.type === DbObjectType.table || object?.type === DbObjectType.table;
if ([DbObjectType.column, DbObjectType.table].includes(type) && isTableColumn) {
return (
<Button
type="link"
style={{ padding: 0, height: 18, display: 'inline-block' }}
onClick={(e) => applyTablePermission(e, object, type)}
>
{formatMessage({
id: 'src.page.Workspace.SideBar.ResourceTree.DatabaseSearchModal.components.E2C1F722',
defaultMessage: '申请表权限',
})}
</Button>
);
}
return (
<Button
type="link"
style={{ padding: 0, height: 18, display: 'inline-block' }}
onClick={(e) => applyTablePermission(e, object)}
style={{ padding: 0, height: 18 }}
onClick={(e) => applyDbPermission(e, object)}
>
{formatMessage({
id: 'src.page.Workspace.SideBar.ResourceTree.DatabaseSearchModal.components.E2C1F722',
defaultMessage: '申请表权限',
})}
申请库权限
</Button>
);
};

const applyDbPermission = (e, db: IDatabase) => {
const applyDbPermission = (e, db) => {
e.stopPropagation();
const dbObj = db?.dbObject?.database || db?.database || db;
modalStore.changeApplyDatabasePermissionModal(true, {
projectId: db?.project?.id,
databaseId: db?.id,
projectId: dbObj?.project?.id,
databaseId: dbObj?.id,
});
modalStore.changeDatabaseSearchModalVisible(false);
};
Expand Down Expand Up @@ -375,7 +391,9 @@ const ObjectList = ({
{getSubTitle(object, type)}
</span>
</div>
{isDatabasetab ? selectDbBtn(object) : permissionBtn(object)}
{isDatabasetab
? selectDbBtn(object)
: permissionBtn(object, currentObjectList.key)}
</div>
);
})}
Expand Down
55 changes: 28 additions & 27 deletions src/page/Workspace/components/DDLResultSet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ import useColumns, { isNumberType } from './hooks/useColumns';
import ResultContext from './ResultContext';
import StatusBar from './StatusBar';
import { copyToSQL, getColumnNameByColumnKey } from './util';
import { OBCompare, ODC_TRACE_SUPPORT_VERSION } from '@/util/versionUtils';

// @ts-ignore
const ToolbarButton = Toolbar.Button;
Expand Down Expand Up @@ -676,7 +677,7 @@ const DDLResultSet: React.FC<IProps> = function (props) {
const executeGuideTipContent = () => {
if (guideCacheStore?.[guideCacheStore.cacheEnum.executePlan]) return null;
return (
<div>
<div style={{ color: 'var(--text-color-secondary)' }}>
<div>
{formatMessage({
id: 'src.page.Workspace.components.DDLResultSet.E32AB474',
Expand Down Expand Up @@ -749,32 +750,32 @@ const DDLResultSet: React.FC<IProps> = function (props) {
/>
</Tooltip>
))}

{showTrace ? (
<ToolbarButton
text={
withFullLinkTrace
? formatMessage({
id: 'odc.src.page.Workspace.components.DDLResultSet.FullLinkTrace',
}) //'全链路 Trace'
: traceEmptyReason
}
disabled={!withFullLinkTrace}
icon={<TraceSvg />}
onClick={() => {
onShowTrace?.();
}}
/>
) : (
<ToolbarButton
text={traceEmptyReason}
disabled={true}
icon={<TraceSvg />}
onClick={() => {
onShowTrace?.();
}}
/>
)}
{showTrace &&
(isString(obVersion) && OBCompare(obVersion, ODC_TRACE_SUPPORT_VERSION, '>=') ? (
<ToolbarButton
text={
withFullLinkTrace
? formatMessage({
id: 'odc.src.page.Workspace.components.DDLResultSet.FullLinkTrace',
}) //'全链路 Trace'
: traceEmptyReason
}
disabled={!withFullLinkTrace}
icon={<TraceSvg />}
onClick={() => {
onShowTrace?.();
}}
/>
) : (
<ToolbarButton
text={traceEmptyReason}
disabled={true}
icon={<TraceSvg />}
onClick={() => {
onShowTrace?.();
}}
/>
))}
</>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/page/Workspace/components/SQLResultSet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ const SQLResultSet: React.FC<IProps> = function (props) {
<DDLResultSet
key={set.uniqKey || i}
dbTotalDurationMicroseconds={executeSQLStage?.totalDurationMicroseconds}
showExplain={session?.supportFeature?.enableSQLExplain}
showExplain={true}
showExecutePlan={session?.supportFeature.enableProfile}
showPagination={true}
showTrace={session?.supportFeature?.enableSQLTrace}
Expand Down
10 changes: 1 addition & 9 deletions src/store/sessionManager/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ import { getBuiltinSnippets } from '@/common/network/snippet';
import { ISnippet } from '../snippet';
import { DBDefaultStoreType } from '@/d.ts/table';
import { isString } from 'lodash';
import {
OBCompare,
ODC_PROFILE_SUPPORT_VERSION,
ODC_TRACE_SUPPORT_VERSION,
} from '@/util/versionUtils';
import { OBCompare, ODC_PROFILE_SUPPORT_VERSION } from '@/util/versionUtils';
import { ConnectionMode } from '@/d.ts';

const DEFAULT_QUERY_LIMIT = 1000;
Expand Down Expand Up @@ -332,10 +328,6 @@ class SessionStore {
) &&
isString(obVersion) &&
OBCompare(obVersion, ODC_PROFILE_SUPPORT_VERSION, '>=');
this.supportFeature.enableSQLTrace =
this.supportFeature.enableSQLTrace &&
isString(obVersion) &&
OBCompare(obVersion, ODC_TRACE_SUPPORT_VERSION, '>=');
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/versionUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import compareVersions, { compare } from 'compare-versions';

export const ODC_TRACE_SUPPORT_VERSION = '4.2.0';
export const ODC_TRACE_SUPPORT_VERSION = '4.1.0';
export const ODC_PROFILE_SUPPORT_VERSION = '4.2.4';
export const ODC_VERSION_SEP = '.';

Expand Down

0 comments on commit 4ed588e

Please sign in to comment.