Skip to content

Commit

Permalink
Fix mobile layout widgets order
Browse files Browse the repository at this point in the history
  • Loading branch information
flops committed Dec 23, 2024
2 parents bb48868 + 28a9c0c commit 1504211
Show file tree
Hide file tree
Showing 60 changed files with 1,109 additions and 532 deletions.
4 changes: 4 additions & 0 deletions src/@types/nodekit.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ export interface SharedAppContextParams {
) => Promise<ResolveEntryByLinkComponentResponse>;
};

sources: {
reqBody: Request['body'];
};

getAppLayoutSettings: (req: Request, res: Response, name?: string) => AppLayoutSettings;
landingPageSettings?: LandingPageSettings;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"button_ok": "Ok",
"label_title": "Insufficient permissions",
"section_message": "To create collections and workbooks, you need the <code>datalens.editor</code> role. Please contact your administrator."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"button_ok": "Понятно",
"label_title": "Недостаточно прав",
"section_message": "Для создания коллекций и воркбуков необходима роль <code>datalens.editor</code>, обратитесь к администратору."
}
3 changes: 2 additions & 1 deletion src/i18n-keysets/dash.widget-dialog.edit/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
"button_params-setup": "Configure",
"button_save": "Save",
"context_autoheight-availability-hint": "Available only for charts with \"Table\" and \"Markdown\" types",
"context_fill-description": "Enter description",
"context_fill-title": "Enter title",
"context_filtering-other-charts": "This option enables you to apply filtering from this chart to other charts on the dashboard",
"context_filtering-usage-limitations": "<link>More about filtration</link>",
"context_hint-display-info": "The hint appears in the widget title if the title is enabled",
"field_autoheight": "Auto height",
"field_background": "Background",
"field_background-enable": "Enable",
"field_description": "Description",
"field_enable-filtering-other-charts": "Enable",
"field_hint": "Hint",
"field_param-name": "Name",
"field_param-value": "Value",
"field_params": "Parameters",
Expand Down
5 changes: 3 additions & 2 deletions src/i18n-keysets/dash.widget-dialog.edit/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@
"button_params-setup": "Настроить",
"button_save": "Сохранить",
"context_autoheight-availability-hint": "Доступно для чартов типа \"Таблица\" и \"Markdown\"",
"context_fill-description": "Введите описание",
"context_fill-title": "Введите заголовок",
"context_filtering-other-charts": "Опция позволяет применить фильтрацию из этого чарта к другим чартам на дашборде",
"context_filtering-usage-limitations": "<link>Подробнее о фильтрации</link>",
"context_hint-display-info": "Подсказка показывается в заголовке виджета, если он включён",
"field_autoheight": "Автовысота",
"field_background": "Фон",
"field_background-enable": "Включить",
"field_description": "Описание",
"field_enable-filtering-other-charts": "Включить",
"field_hint": "Подсказка",
"field_param-name": "Имя",
"field_param-value": "Значение",
"field_params": "Параметры",
"field_show-title": "Показывать",
"field_title": "Название",
"field_title": "Заголовок",
"field_widget": "Чарт",
"label_autoheight-enable": "Включить",
"label_empty-list": "Список пуст",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,15 +646,6 @@ export class DataFetcher {
userTargetUriUi = sourceConfig.uiEndpoint + croppedTargetUri;
}

if (sourceConfig.adapter) {
return sourceConfig.adapter({
targetUri: croppedTargetUri,
sourceName,
req,
ctx,
});
}

if (sourceConfig.adapterWithContext) {
return sourceConfig.adapterWithContext({
targetUri: croppedTargetUri,
Expand All @@ -675,7 +666,9 @@ export class DataFetcher {
if (sourceType === 'charts') {
const incomingHeader = originalReqHeaders.xChartsFetcherVia || '';

const scriptName = req.body.params ? '/editor/' + req.body.params.name : req.body.path;
const {reqBody} = ctx.get('sources');

const scriptName = reqBody.params ? '/editor/' + reqBody.params.name : reqBody.path;

if (incomingHeader && !Array.isArray(incomingHeader)) {
const circular = incomingHeader.split(',').some((someScriptName) => {
Expand Down Expand Up @@ -733,7 +726,7 @@ export class DataFetcher {

const sourceAuthorizationHeaders = getSourceAuthorizationHeaders({
req,
chartsEngine,
ctx,
sourceConfig,
subrequestHeaders,
});
Expand Down
15 changes: 0 additions & 15 deletions src/server/components/charts-engine/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,6 @@ export type SourceConfig = {
preprocess?: (url: string) => string;
allowedMethods?: ('GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE')[];

/**
* @deprecated
**/
adapter?: ({
targetUri,
sourceName,
req,
ctx,
}: {
targetUri: string;
sourceName: string;
req: Request;
ctx: AppContext;
}) => unknown;

adapterWithContext?: ({
targetUri,
sourceName,
Expand Down
6 changes: 3 additions & 3 deletions src/server/registry/units/common/functions-map.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import type {Request, Response} from '@gravity-ui/expresskit';
import type {AppContext} from '@gravity-ui/nodekit';

import type {Palette} from '../../../../shared/constants/colors';
import type {GetEntryByKeyResponse} from '../../../../shared/schema';
import {makeFunctionTemplate} from '../../../../shared/utils/makeFunctionTemplate';
import type {ChartsEngine} from '../../../components/charts-engine';
import type {SourceConfig} from '../../../components/charts-engine/types';

export const commonFunctionsMap = {
getAvailablePalettesMap: makeFunctionTemplate<() => Record<string, Palette>>(),
getSourceAuthorizationHeaders:
makeFunctionTemplate<
(args: {
chartsEngine: ChartsEngine;
req: Request;
req?: Request;
ctx: AppContext;
sourceConfig: SourceConfig;
subrequestHeaders: Record<string, string>;
}) => Record<string, string>
Expand Down
5 changes: 5 additions & 0 deletions src/shared/constants/qa/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ export enum DialogConfirmQA {
CancelButton = 'dialog-confirm-cancel-button',
}

export enum DialogInfoQA {
Dialog = 'dialog-info',
CloseButton = 'dialog-close-button',
}

export enum DialogWarningQA {
Dialog = 'dialog-warning',
ApplyButton = 'dialog-warning-apply-button',
Expand Down
13 changes: 13 additions & 0 deletions src/shared/schema/bi/actions/datasets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
transformValidateDatasetResponseError,
} from '../helpers';
import type {
CheckConnectionsForPublicationArgs,
CheckConnectionsForPublicationResponse,
CheckDatasetsForPublicationArgs,
CheckDatasetsForPublicationResponse,
CopyDatasetArgs,
Expand Down Expand Up @@ -108,6 +110,17 @@ export const actions = {
headers: {...(workbookId ? {[WORKBOOK_ID_HEADER]: workbookId} : {}), ...headers},
}),
}),
checkConnectionsForPublication: createAction<
CheckConnectionsForPublicationResponse,
CheckConnectionsForPublicationArgs
>({
method: 'POST',
path: () => `${API_V1}/info/connections_publicity_checker`,
params: ({connectionsIds, workbookId}, headers) => ({
body: {connections: connectionsIds},
headers: {...(workbookId ? {[WORKBOOK_ID_HEADER]: workbookId} : {}), ...headers},
}),
}),
createDataset: createAction<CreateDatasetResponse, CreateDatasetArgs>({
method: 'POST',
path: () => `${API_V1}/datasets`,
Expand Down
12 changes: 12 additions & 0 deletions src/shared/schema/bi/types/datasets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ export type CheckDatasetsForPublicationArgs = {
datasetsIds: string[];
} & WorkbookIdArg;

export type CheckConnectionsForPublicationResponse = {
result: {
allowed: boolean;
connection_id: string;
reason: string | null;
}[];
};

export type CheckConnectionsForPublicationArgs = {
connectionsIds: string[];
} & WorkbookIdArg;

export type ValidateDatasetErrorResponse = {
code: string;
message: string;
Expand Down
111 changes: 71 additions & 40 deletions src/shared/schema/mix/actions/entries.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import keyBy from 'lodash/keyBy';
import type {Required} from 'utility-types';

import {EntryScope} from '../../../types';
import {createAction} from '../../gateway-utils';
import {getTypedApi} from '../../simple-schema';
import type {GetRelationsEntry, SwitchPublicationStatusResponse} from '../../us/types';
import {escapeStringForLike, filterDatasetsIdsForCheck} from '../helpers';
import {checkEntriesForPublication, escapeStringForLike} from '../helpers';
import {isValidPublishLink} from '../helpers/validation';
import type {
DeleteEntryArgs,
Expand All @@ -27,11 +28,11 @@ export const entriesActions = {
const typedApi = getTypedApi(api);
const {entryId, lockToken, scope} = args;
switch (scope) {
case 'dataset': {
case EntryScope.Dataset: {
const data = await typedApi.bi.deleteDataset({datasetId: entryId});
return data;
}
case 'connection': {
case EntryScope.Connection: {
const data = await typedApi.bi.deleteConnnection({connectionId: entryId});
return data;
}
Expand All @@ -48,28 +49,42 @@ export const entriesActions = {
entryId,
includePermissionsInfo: true,
})) as Required<GetRelationsEntry, 'permissions'>[];
const filteredDatasetsIds = filterDatasetsIdsForCheck(relations);
if (filteredDatasetsIds.length) {
const {result: datasets} = await typedApi.bi.checkDatasetsForPublication({
datasetsIds: filteredDatasetsIds,
workbookId,
});
const normalizedDatasets = keyBy(datasets, (dataset) => dataset.dataset_id);
return relations.map((entry) => {

const [datasets, connections] = await checkEntriesForPublication({
entries: relations,
typedApi,
workbookId,
});

const normalizedDatasets = datasets
? keyBy(datasets.result, (dataset) => dataset.dataset_id)
: {};
const normalizedConnections = connections
? keyBy(connections.result, (connection) => connection.connection_id)
: {};

return relations.map((entry) => {
let lockPublication = false;
let lockPublicationReason = null;

if (entry.scope === EntryScope.Dataset) {
const datasetEntry = normalizedDatasets[entry.entryId];
const lockPublication = Boolean(datasetEntry && !datasetEntry.allowed);
return {
...entry,
lockPublication,
lockPublicationReason: lockPublication ? datasetEntry.reason : null,
};
});
}
return relations.map((entry) => ({
...entry,
lockPublication: false,
lockPublicationReason: null,
}));
lockPublication = datasetEntry && !datasetEntry.allowed;
lockPublicationReason = datasetEntry.reason;
}

if (entry.scope === EntryScope.Connection) {
const connectionEntry = normalizedConnections[entry.entryId];
lockPublication = connectionEntry && !connectionEntry.allowed;
lockPublicationReason = connectionEntry.reason;
}

return {
...entry,
lockPublication,
lockPublicationReason,
};
});
},
),
switchPublicationStatus: createAction<
Expand All @@ -81,23 +96,39 @@ export const entriesActions = {
}

const typedApi = getTypedApi(api);
const filteredDatasetsIds = filterDatasetsIdsForCheck(entries);
if (filteredDatasetsIds.length) {
const {result: datasets} = await typedApi.bi.checkDatasetsForPublication({
datasetsIds: filteredDatasetsIds,
workbookId,
});
if (datasets.some((datasetEntry) => !datasetEntry.allowed)) {
const errorMessage = JSON.stringify(
datasets
.filter(({allowed}) => !allowed)
.map(({dataset_id: entryId, reason}) => ({entryId, reason})),
null,
4,
);
throw new Error(`Failed to publish datasets:\n ${errorMessage}`);
}

const [datasets, connections] = await checkEntriesForPublication({
entries,
typedApi,
workbookId,
});

let errorMessage = '';

if (datasets && datasets.result.some((datasetEntry) => !datasetEntry.allowed)) {
errorMessage += JSON.stringify(
datasets.result
.filter(({allowed}) => !allowed)
.map(({dataset_id: entryId, reason}) => ({entryId, reason})),
null,
4,
);
}

if (connections && connections.result.some((connectionEntry) => !connectionEntry.allowed)) {
errorMessage += JSON.stringify(
connections.result
.filter(({allowed}) => !allowed)
.map(({connection_id: entryId, reason}) => ({entryId, reason})),
null,
4,
);
}

if (errorMessage) {
throw new Error(`Failed to publish entries:\n ${errorMessage}`);
}

const result = await typedApi.us._switchPublicationStatus({entries, mainEntry});
return result;
}),
Expand Down
Loading

0 comments on commit 1504211

Please sign in to comment.