scorpiusjs / scorpius

Modular admin solution built with Meteor
http://scorpiusjs.org
MIT License
34 stars 7 forks source link

How to add custom link? #49

Closed JulianKingman closed 7 years ago

JulianKingman commented 7 years ago

I saw this: https://github.com/orionjs/orion/issues/88

But I'm not getting the link to actually show up. Here's what I have:

All in client:

// main.js
import {Meteor} from 'meteor/meteor';
import {scorpius} from 'meteor/scorpiusjs:core';
import './imports/fsDashboard.html';
import './imports/routes';
Meteor.startup(() => {
  scorpius.links.add({
    identifier: 'fantasysuite-dashboard',
    title: 'Admin Functions',
    routeName: 'fsDashboard',
    permission: 'admin',
  });
});
// routes.js
import {Meteor} from 'meteor/meteor';
import {RouterLayer} from 'meteor/nicolaslopezj:router-layer';
import {scorpius} from 'meteor/scorpiusjs:core';

ReactiveTemplates.request('pages.fsDashboard');
RouterLayer.route('/admin/fsDashboard', {
  layout: 'layout',
  template: 'pages.fsDashboard',
  name: 'pages.fsDashboard',
  reactiveTemplates: true,
  controller: scorpius.RouteController,
});
<!--fsDashboard.html-->
<template name="fsDashboard">
  <div class="admin-links">
    <a href="" class="btn">Reset server</a>
    <a href="" class="btn">Recalculate points</a>
  </div>
</template>
rwatts3 commented 7 years ago

are you trying to add a standalone link or are you trying to add a link connected to a collection?

JulianKingman commented 7 years ago

Standalone, to a custom template (fsDashboard).

JulianKingman commented 7 years ago

After looking at examples, I realized what was wrong. The permissions were wrong, and I needed to add the template by the right name:

/**
 * Created by Julian on 3/22/17.
 */
import { Meteor } from 'meteor/meteor';
import { scorpius } from 'meteor/scorpiusjs:core';
import './imports/fsDashboard.html';
import './imports/routes';
//
Meteor.startup(() => {
  ReactiveTemplates.set('fsDashboard', 'fsDashboard');
  scorpius.links.add({
    identifier: 'fantasysuite-dashboard',
    title: 'Admin Functions',
    routeName: 'fsDashboard',
    permission: 'config.update',
    index: 40,
  });
});