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

Move trustedApplications into basicPreferences #165

Merged
merged 1 commit into from
Aug 27, 2019
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
6 changes: 5 additions & 1 deletion dashboard/basicPreferences.source.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { PaneDefinition } from '../types'
import UI from 'solid-ui'
import { NamedNode, parse } from 'rdflib'
import { renderTrustedApplicationsOptions } from './trustedApplications/trustedApplicationsPane'

const kb = UI.store

export const basicPreferencesPane: PaneDefinition = {
icon: UI.icons.iconBase + 'noun_Sliders_341315_000000.svg',
name: 'basicPreferences',
label: (subject) => {
label: (_subject) => {
return null
},

Expand Down Expand Up @@ -97,6 +98,9 @@ solid:PowerUser a rdfs:Class;
}
const appendedForm = UI.widgets.appendForm(dom, formArea, {}, context.me, preferencesForm, context.preferencesFile, complainIfBad)
appendedForm.style.borderStyle = 'none'

const trustedApplicationSettings = renderTrustedApplicationsOptions(dom)
container.appendChild(trustedApplicationSettings)
}
doRender()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
/* Profile Editing Pane
**
** Unlike most panes, this is available any place whatever the real subject,
** and allows the user to edit their own profile.
**
** Usage: paneRegistry.register('profile/profilePane')
** or standalone script adding onto existing mashlib.
*/

import UI from 'solid-ui'
import { NamedNode, IndexedFormula, sym } from 'rdflib'

import { Namespaces } from 'solid-namespace'

import { getStatementsToAdd, getStatementsToDelete } from './trustedApplicationsUtils'
import { PaneDefinition } from '../types'

const kb: IndexedFormula = UI.store
const ns: Namespaces = UI.ns
Expand All @@ -29,61 +19,47 @@ interface FormElements {
origin: (undefined | NamedNode | HTMLInputElement);
};

const thisPane: PaneDefinition = {
icon: UI.icons.iconBase + 'noun_15177.svg', // Looks like an A - could say it's for Applications?
global: true,
name: 'trustedApplications',
export function renderTrustedApplicationsOptions (dom: HTMLDocument) {
var div = dom.createElement('div')
div.classList.add('trusted-applications-pane')
div.setAttribute('style', 'border: 0.3em solid ' + thisColor + '; border-radius: 0.5em; padding: 0.7em; margin-top:0.7em;')
var table = div.appendChild(dom.createElement('table'))
var main = table.appendChild(dom.createElement('tr'))
var bottom = table.appendChild(dom.createElement('tr'))
var statusArea = bottom.appendChild(dom.createElement('div'))
statusArea.setAttribute('style', 'padding: 0.7em;')

var context = { dom: dom, div: main, statusArea: statusArea, me: null }
UI.authn.logInLoadProfile(context).then((context: any) => {
let subject: NamedNode = context.me

var profile = subject.doc()
var editable = UI.store.updater.editable(profile.uri, kb)

label: function (subject) {
var types = kb.findTypeURIs(subject)
if (types[UI.ns.foaf('Person').uri] || types[UI.ns.vcard('Individual').uri]) {
return 'Manage your trusted applications'
main.appendChild(createText('h3', 'Manage your trusted applications'))

if (!editable) {
main.appendChild(UI.widgets.errorMessageBlock(dom, `Your profile ${subject.doc().uri} is not editable, so we cannot do much here.`))
return
}
return null
},

render: function (subject, dom) {
var div = dom.createElement('div')
div.classList.add('trusted-applications-pane')
div.setAttribute('style', 'border: 0.3em solid ' + thisColor + '; border-radius: 0.5em; padding: 0.7em; margin-top:0.7em;')
var table = div.appendChild(dom.createElement('table'))
var main = table.appendChild(dom.createElement('tr'))
var bottom = table.appendChild(dom.createElement('tr'))
var statusArea = bottom.appendChild(dom.createElement('div'))
statusArea.setAttribute('style', 'padding: 0.7em;')

var context = { dom: dom, div: main, statusArea: statusArea, me: null }
UI.authn.logInLoadProfile(context).then((context: any) => {
let subject: NamedNode = context.me

var profile = subject.doc()
var editable = UI.store.updater.editable(profile.uri, kb)

main.appendChild(createText('h3', 'Manage your trusted applications'))

if (!editable) {
main.appendChild(UI.widgets.errorMessageBlock(dom, `Your profile ${subject.doc().uri} is not editable, so we cannot do much here.`))
return
}

main.appendChild(createText('p', 'Here you can manage the applications you trust.'))

const applicationsTable = createApplicationTable(subject)
main.appendChild(applicationsTable)

main.appendChild(createText('h4', 'Notes'))
main.appendChild(createContainer('ol', [
main.appendChild(createText('li', 'Trusted applications will get access to all resources that you have access to.')),
main.appendChild(createText('li', 'You can limit which modes they have by default.')),
main.appendChild(createText('li', 'They will not gain more access than you have.'))
]))
main.appendChild(createText('p', 'Application URLs must be valid URL. Examples are http://localhost:3000, https://trusted.app, and https://sub.trusted.app.'))
}, (err: any) => {
statusArea.appendChild(UI.widgets.errorMessageBlock(dom, err))
})
return div
} // render()
} //

main.appendChild(createText('p', 'Here you can manage the applications you trust.'))

const applicationsTable = createApplicationTable(subject)
main.appendChild(applicationsTable)

main.appendChild(createText('h4', 'Notes'))
main.appendChild(createContainer('ol', [
main.appendChild(createText('li', 'Trusted applications will get access to all resources that you have access to.')),
main.appendChild(createText('li', 'You can limit which modes they have by default.')),
main.appendChild(createText('li', 'They will not gain more access than you have.'))
]))
main.appendChild(createText('p', 'Application URLs must be valid URL. Examples are http://localhost:3000, https://trusted.app, and https://sub.trusted.app.'))
}, (err: any) => {
statusArea.appendChild(UI.widgets.errorMessageBlock(dom, err))
})
return div
}

function createApplicationTable (subject: NamedNode) {
var applicationsTable = createElement('table', {
Expand Down Expand Up @@ -263,6 +239,4 @@ function generateRandomString () {
return Math.random().toString(36).substring(7)
}

export default thisPane

// ENDS
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ register(require('./sharing/sharingPane.js'))
// The internals pane is always (almost?) the last as it is the least user-friendly
register(require('./internal/internalPane'))

register(require('./trustedApplications/trustedApplicationsPane')) // manage your trusted applications
register(require('./home/homePane'))

// ENDS
1 change: 0 additions & 1 deletion outline/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ module.exports = function (doc) {
return [
{ paneName: 'home', label: 'Your stuff', icon: UI.icons.iconBase + 'noun_547570.svg' },
{ paneName: 'basicPreferences', label: 'Preferences', icon: UI.icons.iconBase + 'noun_Sliders_341315_00000.svg' },
{ paneName: 'trustedApplications', label: 'Trusted Apps', icon: UI.icons.iconBase + 'noun_15177.svg.svg' },
{ paneName: 'editProfile', label: 'Edit your profile', icon: UI.icons.iconBase + 'noun_492246.svg' }
]
.concat(books)
Expand Down
1 change: 0 additions & 1 deletion trustedApplications/trustedApplicationsPane.ts

This file was deleted.