Skip to content

Commit

Permalink
refactor(metadata): add tips (#6801)
Browse files Browse the repository at this point in the history
  • Loading branch information
renjie-run authored Sep 19, 2024
1 parent fc65984 commit 26cdff0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
4 changes: 4 additions & 0 deletions frontend/src/metadata/utils/column/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ export const getColumnDisplayName = (key, name) => {
}
};

export const checkIsPrivateColumn = (column) => {
return PRIVATE_COLUMN_KEYS.includes(column.key);
};

export const getColumnOriginName = (column) => {
const { key, name } = column;
if (PRIVATE_COLUMN_KEYS.includes(key)) return key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { RenamePopover, OptionsPopover } from '../../../../../../components/popo
import DropdownItem from './dropdown-item';
import { gettext } from '../../../../../../../utils/constants';
import { isMobile } from '../../../../../../../utils/utils';
import { checkIsPrivateColumn } from '../../../../../../utils/column';
import { getDateDisplayString } from '../../../../../../utils/cell';
import { CellType, DEFAULT_DATE_FORMAT, SORT_COLUMN_OPTIONS, SHOW_DISABLED_SORT_COLUMNS, SORT_TYPE, EVENT_BUS_TYPE } from '../../../../../../constants';

Expand All @@ -20,6 +21,10 @@ const HeaderDropdownMenu = ({ column, view, renameColumn, modifyColumnData, dele
const [isRenamePopoverShow, setRenamePopoverShow] = useState(false);
const [isOptionPopoverShow, setOptionPopoverShow] = useState(false);

const isPrivateColumn = useMemo(() => {
return checkIsPrivateColumn(column);
}, [column]);

const today = useMemo(() => {
let todayDate = new Date();
let year = todayDate.getFullYear();
Expand Down Expand Up @@ -107,7 +112,7 @@ const HeaderDropdownMenu = ({ column, view, renameColumn, modifyColumnData, dele
disabled={true}
target="sf-metadata-edit-column-format"
title={gettext('Edit format settings')}
tip={gettext('You do not have permission')}
tip={isPrivateColumn ? gettext('This property is not editable') : gettext('You do not have permission')}
iconName="set-up"
/>
);
Expand Down Expand Up @@ -197,7 +202,7 @@ const HeaderDropdownMenu = ({ column, view, renameColumn, modifyColumnData, dele
target="sf-metadata-edit-column-options"
iconName="single-select"
title={gettext('Edit single select')}
tip={gettext('You do not have permission')}
tip={isPrivateColumn ? gettext('This property is not editable') : gettext('You do not have permission')}
onChange={openOptionPopover}
/>
{/* <DropdownItem
Expand All @@ -216,14 +221,14 @@ const HeaderDropdownMenu = ({ column, view, renameColumn, modifyColumnData, dele
target="sf-metadata-edit-column-options"
iconName="multiple-select"
title={gettext('Edit multiple select')}
tip={gettext('You do not have permission')}
tip={isPrivateColumn ? gettext('This property is not editable') : gettext('You do not have permission')}
onChange={openOptionPopover}
/>
)}
{/* {type === CellType.NUMBER && (
TODO:
<DropdownItem
disabled={canModifyColumnData}
disabled={!canModifyColumnData}
target="sf-metadata-edit-column-format"
iconName="set-up"
title={gettext('Edit format settings')}
Expand All @@ -241,7 +246,7 @@ const HeaderDropdownMenu = ({ column, view, renameColumn, modifyColumnData, dele
target="sf-metadata-rename-column"
iconName="rename"
title={gettext('Rename property')}
tip={gettext('You do not have permission')}
tip={isPrivateColumn ? gettext('This property is not editable') : gettext('You do not have permission')}
onChange={openRenamePopover}
onMouseEnter={hideSubMenu}
/>
Expand Down Expand Up @@ -272,14 +277,14 @@ const HeaderDropdownMenu = ({ column, view, renameColumn, modifyColumnData, dele
target="sf-metadata-delete-column"
iconName="delete"
title={gettext('Delete property')}
tip={gettext('You do not have permission')}
tip={isPrivateColumn ? gettext('This property can not be deleted') : gettext('You do not have permission')}
onChange={onDelete}
onMouseEnter={hideSubMenu}
/>
</div>
</DropdownMenu>
);
}, [column, openRenamePopover, hideSubMenu, renderDateFormat, openOptionPopover, menuRef, dropdownDomRef, modifySort, onDelete]);
}, [column, openRenamePopover, hideSubMenu, renderDateFormat, openOptionPopover, menuRef, dropdownDomRef, modifySort, onDelete, isPrivateColumn]);

return (
<>
Expand Down

0 comments on commit 26cdff0

Please sign in to comment.