Skip to content

Commit

Permalink
Use default selected datacontext when joining with an existing dataco…
Browse files Browse the repository at this point in the history
…ntext.
  • Loading branch information
tealefristoe committed Sep 15, 2024
1 parent 78fffcb commit dee2ff7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default class App extends Component {
const setState = (state: Partial<IState>) => this.setState(state);
const handleJoinShareIdChange = (event: ChangeEvent<HTMLInputElement>) => this.handleJoinShareIdChange(event);
const handleDataLabelChange = (event: ChangeEvent<HTMLInputElement>) => this.handleDataLabelChange(event);
const joinShare = () => this.joinShare();
const joinShare = (dataContextName?: string) => this.joinShare(dataContextName);
const handleDataContextChange = (event: ChangeEvent<HTMLSelectElement>) => this.handleDataContextChange(event);
const initiateShare = (selectedContext?: string) => {
if (selectedContext) {
Expand Down Expand Up @@ -381,10 +381,10 @@ export default class App extends Component {
}
};

joinShare = async () => {
joinShare = async (dataContextName?: string) => {
await this.updatePersonalDataLabelAndKey();
const {joinShareId: shareId, personalDataKey, personalDataLabel, selectedDataContext,
joinAndMergeTable } = this.state;
const {joinShareId: shareId, personalDataKey, personalDataLabel, joinAndMergeTable } = this.state;
const selectedDataContext = dataContextName ?? this.state.selectedDataContext

this.setState({ isInProcessOfSharing: true });
try {
Expand Down
20 changes: 11 additions & 9 deletions src/ui-pages/join-and-merge-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface JoinAndMergeTableProps {
handleDataContextChange: (event: React.ChangeEvent<HTMLSelectElement>) => void;
handleJoinShareIdChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
handleDataLabelChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
joinShare: () => void;
joinShare: (dataContextName?: string) => void;
updateState: (state: Partial<IState>) => void;
}

Expand All @@ -26,13 +26,13 @@ export const JoinAndMergeTable = (props: JoinAndMergeTableProps) => {
<div className="select-stack">
<div>{SELECT_TABLE_TO_MERGE}</div>
{availableContextOptions.length > 0
? <select value={selectedContextOption} onChange={handleDataContextChange}>
{availableContextOptions}
</select>
: <div className="warning">
{NO_TABLES_TO_MERGE}
</div>
}
? <select value={selectedContextOption} onChange={handleDataContextChange}>
{availableContextOptions}
</select>
: <div className="warning">
{NO_TABLES_TO_MERGE}
</div>
}
</div>
<div className="input-stack">
<div>{PROVIDE_NAME_OR_LABEL}</div>
Expand All @@ -51,7 +51,9 @@ export const JoinAndMergeTable = (props: JoinAndMergeTableProps) => {
</button>
<button
disabled={!selectedContextOption || !joinShareId || (!personalDataLabel && !lastPersonalDataLabel)}
onClick={joinShare}>{BEGIN_COLLABORATION}
onClick={() => joinShare(selectedContextOption)}
>
{BEGIN_COLLABORATION}
</button>
</div>
</div>
Expand Down

0 comments on commit dee2ff7

Please sign in to comment.