Skip to content

Commit 3a23c56

Browse files
committed
chore(cleanup): remove deprecated preferences code
1 parent 4caaaf0 commit 3a23c56

File tree

6 files changed

+273
-579
lines changed

6 files changed

+273
-579
lines changed

ember-headless-table/src/-private/interfaces/preferences.ts

-22
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ export interface PreferencesAdapter {
1010
* This could allow for saving the data off to an API or local storage.
1111
*/
1212
export interface TablePreferencesData {
13-
/**
14-
* @deprecated columns have no configuration outside of what is provided by plugins
15-
*/
16-
columns?: Record<string, ColumnPreferences>;
1713
/**
1814
* Every plugin has its own namespace for preferences storage.
1915
*
@@ -83,21 +79,3 @@ export interface PluginPreferences {
8379
[columnKey: string]: Record<string, unknown>;
8480
};
8581
}
86-
87-
/**
88-
* @deprecated columns have no configuration outside of what is provided by plugins
89-
*/
90-
export interface ColumnPreferences {
91-
/**
92-
* @deprecated columns have no configuration outside of what is provided by plugins
93-
*/
94-
isVisible?: boolean;
95-
/**
96-
* @deprecated columns have no configuration outside of what is provided by plugins
97-
*/
98-
width?: number;
99-
/**
100-
* @deprecated columns have no configuration outside of what is provided by plugins
101-
*/
102-
position?: number;
103-
}

ember-headless-table/src/-private/preferences.ts

-89
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { TrackedMap } from 'tracked-built-ins';
22

33
import type {
4-
ColumnPreferences,
54
PluginPreferenceFor,
65
PluginPreferences,
76
PreferencesAdapter as Adapter,
@@ -12,11 +11,6 @@ import type {
1211
export class TablePreferences {
1312
storage = new TrackedPreferences();
1413

15-
/**
16-
* @deprecated - preferences must be plugin-based
17-
*/
18-
columnPreferences = new TrackedMap<string, ColumnPreferences>();
19-
2014
constructor(private key: string, private adapter?: Adapter) {
2115
if (this.adapter) {
2216
this.restore(this.adapter);
@@ -27,88 +21,10 @@ export class TablePreferences {
2721
return this.adapter !== undefined;
2822
}
2923

30-
/**
31-
* @deprecated - preferences must be plugin-based
32-
*/
33-
deleteColumnPreference<K extends keyof ColumnPreferences>(columnKey: string, key: K) {
34-
let preferences = this.getColumnPreferences(columnKey);
35-
36-
if (!(key in preferences)) {
37-
return false;
38-
}
39-
40-
let newPreferences = { ...this.getColumnPreferences(columnKey) };
41-
42-
delete newPreferences[key];
43-
44-
if (Object.keys(newPreferences).length === 0) {
45-
this.columnPreferences.delete(columnKey);
46-
} else {
47-
this.columnPreferences.set(columnKey, newPreferences);
48-
}
49-
50-
this.persist();
51-
52-
return true;
53-
}
54-
55-
/**
56-
* @deprecated - preferences must be plugin-based
57-
*/
58-
getColumnPreferences(columnKey: string): ColumnPreferences {
59-
return this.columnPreferences.get(columnKey) ?? {};
60-
}
61-
6224
getIsAtDefault() {
6325
return this.storage.isAtDefault;
6426
}
6527

66-
/**
67-
* @deprecated - preferences must be plugin-based
68-
*/
69-
setColumnPreferences(columnKey: string, value: ColumnPreferences) {
70-
this.columnPreferences.set(columnKey, value);
71-
this.persist();
72-
}
73-
74-
/**
75-
* @deprecated - preferences must be plugin-based
76-
*/
77-
setColumnPreference<K extends keyof ColumnPreferences>(
78-
columnKey: string,
79-
key: K,
80-
value: ColumnPreferences[K]
81-
) {
82-
let preferences = this.getColumnPreferences(columnKey);
83-
let newValue = { ...preferences, [key]: value };
84-
85-
this.columnPreferences.set(columnKey, newValue);
86-
87-
this.persist();
88-
}
89-
90-
/**
91-
* @deprecated - preferences must be plugin-based
92-
* use storage.serialize() instead
93-
*/
94-
toTablePreferencesData() {
95-
let data: TablePreferencesData = {};
96-
97-
let columns: Record<string, ColumnPreferences> = {};
98-
99-
for (let [key, preferences] of this.columnPreferences) {
100-
if (Object.keys(preferences).length > 0) {
101-
columns[key] = preferences;
102-
}
103-
}
104-
105-
if (Object.keys(columns).length > 0) {
106-
data.columns = columns;
107-
}
108-
109-
return data;
110-
}
111-
11228
/**
11329
* Passes a JSON-compatible structure to `adapter.persist`
11430
*
@@ -118,7 +34,6 @@ export class TablePreferences {
11834
*/
11935
persist() {
12036
return this.adapter?.persist?.(this.key, {
121-
...this.toTablePreferencesData(),
12237
...this.storage.serialize(),
12338
});
12439
}
@@ -132,10 +47,6 @@ export class TablePreferences {
13247

13348
if (!data) return;
13449

135-
for (let [key, preferences] of Object.entries(data.columns ?? {})) {
136-
this.columnPreferences.set(key, preferences);
137-
}
138-
13950
return this.storage.restore(data);
14051
}
14152
}

ember-headless-table/src/-private/table.ts

+1-11
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { composeFunctionModifiers } from './utils';
1616

1717
import type { Plugin } from '../plugins';
1818
import type { Class } from '[private-types]';
19-
import type { ColumnKey, ColumnPreferences, Destructor, TableConfig } from '#interfaces';
19+
import type { ColumnKey, Destructor, TableConfig } from '#interfaces';
2020

2121
const DEFAULT_COLUMN_CONFIG = {
2222
isVisible: true,
@@ -342,16 +342,6 @@ export class Table<DataType = unknown> extends Resource<Signature<DataType>> {
342342
this.#page = this.pagination?.page;
343343
}
344344

345-
/**
346-
* @deprecated
347-
*/
348-
getColumnPreference<K extends keyof ColumnPreferences>(
349-
columnKey: ColumnKey<DataType>,
350-
key: K
351-
): ColumnPreferences[K] {
352-
return this.preferences.getColumnPreferences(columnKey)[key];
353-
}
354-
355345
/**
356346
* @private
357347
*/

pnpm-lock.yaml

+73-27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)