Skip to content

Commit

Permalink
Rename datasources to rawList
Browse files Browse the repository at this point in the history
  • Loading branch information
aptkingston committed Dec 18, 2024
1 parent 9650b38 commit 54c9718
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packages/builder/src/stores/builder/datasources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ interface InternalDatasource extends Omit<Datasource, "entities"> {
}

interface BuilderDatasourceStore {
datasources: Datasource[]
rawList: Datasource[]
selectedDatasourceId: null | string
}

Expand All @@ -65,8 +65,8 @@ export class DatasourceStore extends DerivedBudiStore<
// able to keep updated unlike the egress generated definition of the
// internal datasource
let internalDS: Datasource | InternalDatasource | undefined =
$store.datasources?.find(ds => ds._id === BUDIBASE_INTERNAL_DB_ID)
let otherDS = $store.datasources?.filter(
$store.rawList?.find(ds => ds._id === BUDIBASE_INTERNAL_DB_ID)
let otherDS = $store.rawList?.filter(
ds => ds._id !== BUDIBASE_INTERNAL_DB_ID
)
if (internalDS) {
Expand Down Expand Up @@ -102,7 +102,7 @@ export class DatasourceStore extends DerivedBudiStore<

super(
{
datasources: [],
rawList: [],
selectedDatasourceId: null,
},
makeDerivedStore
Expand All @@ -123,7 +123,7 @@ export class DatasourceStore extends DerivedBudiStore<
const datasources = await API.getDatasources()
this.store.update(state => ({
...state,
datasources,
rawList: datasources,
}))
}

Expand Down Expand Up @@ -160,7 +160,7 @@ export class DatasourceStore extends DerivedBudiStore<
}

sourceCount(source: string) {
return get(this.store).datasources.filter(
return get(this.store).rawList.filter(
datasource => datasource.source === source
).length
}
Expand Down Expand Up @@ -252,21 +252,21 @@ export class DatasourceStore extends DerivedBudiStore<
if (!datasource) {
this.store.update(state => ({
...state,
datasources: state.datasources.filter(x => x._id !== datasourceId),
rawList: state.rawList.filter(x => x._id !== datasourceId),
}))
tables.removeDatasourceTables(datasourceId)
queries.removeDatasourceQueries(datasourceId)
return
}

// Add new datasource
const index = get(this.store).datasources.findIndex(
const index = get(this.store).rawList.findIndex(
x => x._id === datasource._id
)
if (index === -1) {
this.store.update(state => ({
...state,
datasources: [...state.datasources, datasource],
rawList: [...state.rawList, datasource],
}))

// If this is a new datasource then we should refresh the tables list,
Expand All @@ -277,7 +277,7 @@ export class DatasourceStore extends DerivedBudiStore<
// Update existing datasource
else if (datasource) {
this.store.update(state => {
state.datasources[index] = datasource
state.rawList[index] = datasource
return state
})
}
Expand Down

0 comments on commit 54c9718

Please sign in to comment.