Add ref= argument to splore to view specific ref.

This commit is contained in:
Benjamin Kalman
2016-02-25 17:39:20 -08:00
parent d0fd0ca079
commit 1c4d4d83da

View File

@@ -37,10 +37,16 @@ function load() {
}
httpStore = new HttpStore(hash.server, undefined, opts);
httpStore.getRoot().then(ref => {
const setRootRef = ref => {
rootRef = ref;
handleChunkLoad(ref, ref);
});
};
if (hash.ref) {
setRootRef(Ref.parse(hash.ref));
} else {
httpStore.getRoot().then(setRootRef);
}
}
function formatKeyString(v: any): string {
@@ -194,11 +200,14 @@ function handleNodeClick(e: MouseEvent, id: string) {
}
}
function setServer(url: string, token: ?string) {
function setServer(url: string, token: ?string, ref: ?string) {
let hash = `server=${url}`;
if (token) {
hash += '&token=' + token;
}
if (ref) {
hash += '&ref=' + ref;
}
location.hash = hash;
}
@@ -218,20 +227,24 @@ class Prompt extends React.Component<void, {}, PromptState> {
return <div style={{display: 'flex', height: '100%', alignItems: 'center',
justifyContent: 'center'}}>
<div style={fontStyle}>
<label>Can haz server?
<div style={{margin:'0.5em 0'}}>
<input type='text' ref='url' autoFocus={true} style={inputStyle}
defaultValue='http://api.noms.io/-/ds/[user]'/><br/>
<input type='text' ref='token' style={inputStyle}
placeholder='auth token'/>
</div>
</label>
<div>
<button onClick={() => setServer(this.refs.url.value, this.refs.token.value)}>OK</button>
</div>
Can haz server?
<form style={{margin:'0.5em 0'}} onSubmit={() => this._handleOnSubmit()}>
<input type='text' ref='url' autoFocus={true} style={inputStyle}
defaultValue='http://api.noms.io/-/ds/[user]'/><br/>
<input type='text' ref='token' style={inputStyle}
placeholder='auth token'/>
<input type='text' ref='ref' style={inputStyle}
placeholder='sha1-xyz (ref to jump to)' />
<button type='submit'>OK</button>
</form>
</div>
</div>;
}
_handleOnSubmit() {
const {url, token, ref} = this.refs;
setServer(url.value, token.value, ref.value);
}
}
function renderPrompt() {