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

View File

@@ -163,37 +163,52 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
Widget _buildOrgRow(BuildContext context) { Widget _buildOrgRow(BuildContext context) {
return BlocBuilder<OrganizationBloc, OrganizationState>( return BlocBuilder<OrganizationBloc, OrganizationState>(
builder: (context, state) { builder: (context, state) {
List<Organization> orgs = [];
Organization? selectedOrg;
bool isLoading = false;
if (state is OrganizationLoaded) { if (state is OrganizationLoaded) {
final orgs = state.organizations; orgs = state.organizations;
return Column( selectedOrg = state.selectedOrg;
children: [ isLoading = state.isLoading;
Row( } else if (state is OrganizationLoading) {
children: [ isLoading = true;
...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();
} }
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),
],
);
}, },
); );
} }