Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default workspace rooms to active workspace #34160

Merged
merged 3 commits into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/ValuePicker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function ValuePicker({value, label, items, placeholder, errorText, onInputChange
hidePickerModal();
};

const descStyle = value.length === 0 ? StyleUtils.getFontSizeStyle(variables.fontSizeLabel) : null;
const descStyle = !value || value.length === 0 ? StyleUtils.getFontSizeStyle(variables.fontSizeLabel) : null;
const selectedItem = _.find(items, {value});
const selectedLabel = selectedItem ? selectedItem.label : '';

Expand Down
19 changes: 18 additions & 1 deletion src/pages/workspace/WorkspaceNewRoomPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ const propTypes = {
/** accountID of current user */
accountID: PropTypes.number,
}),

/** policyID for main workspace */
activePolicyID: PropTypes.string,
};
const defaultProps = {
reports: {},
Expand All @@ -88,6 +91,7 @@ const defaultProps = {
session: {
accountID: 0,
},
activePolicyID: null,
};

function WorkspaceNewRoomPage(props) {
Expand All @@ -96,7 +100,7 @@ function WorkspaceNewRoomPage(props) {
const {isOffline} = useNetwork();
const {isSmallScreenWidth} = useWindowDimensions();
const [visibility, setVisibility] = useState(CONST.REPORT.VISIBILITY.RESTRICTED);
const [policyID, setPolicyID] = useState(null);
const [policyID, setPolicyID] = useState(props.activePolicyID);
const [writeCapability, setWriteCapability] = useState(CONST.REPORT.WRITE_CAPABILITIES.ALL);
const wasLoading = usePrevious(props.formState.isLoading);
const visibilityDescription = useMemo(() => translate(`newRoomPage.${visibility}Description`), [translate, visibility]);
Expand Down Expand Up @@ -138,6 +142,13 @@ function WorkspaceNewRoomPage(props) {
Report.clearNewRoomFormError();
}, []);

useEffect(() => {
if (policyID) {
return;
}
setPolicyID(props.activePolicyID);
}, [props.activePolicyID, policyID]);

useEffect(() => {
if (!(((wasLoading && !props.formState.isLoading) || (isOffline && props.formState.isLoading)) && _.isEmpty(props.formState.errorFields))) {
return;
Expand Down Expand Up @@ -296,6 +307,7 @@ function WorkspaceNewRoomPage(props) {
inputID="policyID"
label={translate('workspace.common.workspace')}
items={workspaceOptions}
value={policyID}
onValueChange={setPolicyID}
/>
</View>
Expand Down Expand Up @@ -353,5 +365,10 @@ export default compose(
session: {
key: ONYXKEYS.SESSION,
},
activePolicyID: {
key: ONYXKEYS.ACCOUNT,
selector: (account) => (account && account.activePolicyID) || null,
initialValue: null,
},
}),
)(WorkspaceNewRoomPage);
Loading