Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 423c515

Browse files
committed
Consolidate AddExistingToSpace between Dialog and Just Me integrated flow
1 parent 654ce95 commit 423c515

File tree

3 files changed

+205
-235
lines changed

3 files changed

+205
-235
lines changed

res/css/views/dialogs/_AddExistingToSpaceDialog.scss

Lines changed: 84 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,90 @@ limitations under the License.
105105
mask-position: center;
106106
}
107107
}
108+
109+
.mx_AddExistingToSpace_footer {
110+
display: flex;
111+
margin-top: 20px;
112+
113+
> span {
114+
flex-grow: 1;
115+
font-size: $font-12px;
116+
line-height: $font-15px;
117+
color: $secondary-fg-color;
118+
119+
.mx_ProgressBar {
120+
height: 8px;
121+
width: 100%;
122+
123+
@mixin ProgressBarBorderRadius 8px;
124+
}
125+
126+
.mx_AddExistingToSpace_progressText {
127+
margin-top: 8px;
128+
font-size: $font-15px;
129+
line-height: $font-24px;
130+
color: $primary-fg-color;
131+
}
132+
133+
> * {
134+
vertical-align: middle;
135+
}
136+
}
137+
138+
.mx_AddExistingToSpace_error {
139+
padding-left: 12px;
140+
141+
> img {
142+
align-self: center;
143+
}
144+
145+
.mx_AddExistingToSpace_errorHeading {
146+
font-weight: $font-semi-bold;
147+
font-size: $font-15px;
148+
line-height: $font-18px;
149+
color: $notice-primary-color;
150+
}
151+
152+
.mx_AddExistingToSpace_errorCaption {
153+
margin-top: 4px;
154+
font-size: $font-12px;
155+
line-height: $font-15px;
156+
color: $primary-fg-color;
157+
}
158+
}
159+
160+
.mx_AccessibleButton {
161+
display: inline-block;
162+
align-self: center;
163+
}
164+
165+
.mx_AccessibleButton_kind_primary {
166+
padding: 8px 36px;
167+
}
168+
169+
.mx_AddExistingToSpace_retryButton {
170+
margin-left: 12px;
171+
padding-left: 24px;
172+
position: relative;
173+
174+
&::before {
175+
content: '';
176+
position: absolute;
177+
background-color: $primary-fg-color;
178+
mask-repeat: no-repeat;
179+
mask-position: center;
180+
mask-size: contain;
181+
mask-image: url('$(res)/img/element-icons/retry.svg');
182+
width: 18px;
183+
height: 18px;
184+
left: 0;
185+
}
186+
}
187+
188+
.mx_AccessibleButton_kind_link {
189+
padding: 0;
190+
}
191+
}
108192
}
109193

110194
.mx_AddExistingToSpaceDialog {
@@ -189,88 +273,4 @@ limitations under the License.
189273
.mx_AddExistingToSpace {
190274
display: contents;
191275
}
192-
193-
.mx_AddExistingToSpaceDialog_footer {
194-
display: flex;
195-
margin-top: 20px;
196-
197-
> span {
198-
flex-grow: 1;
199-
font-size: $font-12px;
200-
line-height: $font-15px;
201-
color: $secondary-fg-color;
202-
203-
.mx_ProgressBar {
204-
height: 8px;
205-
width: 100%;
206-
207-
@mixin ProgressBarBorderRadius 8px;
208-
}
209-
210-
.mx_AddExistingToSpaceDialog_progressText {
211-
margin-top: 8px;
212-
font-size: $font-15px;
213-
line-height: $font-24px;
214-
color: $primary-fg-color;
215-
}
216-
217-
> * {
218-
vertical-align: middle;
219-
}
220-
}
221-
222-
.mx_AddExistingToSpaceDialog_error {
223-
padding-left: 12px;
224-
225-
> img {
226-
align-self: center;
227-
}
228-
229-
.mx_AddExistingToSpaceDialog_errorHeading {
230-
font-weight: $font-semi-bold;
231-
font-size: $font-15px;
232-
line-height: $font-18px;
233-
color: $notice-primary-color;
234-
}
235-
236-
.mx_AddExistingToSpaceDialog_errorCaption {
237-
margin-top: 4px;
238-
font-size: $font-12px;
239-
line-height: $font-15px;
240-
color: $primary-fg-color;
241-
}
242-
}
243-
244-
.mx_AccessibleButton {
245-
display: inline-block;
246-
align-self: center;
247-
}
248-
249-
.mx_AccessibleButton_kind_primary {
250-
padding: 8px 36px;
251-
}
252-
253-
.mx_AddExistingToSpaceDialog_retryButton {
254-
margin-left: 12px;
255-
padding-left: 24px;
256-
position: relative;
257-
258-
&::before {
259-
content: '';
260-
position: absolute;
261-
background-color: $primary-fg-color;
262-
mask-repeat: no-repeat;
263-
mask-position: center;
264-
mask-size: contain;
265-
mask-image: url('$(res)/img/element-icons/retry.svg');
266-
width: 18px;
267-
height: 18px;
268-
left: 0;
269-
}
270-
}
271-
272-
.mx_AccessibleButton_kind_link {
273-
padding: 0;
274-
}
275-
}
276276
}

src/components/structures/SpaceRoomView.tsx

Lines changed: 7 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -517,70 +517,25 @@ const SpaceSetupFirstRooms = ({ space, title, description, onFinished }) => {
517517
};
518518

519519
const SpaceAddExistingRooms = ({ space, onFinished }) => {
520-
const [selectedToAdd, setSelectedToAdd] = useState(new Set<Room>());
521-
522-
const [busy, setBusy] = useState(false);
523-
const [error, setError] = useState("");
524-
525-
let onClick = onFinished;
526-
let buttonLabel = _t("Skip for now");
527-
if (selectedToAdd.size > 0) {
528-
onClick = async () => {
529-
setBusy(true);
530-
531-
for (const room of selectedToAdd) {
532-
const via = calculateRoomVia(room);
533-
try {
534-
await SpaceStore.instance.addRoomToSpace(space, room.roomId, via).catch(async e => {
535-
if (e.errcode === "M_LIMIT_EXCEEDED") {
536-
await sleep(e.data.retry_after_ms);
537-
return SpaceStore.instance.addRoomToSpace(space, room.roomId, via); // retry
538-
}
539-
540-
throw e;
541-
});
542-
} catch (e) {
543-
console.error("Failed to add rooms to space", e);
544-
setError(_t("Failed to add rooms to space"));
545-
break;
546-
}
547-
}
548-
setBusy(false);
549-
onFinished();
550-
};
551-
buttonLabel = busy ? _t("Adding...") : _t("Add");
552-
}
553-
554520
return <div>
555521
<h1>{ _t("What do you want to organise?") }</h1>
556522
<div className="mx_SpaceRoomView_description">
557523
{ _t("Pick rooms or conversations to add. This is just a space for you, " +
558524
"no one will be informed. You can add more later.") }
559525
</div>
560526

561-
{ error && <div className="mx_SpaceRoomView_errorText">{ error }</div> }
562-
563527
<AddExistingToSpace
564528
space={space}
565-
selected={selectedToAdd}
566-
onChange={(checked, room) => {
567-
if (checked) {
568-
selectedToAdd.add(room);
569-
} else {
570-
selectedToAdd.delete(room);
571-
}
572-
setSelectedToAdd(new Set(selectedToAdd));
573-
}}
529+
emptySelectionButton={
530+
<AccessibleButton kind="primary" onClick={onFinished}>
531+
{ _t("Skip for now") }
532+
</AccessibleButton>
533+
}
534+
onFinished={onFinished}
574535
/>
575536

576537
<div className="mx_SpaceRoomView_buttons">
577-
<AccessibleButton
578-
kind="primary"
579-
disabled={busy}
580-
onClick={onClick}
581-
>
582-
{ buttonLabel }
583-
</AccessibleButton>
538+
584539
</div>
585540
<SpaceFeedbackPrompt />
586541
</div>;

0 commit comments

Comments
 (0)