Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro committed Jan 30, 2024
1 parent 5021728 commit 4bacf57
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('useStoredSidebarWidth', () => {
it('returns a stored filterBar width from localStorage', () => {
const id = '123';
const expectedWidth = 378;
setItem(LocalStorageKeys.common__resizable_sidebar_widths, {
setItem(LocalStorageKeys.CommonResizableSidebarWidths, {
[id]: expectedWidth,
'456': 250,
});
Expand All @@ -66,7 +66,7 @@ describe('useStoredSidebarWidth', () => {
const expectedWidth = 378;
const otherDashboardId = '456';
const otherDashboardWidth = 253;
setItem(LocalStorageKeys.common__resizable_sidebar_widths, {
setItem(LocalStorageKeys.CommonResizableSidebarWidths, {
[id]: 300,
[otherDashboardId]: otherDashboardWidth,
});
Expand All @@ -81,7 +81,7 @@ describe('useStoredSidebarWidth', () => {

const updatedWidth = result.current[0];
const widthsMap = getItem(
LocalStorageKeys.common__resizable_sidebar_widths,
LocalStorageKeys.CommonResizableSidebarWidths,
{},
);
expect(widthsMap[id]).toEqual(expectedWidth);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ export default function useStoredSidebarWidth(
useEffect(() => {
widthsMapRef.current =
widthsMapRef.current ??
getItem(LocalStorageKeys.common__resizable_sidebar_widths, {});
getItem(LocalStorageKeys.CommonResizableSidebarWidths, {});
if (widthsMapRef.current[id]) {
setSidebarWidth(widthsMapRef.current[id]);
}
}, [id]);

function setStoredSidebarWidth(updatedWidth: number) {
setSidebarWidth(updatedWidth);
setItem(LocalStorageKeys.common__resizable_sidebar_widths, {
setItem(LocalStorageKeys.CommonResizableSidebarWidths, {
...widthsMapRef.current,
[id]: updatedWidth,
});
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/components/Table/Table.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ export const HeaderRenderers: ComponentStory<typeof Table> = () => {
{ label: 'Brazilian Real', value: 'pt_BR' },
]}
value={priceLocale}
onChange={value => setPriceLocale(value as LocaleCode)}
onChange={value => setPriceLocale(value)}
/>
),
dataIndex: 'price',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ test('Should show "Drill to detail"', () => {
test('Should show menu items tied to can_view_and_drill permission', () => {
// @ts-ignore
global.featureFlags = {
[FeatureFlag.DRILL_TO_DETAIL]: true,
[FeatureFlag.DrillToDetail]: true,
};
const props = {
...createProps(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test('stores the dashboard info with local storages', () => {
render(<SyncDashboardState dashboardPageId={testDashboardPageId} />, {
useRedux: true,
});
expect(getItem(LocalStorageKeys.dashboard__explore_context, {})).toEqual({
expect(getItem(LocalStorageKeys.DashboardExploreContext, {})).toEqual({
[testDashboardPageId]: expect.objectContaining({
dashboardPageId: testDashboardPageId,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const EMPTY_OBJECT = {};

export const getDashboardContextLocalStorage = () => {
const dashboardsContexts = getItem(
LocalStorageKeys.dashboard__explore_context,
LocalStorageKeys.DashboardExploreContext,
{},
);
// A new dashboard tab id is generated on each dashboard page opening.
Expand All @@ -52,7 +52,7 @@ const updateDashboardTabLocalStorage = (
dashboardContext: DashboardContextForExplore,
) => {
const dashboardsContexts = getDashboardContextLocalStorage();
setItem(LocalStorageKeys.dashboard__explore_context, {
setItem(LocalStorageKeys.DashboardExploreContext, {
...dashboardsContexts,
[dashboardPageId]: dashboardContext,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const DashboardPage: FC<PageProps> = ({ idOrSlug }: PageProps) => {
// generated next time user opens a dashboard and the old one won't be reused
const handleTabClose = () => {
const dashboardsContexts = getDashboardContextLocalStorage();
setItem(LocalStorageKeys.dashboard__explore_context, {
setItem(LocalStorageKeys.DashboardExploreContext, {
...dashboardsContexts,
[dashboardPageId]: {
...dashboardsContexts[dashboardPageId],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const simpleCustomFilter = new AdhocFilter({
expressionType: ExpressionTypes.Simple,
subject: 'ds',
operator: 'LATEST PARTITION',
operatorId: Operators.LATEST_PARTITION,
operatorId: Operators.LatestPartition,
});

const options = [
Expand Down Expand Up @@ -218,11 +218,11 @@ describe('AdhocFilterEditPopoverSimpleTabContent', () => {
adhocFilter: simpleMultiAdhocFilter,
});
const { onOperatorChange } = useSimpleTabFilterProps(props);
onOperatorChange(Operators.LESS_THAN);
onOperatorChange(Operators.LessThan);
expect(props.onChange.calledOnce).toBe(true);
expect(props.onChange.lastCall.args[0]).toEqual(
simpleMultiAdhocFilter.duplicateWith({
operatorId: Operators.LESS_THAN,
operatorId: Operators.LessThan,
operator: '<',
comparator: '10',
}),
Expand Down Expand Up @@ -256,8 +256,8 @@ describe('AdhocFilterEditPopoverSimpleTabContent', () => {
partitionColumn: 'ds',
});
const { isOperatorRelevant } = useSimpleTabFilterProps(props);
expect(isOperatorRelevant(Operators.LATEST_PARTITION, 'ds')).toBe(true);
expect(isOperatorRelevant(Operators.LATEST_PARTITION, 'value')).toBe(false);
expect(isOperatorRelevant(Operators.LatestPartition, 'ds')).toBe(true);
expect(isOperatorRelevant(Operators.LatestPartition, 'value')).toBe(false);
});

it('will generate custom sqlExpression for LATEST PARTITION operator', () => {
Expand All @@ -275,13 +275,13 @@ describe('AdhocFilterEditPopoverSimpleTabContent', () => {
partitionColumn: 'ds',
});
const { onOperatorChange } = useSimpleTabFilterProps(props);
onOperatorChange(Operators.LATEST_PARTITION);
onOperatorChange(Operators.LatestPartition);
expect(props.onChange.calledOnce).toBe(true);
expect(props.onChange.lastCall.args[0]).toEqual(
testAdhocFilter.duplicateWith({
subject: 'ds',
operator: 'LATEST PARTITION',
operatorId: Operators.LATEST_PARTITION,
operatorId: Operators.LatestPartition,
comparator: null,
clause: 'WHERE',
expressionType: 'SQL',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const useSimpleTabFilterProps = (props: Props) => {
!!column && (column.type === 'INT' || column.type === 'INTEGER');
const isColumnFunction = !!column && !!column.expression;

if (operator && operator === Operators.LATEST_PARTITION) {
if (operator && operator === Operators.LatestPartition) {
const { partitionColumn } = props;
return partitionColumn && subject && subject === partitionColumn;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const translateToSql = (
operator &&
// 'LATEST PARTITION' supported callback only
operator ===
OPERATOR_ENUM_TO_OPERATOR_TYPE[Operators.LATEST_PARTITION].operation
OPERATOR_ENUM_TO_OPERATOR_TYPE[Operators.LatestPartition].operation
? OPERATORS_TO_SQL[operator](adhocFilter)
: OPERATORS_TO_SQL[operator];
return getSimpleSQLExpression(subject, op, comparator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,8 @@ export default function VizTypeGallery(props: VizTypeGalleryProps) {

const [activeSection, setActiveSection] = useState<string>(() =>
selectedVizMetadata?.category
? Sections.CATEGORY
: Sections.RECOMMENDED_TAGS,
? Sections.Category
: Sections.RecommendedTags,
);

// get a fuse instance for fuzzy search
Expand Down Expand Up @@ -666,17 +666,17 @@ export default function VizTypeGallery(props: VizTypeGalleryProps) {

const sectionMap = useMemo(
() => ({
[Sections.RECOMMENDED_TAGS]: {
[Sections.RecommendedTags]: {
title: t('Recommended tags'),
icon: <Icons.Tags />,
selectors: RECOMMENDED_TAGS,
},
[Sections.CATEGORY]: {
[Sections.Category]: {
title: t('Category'),
icon: <Icons.Category />,
selectors: categories,
},
[Sections.TAGS]: {
[Sections.Tags]: {
title: t('Tags'),
icon: <Icons.Tags />,
selectors: tags,
Expand All @@ -689,21 +689,18 @@ export default function VizTypeGallery(props: VizTypeGalleryProps) {
if (isActivelySearching) {
return searchResults;
}
if (
activeSelector === ALL_CHARTS &&
activeSection === Sections.ALL_CHARTS
) {
if (activeSelector === ALL_CHARTS && activeSection === Sections.AllCharts) {
return sortedMetadata;
}
if (
activeSection === Sections.CATEGORY &&
activeSection === Sections.Category &&
chartsByCategory[activeSelector]
) {
return chartsByCategory[activeSelector];
}
if (
(activeSection === Sections.TAGS ||
activeSection === Sections.RECOMMENDED_TAGS) &&
(activeSection === Sections.Tags ||
activeSection === Sections.RecommendedTags) &&
chartsByTags[activeSelector]
) {
return chartsByTags[activeSelector];
Expand All @@ -725,13 +722,13 @@ export default function VizTypeGallery(props: VizTypeGalleryProps) {
margin-bottom: 0;
`
}
sectionId={Sections.ALL_CHARTS}
sectionId={Sections.AllCharts}
selector={ALL_CHARTS}
icon={<Icons.Ballot />}
isSelected={
!isActivelySearching &&
ALL_CHARTS === activeSelector &&
Sections.ALL_CHARTS === activeSection
Sections.AllCharts === activeSection
}
onClick={clickSelector}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const SSHTunnelForm = ({
>;
setSSHTunnelLoginMethod: (method: AuthType) => void;
}) => {
const [usePassword, setUsePassword] = useState<AuthType>(AuthType.password);
const [usePassword, setUsePassword] = useState<AuthType>(AuthType.Password);

return (
<Form>
Expand Down Expand Up @@ -126,13 +126,13 @@ const SSHTunnelForm = ({
}}
>
<Radio
value={AuthType.password}
value={AuthType.Password}
data-test="ssh-tunnel-use_password-radio"
>
{t('Password')}
</Radio>
<Radio
value={AuthType.privateKey}
value={AuthType.PrivateKey}
data-test="ssh-tunnel-use_private_key-radio"
>
{t('Private Key & Password')}
Expand All @@ -142,7 +142,7 @@ const SSHTunnelForm = ({
</StyledDiv>
</Col>
</StyledRow>
{usePassword === AuthType.password && (
{usePassword === AuthType.Password && (
<StyledRow gutter={16}>
<Col xs={24}>
<StyledDiv>
Expand Down Expand Up @@ -172,7 +172,7 @@ const SSHTunnelForm = ({
</Col>
</StyledRow>
)}
{usePassword === AuthType.privateKey && (
{usePassword === AuthType.PrivateKey && (
<>
<StyledRow gutter={16}>
<Col xs={24}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const SSHTunnelSwitch = ({
setUseSSHTunneling(changed);
if (!changed) {
setDB({
type: ActionType.removeSSHTunnelConfig,
type: ActionType.RemoveSSHTunnelConfig,
});
}
}}
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/pages/Chart/Chart.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('ChartPage', () => {

beforeEach(() => {
localStorage.setItem(
LocalStorageKeys.dashboard__explore_context,
LocalStorageKeys.DashboardExploreContext,
JSON.stringify({
[dashboardPageId]: {},
}),
Expand Down

0 comments on commit 4bacf57

Please sign in to comment.