Skip to content

Commit 8118792

Browse files
author
chimnayajith
committed
compose: Replace compose box with error banner for archived channels
1 parent ea31c88 commit 8118792

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

lib/widgets/compose_box.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,7 @@ class _ComposeBoxState extends State<ComposeBox> with PerAccountStoreAwareStateM
14111411
case TopicNarrow(:final streamId):
14121412
final channel = store.streams[streamId];
14131413
if (channel == null || !store.hasPostingPermission(inChannel: channel,
1414-
user: selfUser, byDate: DateTime.now())) {
1414+
user: selfUser, byDate: DateTime.now()) || channel.isArchived) {
14151415
return _ErrorBanner(label:
14161416
ZulipLocalizations.of(context).errorBannerCannotPostInChannelLabel);
14171417
}

test/widgets/compose_box_test.dart

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,34 @@ void main() {
874874
});
875875
});
876876

877+
group('in channel/topic narrow with archived channels', () {
878+
void checkComposeBox({required bool isShown}) => checkComposeBoxIsShown(isShown,
879+
bannerLabel: zulipLocalizations.errorBannerCannotPostInChannelLabel);
880+
881+
final narrowTestCases = [
882+
('channel', const ChannelNarrow(1)),
883+
('topic', eg.topicNarrow(1, 'topic')),
884+
];
885+
886+
for (final (String narrowType, Narrow narrow) in narrowTestCases) {
887+
testWidgets('error banner is shown in $narrowType narrow', (tester) async {
888+
await prepareComposeBox(tester,
889+
narrow: narrow,
890+
selfUser: eg.user(role: UserRole.administrator),
891+
streams: [eg.stream(streamId: 1, isArchived: true)]);
892+
checkComposeBox(isShown: false);
893+
});
894+
895+
testWidgets('compose box is shown in $narrowType narrow', (tester) async {
896+
await prepareComposeBox(tester,
897+
narrow: narrow,
898+
selfUser: eg.user(role: UserRole.administrator),
899+
streams: [eg.stream(streamId: 1, isArchived: false)]);
900+
checkComposeBox(isShown: true);
901+
});
902+
}
903+
});
904+
877905
group('in channel/topic narrow according to channel post policy', () {
878906
void checkComposeBox({required bool isShown}) => checkComposeBoxIsShown(isShown,
879907
bannerLabel: zulipLocalizations.errorBannerCannotPostInChannelLabel);

0 commit comments

Comments
 (0)