Refactor FileExplorer and HomePage to use dynamic orgId instead of hardcoded values

This commit is contained in:
Leon Bösche
2026-01-09 22:44:45 +01:00
parent cfeae0a199
commit a1ff88bfd9
2 changed files with 56 additions and 38 deletions

View File

@@ -234,7 +234,7 @@ class _FileExplorerState extends State<FileExplorer> {
if (newName.isNotEmpty && newName != file.name) {
context.read<FileBrowserBloc>().add(
RenameFile(
orgId: 'org1',
orgId: widget.orgId,
path: file.path,
newName: newName,
),
@@ -361,7 +361,7 @@ class _FileExplorerState extends State<FileExplorer> {
);
if (confirmed == true) {
context.read<FileBrowserBloc>().add(
DeleteFile(orgId: 'org1', path: file.path),
DeleteFile(orgId: widget.orgId, path: file.path),
);
}
}
@@ -725,7 +725,7 @@ class _FileExplorerState extends State<FileExplorer> {
StartUpload(
files: files,
targetPath: '/',
orgId: 'org1',
orgId: widget.orgId,
),
);
}
@@ -747,7 +747,7 @@ class _FileExplorerState extends State<FileExplorer> {
if (folderName != null && folderName.isNotEmpty) {
context.read<FileBrowserBloc>().add(
CreateFolder(
orgId: 'org1',
orgId: widget.orgId,
parentPath: '/',
folderName: folderName,
),
@@ -781,7 +781,7 @@ class _FileExplorerState extends State<FileExplorer> {
onPressed: () {
final parentPath = _getParentPath(state.currentPath);
context.read<FileBrowserBloc>().add(
LoadDirectory(orgId: 'org1', path: parentPath),
LoadDirectory(orgId: widget.orgId, path: parentPath),
);
},
),
@@ -830,7 +830,10 @@ class _FileExplorerState extends State<FileExplorer> {
state.currentPath,
);
context.read<FileBrowserBloc>().add(
LoadDirectory(orgId: 'org1', path: parentPath),
LoadDirectory(
orgId: widget.orgId,
path: parentPath,
),
);
},
),
@@ -888,7 +891,7 @@ class _FileExplorerState extends State<FileExplorer> {
StartUpload(
files: files,
targetPath: '/',
orgId: 'org1',
orgId: widget.orgId,
),
);
}
@@ -910,7 +913,7 @@ class _FileExplorerState extends State<FileExplorer> {
if (folderName != null && folderName.isNotEmpty) {
context.read<FileBrowserBloc>().add(
CreateFolder(
orgId: 'org1',
orgId: widget.orgId,
parentPath: state.currentPath,
folderName: folderName,
),
@@ -965,7 +968,7 @@ class _FileExplorerState extends State<FileExplorer> {
onAcceptWithDetails: (draggedFile) {
context.read<FileBrowserBloc>().add(
MoveFile(
orgId: 'org1',
orgId: widget.orgId,
sourcePath: draggedFile.data.path,
targetPath: file.path,
),

View File

@@ -163,37 +163,52 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
Widget _buildOrgRow(BuildContext context) {
return BlocBuilder<OrganizationBloc, OrganizationState>(
builder: (context, state) {
List<Organization> orgs = [];
Organization? selectedOrg;
bool isLoading = false;
if (state is OrganizationLoaded) {
final orgs = state.organizations;
return Column(
children: [
Row(
children: [
...orgs.map(
(org) => Row(
children: [
_buildOrgButton(
org,
org.id == state.selectedOrg?.id,
() {
context.read<OrganizationBloc>().add(
SelectOrganization(org.id),
);
},
),
const SizedBox(width: 16),
],
),
),
_buildAddButton(() => _showCreateOrgDialog(context)),
],
),
const Divider(height: 1),
],
);
} else {
return const SizedBox.shrink();
orgs = state.organizations;
selectedOrg = state.selectedOrg;
isLoading = state.isLoading;
} else if (state is OrganizationLoading) {
isLoading = true;
}
return Column(
children: [
Row(
children: [
...orgs.map(
(org) => Row(
children: [
_buildOrgButton(org, org.id == selectedOrg?.id, () {
context.read<OrganizationBloc>().add(
SelectOrganization(org.id),
);
}),
const SizedBox(width: 16),
],
),
),
if (isLoading)
SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
valueColor: AlwaysStoppedAnimation<Color>(
AppTheme.accentColor,
),
),
)
else
_buildAddButton(() => _showCreateOrgDialog(context)),
],
),
const Divider(height: 1),
],
);
},
);
}