Skip to content

Commit

Permalink
Merge branch 'devel' into CB-4677-fix-scheduler-kerberos
Browse files Browse the repository at this point in the history
  • Loading branch information
dariamarutkina authored Feb 22, 2024
2 parents d672aa2 + 9ba77f1 commit 9663327
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,27 @@ import { useService } from '@cloudbeaver/core-di';
import { ITabData, Tab, TabIcon, TabTitle } from '@cloudbeaver/core-ui';
import { CaptureViewContext } from '@cloudbeaver/core-view';
import type { TabHandlerTabComponent } from '@cloudbeaver/plugin-navigation-tabs';
import { DATA_CONTEXT_SQL_EDITOR_STATE, getSqlEditorName, ISqlEditorTabState, SqlDataSourceService } from '@cloudbeaver/plugin-sql-editor';
import {
DATA_CONTEXT_SQL_EDITOR_STATE,
ESqlDataSourceFeatures,
getSqlEditorName,
ISqlEditorTabState,
SqlDataSourceService,
} from '@cloudbeaver/plugin-sql-editor';

import { DATA_CONTEXT_SQL_EDITOR_TAB } from './DATA_CONTEXT_SQL_EDITOR_TAB';
import sqlEditorTabStyles from './SqlEditorTab.m.css';

export const SqlEditorTab: TabHandlerTabComponent<ISqlEditorTabState> = observer(function SqlEditorTab({ tab, onSelect, onClose, style }) {
const viewContext = useContext(CaptureViewContext);
const tabMenuContext = useDataContext(viewContext);

tabMenuContext.set(DATA_CONTEXT_SQL_EDITOR_TAB, true);
tabMenuContext.set(DATA_CONTEXT_SQL_EDITOR_STATE, tab.handlerState);

const sqlDataSourceService = useService(SqlDataSourceService);
const connectionInfo = useService(ConnectionInfoResource);

const translate = useTranslate();

const dataSource = sqlDataSourceService.get(tab.handlerState.editorId);
Expand All @@ -44,6 +50,7 @@ export const SqlEditorTab: TabHandlerTabComponent<ISqlEditorTabState> = observer
const name = getSqlEditorName(tab.handlerState, dataSource, connection);
const icon = dataSource?.icon ?? '/icons/sql_script_m.svg';
const saved = dataSource?.isSaved !== false;
const isScript = dataSource?.hasFeature(ESqlDataSourceFeatures.script);
const isReadonly = Boolean(dataSource?.isReadonly());
const hasUnsavedMark = !saved && !isReadonly;

Expand All @@ -54,7 +61,9 @@ export const SqlEditorTab: TabHandlerTabComponent<ISqlEditorTabState> = observer
<Tab tabId={tab.id} style={style} title={name} menuContext={tabMenuContext} onOpen={handleSelect} onClose={handleClose}>
<TabIcon icon={icon} />
<TabTitle>{name}</TabTitle>
{isReadonly && <IconOrImage title={translate('ui_readonly')} icon="/icons/lock.png" className={s(sqlEditorTabStyles, { readonlyIcon: true })} />}
{isReadonly && isScript && (
<IconOrImage title={translate('ui_readonly')} icon="/icons/lock.png" className={s(sqlEditorTabStyles, { readonlyIcon: true })} />
)}
{hasUnsavedMark && <unsaved-mark className={s(sqlEditorTabStyles, { unsavedMark: true })} />}
</Tab>,
);
Expand Down

0 comments on commit 9663327

Please sign in to comment.