Skip to content

Commit

Permalink
refactor: remove edit permission for version page and fix handleEditD…
Browse files Browse the repository at this point in the history
…isplayName function
  • Loading branch information
pranita09 committed Nov 27, 2024
1 parent 70dc404 commit 36e6b64
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ export const DatabaseSchemaTable = ({
if (!schemaDetails) {
return;
}
const updatedData = { ...schemaDetails, displayName: data.displayName };
const updatedData = data.displayName
? { ...schemaDetails, displayName: data.displayName }
: { ...schemaDetails, displayName: undefined };
const jsonPatch = compare(schemaDetails, updatedData);
await patchDatabaseSchemaDetails(schemaDetails.id ?? '', jsonPatch);
setSchemas((prevData) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright 2024 Collate.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { EntityName } from '../../Modals/EntityNameModal/EntityNameModal.interface';

export interface DisplayNameProps {
id: string;
name?: string;
displayName?: string;
link: string;
onEditDisplayName?: (data: EntityName, id?: string) => Promise<void>;
allowRename?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,7 @@ import { DE_ACTIVE_COLOR, ICON_DIMENSION } from '../../../constants/constants';
import { showErrorToast } from '../../../utils/ToastUtils';
import EntityNameModal from '../../Modals/EntityNameModal/EntityNameModal.component';
import { EntityName } from '../../Modals/EntityNameModal/EntityNameModal.interface';

export interface DisplayNameProps {
id: string;
name?: string;
displayName?: string;
link: string;
onEditDisplayName?: (data: EntityName, id?: string) => Promise<void>;
allowRename: boolean;
}
import { DisplayNameProps } from './DisplayName.interface';

const DisplayName: React.FC<DisplayNameProps> = ({
id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ function SchemaTablesTab({
if (!tableDetails) {
return;
}

const updatedData = { ...tableDetails, displayName: data.displayName };
const updatedData = data.displayName
? { ...tableDetails, displayName: data.displayName }
: { ...tableDetails, displayName: undefined };
const jsonPatch = compare(tableDetails, updatedData);
await patchTableDetails(tableDetails.id, jsonPatch);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,9 @@ function ServiceMainTabContent({
if (!pageDataDetails) {
return;
}
const updatedData = {
...pageDataDetails,
displayName: entityData.displayName,
};
const updatedData = entityData.displayName
? { ...pageDataDetails, displayName: entityData.displayName }
: { ...pageDataDetails, displayName: undefined };
const jsonPatch = compare(pageDataDetails, updatedData);
await callServicePatchAPI(
serviceCategory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ export interface ServiceVersionMainTabContentProps {
pagingHandler: NextPreviousProps['pagingHandler'];
entityType: EntityType;
changeDescription: ChangeDescription;
isVersionPage?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import TagsContainerV2 from '../../components/Tag/TagsContainerV2/TagsContainerV
import { DisplayType } from '../../components/Tag/TagsViewer/TagsViewer.interface';
import { PAGE_SIZE } from '../../constants/constants';
import { TABLE_SCROLL_VALUE } from '../../constants/Table.constants';
import { usePermissionProvider } from '../../context/PermissionProvider/PermissionProvider';
import { TagSource } from '../../generated/type/tagLabel';
import { useFqn } from '../../hooks/useFqn';
import { getCommonDiffsFromVersionData } from '../../utils/EntityVersionUtils';
Expand All @@ -43,24 +42,15 @@ function ServiceVersionMainTabContent({
serviceDetails,
entityType,
changeDescription,
isVersionPage = true,
}: ServiceVersionMainTabContentProps) {
const { serviceCategory } = useParams<{
serviceCategory: ServiceTypes;
}>();

const { fqn: serviceFQN } = useFqn();
const { permissions } = usePermissionProvider();

const editDisplayNamePermission = useMemo(() => {
return !isVersionPage
? permissions.databaseService.EditAll ||
permissions.databaseService.EditDisplayName
: false;
}, [permissions]);

const tableColumn: ColumnsType<ServicePageData> = useMemo(
() => getServiceMainTabColumns(serviceCategory, editDisplayNamePermission),
() => getServiceMainTabColumns(serviceCategory),
[serviceCategory]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { getUsagePercentile } from './TableUtils';

export const getServiceMainTabColumns = (
serviceCategory: ServiceTypes,
editDisplayNamePermission: boolean,
editDisplayNamePermission?: boolean,
handleDisplayNameUpdate?: (
entityData: EntityName,
id?: string
Expand Down
3 changes: 1 addition & 2 deletions openmetadata-ui/src/main/resources/ui/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ const process = require('process');

const outputPath = path.join(__dirname, 'build');
const subPath = process.env.APP_SUB_PATH ?? '';
const devServerTarget =
process.env.DEV_SERVER_TARGET ?? 'http://localhost:8585/';
const devServerTarget = process.env.DEV_SERVER_TARGET ?? 'http://localhost:8585/';

module.exports = {
// Development mode
Expand Down

0 comments on commit 36e6b64

Please sign in to comment.