Skip to content

Commit 8c811a2

Browse files
committed
compose: Replace compose box with error banner for archived channels
1 parent ed07d51 commit 8c811a2

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

lib/widgets/compose_box.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,8 +1423,10 @@ class _ComposeBoxState extends State<ComposeBox> with PerAccountStoreAwareStateM
14231423
case ChannelNarrow(:final streamId):
14241424
case TopicNarrow(:final streamId):
14251425
final channel = store.streams[streamId];
1426-
if (channel == null || !store.hasPostingPermission(inChannel: channel,
1427-
user: store.selfUser, byDate: DateTime.now())) {
1426+
if (channel == null
1427+
|| !store.hasPostingPermission(inChannel: channel,
1428+
user: store.selfUser, byDate: DateTime.now())
1429+
|| channel.isArchived) {
14281430
return _ErrorBanner(label:
14291431
ZulipLocalizations.of(context).errorBannerCannotPostInChannelLabel);
14301432
}

test/widgets/compose_box_test.dart

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,34 @@ void main() {
951951
});
952952
});
953953

954+
group('in channel/topic narrow with archived channels', () {
955+
void checkComposeBox({required bool isShown}) => checkComposeBoxIsShown(isShown,
956+
bannerLabel: zulipLocalizations.errorBannerCannotPostInChannelLabel);
957+
958+
final narrowTestCases = [
959+
('channel', const ChannelNarrow(1)),
960+
('topic', eg.topicNarrow(1, 'topic')),
961+
];
962+
963+
for (final (String narrowType, Narrow narrow) in narrowTestCases) {
964+
testWidgets('error banner is shown in $narrowType narrow', (tester) async {
965+
await prepareComposeBox(tester,
966+
narrow: narrow,
967+
selfUser: eg.user(),
968+
streams: [eg.stream(streamId: 1, isArchived: true)]);
969+
checkComposeBox(isShown: false);
970+
});
971+
972+
testWidgets('compose box is shown in $narrowType narrow', (tester) async {
973+
await prepareComposeBox(tester,
974+
narrow: narrow,
975+
selfUser: eg.user(role: UserRole.administrator),
976+
streams: [eg.stream(streamId: 1, isArchived: false)]);
977+
checkComposeBox(isShown: true);
978+
});
979+
}
980+
});
981+
954982
group('in channel/topic narrow according to channel post policy', () {
955983
void checkComposeBox({required bool isShown}) => checkComposeBoxIsShown(isShown,
956984
bannerLabel: zulipLocalizations.errorBannerCannotPostInChannelLabel);

0 commit comments

Comments
 (0)